Skip to content

Commit

Permalink
refactor(test): Adds wait() step to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gpestana committed Nov 11, 2017
1 parent c10119c commit 6a72525
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,2 +1,4 @@
kapacitor-unit
notes.md
*.swp
*.swo
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@


Kapacitor-unit is a testing framework to make TICK scripts testing easy and
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.
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.


Read more about the idea and motivation behind kapacitor-unit in
Expand Down
Binary file removed sample/.alert_weather_batch.tick.swp
Binary file not shown.
Binary file removed sample/.test_case_batch.yaml.swp
Binary file not shown.
13 changes: 9 additions & 4 deletions test/test.go
Expand Up @@ -40,10 +40,7 @@ func (t *Test) Run(k io.Kapacitor, i io.Influxdb) error {
if err != nil {
return err
}

// Change to better mechanism
time.Sleep(3 * time.Second)

t.wait()
err = t.results(k)
if err != nil {
return err
Expand Down Expand Up @@ -118,6 +115,14 @@ func (t *Test) setup(k io.Kapacitor, i io.Influxdb) error {
return nil
}

func (t *Test) wait() {
switch t.Type {
case "batch":
// If batch script, waits 3 seconds for batch queries being processed
time.Sleep(3 * time.Second)
}
}

// Deletes data, database and retention policies created to run the test
func (t *Test) teardown(k io.Kapacitor, i io.Influxdb) error {
glog.Info("Teardown test:: ", t.Name)
Expand Down

0 comments on commit 6a72525

Please sign in to comment.