Skip to content

Commit

Permalink
Merge pull request #883 from pwzgorilla/stop
Browse files Browse the repository at this point in the history
more ci test for canary update
  • Loading branch information
gorilla authored Aug 16, 2017
2 parents 9538a20 + 7e43345 commit 7df8459
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions integration-test/swan_api_canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,55 @@ func (s *ApiSuite) TestCanaryUpdate(c *check.C) {
c.Assert(counter[vers[0].ID], check.Equals, 3)
c.Assert(counter[vers[1].ID], check.Equals, 2)

// canary continue
body = &types.CanaryUpdateBody{
Instances: 5,
Value: 0.5,
OnFailure: "continue",
Delay: 0.5,
}
s.canaryUpdate(id, body, c)
err = s.waitApp(id, types.OpStatusNoop, time.Second*180, c)
c.Assert(err, check.IsNil)
fmt.Println("TestCanaryUpdate() continued")

// verify app
app = s.inspectApp(id, c)
c.Assert(app.Name, check.Equals, "demo")
c.Assert(app.VersionCount, check.Equals, 2)
c.Assert(len(app.Version), check.Equals, 1)
c.Assert(app.OpStatus, check.Equals, types.OpStatusNoop)

// verify app tasks
tasks = s.listAppTasks(id, c)
c.Assert(len(tasks), check.Equals, 5)

var y int
for _, task := range tasks {
if task.Weight == 100 {
y++
}
}

c.Assert(y, check.Equals, 5)

// verify app versions
vers = s.listAppVersions(id, c)
c.Assert(len(vers), check.Equals, 2)
c.Assert(vers[0].Mem, check.Equals, float64(10))

counter = make(map[string]int)
for _, task := range tasks {
if v, ok := counter[task.Version]; ok {
v++
counter[task.Version] = v
} else {
counter[task.Version] = 1
}
}

c.Assert(counter[vers[0].ID], check.Equals, 5)

// clean up

err = s.removeApp(id, time.Second*10, c)
Expand Down

0 comments on commit 7df8459

Please sign in to comment.