Skip to content

Commit 6a72525

Browse files
committed
refactor(test): Adds wait() step to tests
1 parent c10119c commit 6a72525

5 files changed

+12
-5
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
kapacitor-unit
22
notes.md
3+
*.swp
4+
*.swo

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
Kapacitor-unit is a testing framework to make TICK scripts testing easy and
9-
automated. Testing with Kapacitor-unit is as easy as defining the test configuration defining which alerts are expected to trigger when the TICK script ingests specific data.
9+
automated. Testing with Kapacitor-unit is as easy as defining the test configuration saying which alerts are expected to trigger when the TICK script processes specific data.
1010

1111

1212
Read more about the idea and motivation behind kapacitor-unit in

sample/.alert_weather_batch.tick.swp

-12 KB
Binary file not shown.

sample/.test_case_batch.yaml.swp

-12 KB
Binary file not shown.

test/test.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ func (t *Test) Run(k io.Kapacitor, i io.Influxdb) error {
4040
if err != nil {
4141
return err
4242
}
43-
44-
// Change to better mechanism
45-
time.Sleep(3 * time.Second)
46-
43+
t.wait()
4744
err = t.results(k)
4845
if err != nil {
4946
return err
@@ -118,6 +115,14 @@ func (t *Test) setup(k io.Kapacitor, i io.Influxdb) error {
118115
return nil
119116
}
120117

118+
func (t *Test) wait() {
119+
switch t.Type {
120+
case "batch":
121+
// If batch script, waits 3 seconds for batch queries being processed
122+
time.Sleep(3 * time.Second)
123+
}
124+
}
125+
121126
// Deletes data, database and retention policies created to run the test
122127
func (t *Test) teardown(k io.Kapacitor, i io.Influxdb) error {
123128
glog.Info("Teardown test:: ", t.Name)

0 commit comments

Comments
 (0)