Skip to content

Commit ad0459b

Browse files
authored
Merge pull request gophercloud#3392 from shiftstack/less_random_fewer_errors
acceptance: Prevent 409 when bulk-creating secgroup rules
2 parents dbed7c1 + 0cc4e3f commit ad0459b

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

  • internal/acceptance/openstack/networking/v2/extensions

internal/acceptance/openstack/networking/v2/extensions/extensions.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,18 @@ func CreateSecurityGroupRule(t *testing.T, client *gophercloud.ServiceClient, se
140140
return rule, nil
141141
}
142142

143-
// CreateSecurityGroupRulesBulk will create security group rules with a random name
144-
// and random port between 80 and 99.
143+
// CreateSecurityGroupRulesBulk will create 3 security group rules with ports between 1080 and 1099.
145144
// An error will be returned if one was failed to be created.
146145
func CreateSecurityGroupRulesBulk(t *testing.T, client *gophercloud.ServiceClient, secGroupID string) ([]rules.SecGroupRule, error) {
147146
t.Logf("Attempting to bulk create security group rules in group: %s", secGroupID)
148147

149148
sgRulesCreateOpts := make([]rules.CreateOpts, 3)
150-
for i := range 3 {
151-
description := "Rule description"
152-
fromPort := tools.RandomInt(1080, 1089)
153-
toPort := tools.RandomInt(1090, 1099)
149+
for i := range sgRulesCreateOpts {
150+
fromPort := 1080 + i
151+
toPort := tools.RandomInt(fromPort, 1099)
154152

155153
sgRulesCreateOpts[i] = rules.CreateOpts{
156-
Description: description,
154+
Description: "Rule description",
157155
Direction: "ingress",
158156
EtherType: "IPv4",
159157
SecGroupID: secGroupID,

0 commit comments

Comments
 (0)