Merge lp:~axwalk/juju-core/lp1303583-provider-azure-tests-gccgo into lp:~go-bot/juju-core/trunk

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 2765
Proposed branch: lp:~axwalk/juju-core/lp1303583-provider-azure-tests-gccgo
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 67 lines (+10/-6)
2 files modified
provider/azure/environ.go (+5/-1)
provider/azure/environ_test.go (+5/-5)
To merge this branch: bzr merge lp:~axwalk/juju-core/lp1303583-provider-azure-tests-gccgo
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+220552@code.launchpad.net

Commit message

provider/azure: fix tests for go1.3/gccgo

Fix a test to use SameContents instead of DeepEquals.
Also, make StopInstances deterministic; it now stops
instances in the order of IDs specified. One of the
StopInstances tests was sending responses in the wrong
order, and that has been rectified.

Fixes lp:1303583

https://codereview.appspot.com/93520047/

Description of the change

provider/azure: fix tests for go1.3/gccgo

Fix a test to use SameContents instead of DeepEquals.
Also, make StopInstances deterministic; it now stops
instances in the order of IDs specified. One of the
StopInstances tests was sending responses in the wrong
order, and that has been rectified.

Fixes lp:1303583

https://codereview.appspot.com/93520047/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :
Download full text (3.9 KiB)

Reviewers: mp+220552_code.launchpad.net,

Message:
Please take a look.

Description:
provider/azure: fix tests for go1.3/gccgo

Fix a test to use SameContents instead of DeepEquals.
Also, make StopInstances deterministic; it now stops
instances in the order of IDs specified. One of the
StopInstances tests was sending responses in the wrong
order, and that has been rectified.

Fixes lp:1303583

https://code.launchpad.net/~axwalk/juju-core/lp1303583-provider-azure-tests-gccgo/+merge/220552

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/93520047/

Affected files (+12, -6 lines):
   A [revision details]
   M provider/azure/environ.go
   M provider/azure/environ_test.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20140522020148-mkgjwj28zqzfxcad
+New revision: <email address hidden>

Index: provider/azure/environ.go
=== modified file 'provider/azure/environ.go'
--- provider/azure/environ.go 2014-05-22 01:35:12 +0000
+++ provider/azure/environ.go 2014-05-22 03:48:17 +0000
@@ -769,15 +769,18 @@

   // Map services to role names we want to delete.
   serviceInstances := make(map[string]map[string]bool)
+ serviceNames := make([]string, 0)
   for _, id := range ids {
    serviceName, roleName := env.splitInstanceId(id)
    if roleName == "" {
     serviceInstances[serviceName] = nil
+ serviceNames = append(serviceNames, serviceName)
    } else {
     deleteRoleNames, ok := serviceInstances[serviceName]
     if !ok {
      deleteRoleNames = make(map[string]bool)
      serviceInstances[serviceName] = deleteRoleNames
+ serviceNames = append(serviceNames, serviceName)
     }
     deleteRoleNames[roleName] = true
    }
@@ -788,7 +791,8 @@
   //
   // Note: concurrent operations on Affinity Groups have been
   // found to cause conflict responses, so we do everything serially.
- for serviceName, deleteRoleNames := range serviceInstances {
+ for _, serviceName := range serviceNames {
+ deleteRoleNames := serviceInstances[serviceName]
    service, err := context.GetHostedServiceProperties(serviceName, true)
    if err != nil {
     return err

Index: provider/azure/environ_test.go
=== modified file 'provider/azure/environ_test.go'
--- provider/azure/environ_test.go 2014-05-14 02:59:53 +0000
+++ provider/azure/environ_test.go 2014-05-22 03:48:17 +0000
@@ -828,8 +828,9 @@
   inst2, err := env.getInstance(service2, service2Role1Name)
   c.Assert(err, gc.IsNil)

- responses := buildGetServicePropertiesResponses(c, service1, service2)
- // Failed to delete one of the services.
+ responses := buildGetServicePropertiesResponses(c, service1)
+ // Failed to delete one of the services. This will cause StopInstances to
stop
+ // immediately.
   responses = append(responses, gwacl.NewDispatcherResponse(nil,
http.StatusConflict, nil))
   requests := gwacl.PatchManagementAPIResponses(responses)

@@ -838,8 +839,7 @@

   c.Check(len(*requests), gc.Equals, len(responses))
   assertOneRequestMatches(c,
*requests, "GET",...

Read more...

Revision history for this message
Dave Cheney (dave-cheney) wrote :

LGTM.

https://codereview.appspot.com/93520047/diff/1/provider/azure/environ.go
File provider/azure/environ.go (right):

https://codereview.appspot.com/93520047/diff/1/provider/azure/environ.go#newcode772
provider/azure/environ.go:772: serviceNames := make([]string, 0)
var serviceNames []string

https://codereview.appspot.com/93520047/

Revision history for this message
Andrew Wilkins (axwalk) wrote :

Please take a look.

https://codereview.appspot.com/93520047/diff/1/provider/azure/environ.go
File provider/azure/environ.go (right):

https://codereview.appspot.com/93520047/diff/1/provider/azure/environ.go#newcode772
provider/azure/environ.go:772: serviceNames := make([]string, 0)
On 2014/05/22 04:30:03, dfc wrote:
> var serviceNames []string

Done.

https://codereview.appspot.com/93520047/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'provider/azure/environ.go'
2--- provider/azure/environ.go 2014-05-22 01:35:12 +0000
3+++ provider/azure/environ.go 2014-05-22 04:37:15 +0000
4@@ -769,15 +769,18 @@
5
6 // Map services to role names we want to delete.
7 serviceInstances := make(map[string]map[string]bool)
8+ var serviceNames []string
9 for _, id := range ids {
10 serviceName, roleName := env.splitInstanceId(id)
11 if roleName == "" {
12 serviceInstances[serviceName] = nil
13+ serviceNames = append(serviceNames, serviceName)
14 } else {
15 deleteRoleNames, ok := serviceInstances[serviceName]
16 if !ok {
17 deleteRoleNames = make(map[string]bool)
18 serviceInstances[serviceName] = deleteRoleNames
19+ serviceNames = append(serviceNames, serviceName)
20 }
21 deleteRoleNames[roleName] = true
22 }
23@@ -788,7 +791,8 @@
24 //
25 // Note: concurrent operations on Affinity Groups have been
26 // found to cause conflict responses, so we do everything serially.
27- for serviceName, deleteRoleNames := range serviceInstances {
28+ for _, serviceName := range serviceNames {
29+ deleteRoleNames := serviceInstances[serviceName]
30 service, err := context.GetHostedServiceProperties(serviceName, true)
31 if err != nil {
32 return err
33
34=== modified file 'provider/azure/environ_test.go'
35--- provider/azure/environ_test.go 2014-05-14 02:59:53 +0000
36+++ provider/azure/environ_test.go 2014-05-22 04:37:15 +0000
37@@ -828,8 +828,9 @@
38 inst2, err := env.getInstance(service2, service2Role1Name)
39 c.Assert(err, gc.IsNil)
40
41- responses := buildGetServicePropertiesResponses(c, service1, service2)
42- // Failed to delete one of the services.
43+ responses := buildGetServicePropertiesResponses(c, service1)
44+ // Failed to delete one of the services. This will cause StopInstances to stop
45+ // immediately.
46 responses = append(responses, gwacl.NewDispatcherResponse(nil, http.StatusConflict, nil))
47 requests := gwacl.PatchManagementAPIResponses(responses)
48
49@@ -838,8 +839,7 @@
50
51 c.Check(len(*requests), gc.Equals, len(responses))
52 assertOneRequestMatches(c, *requests, "GET", ".*"+service1.ServiceName+".*")
53- assertOneRequestMatches(c, *requests, "GET", ".*"+service2.ServiceName+".*")
54- assertOneRequestMatches(c, *requests, "DELETE", ".*("+service1.ServiceName+"|"+service2.ServiceName+").")
55+ assertOneRequestMatches(c, *requests, "DELETE", service1.ServiceName)
56 }
57
58 func (s *environSuite) TestStopInstancesWithZeroInstance(c *gc.C) {
59@@ -1525,7 +1525,7 @@
60 cons := constraints.MustParse("arch=amd64 tags=bar cpu-power=10")
61 unsupported, err := validator.Validate(cons)
62 c.Assert(err, gc.IsNil)
63- c.Assert(unsupported, gc.DeepEquals, []string{"cpu-power", "tags"})
64+ c.Assert(unsupported, jc.SameContents, []string{"cpu-power", "tags"})
65 }
66
67 func (s *environSuite) TestConstraintsValidatorVocab(c *gc.C) {

Subscribers

People subscribed via source and target branches

to status/vote changes: