Thanks to visit codestin.com
Credit goes to github.com

Skip to content

acceptance: Prevent 409 when bulk-creating secgroup rules #3392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,18 @@ func CreateSecurityGroupRule(t *testing.T, client *gophercloud.ServiceClient, se
return rule, nil
}

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

sgRulesCreateOpts := make([]rules.CreateOpts, 3)
for i := range 3 {
description := "Rule description"
fromPort := tools.RandomInt(1080, 1089)
toPort := tools.RandomInt(1090, 1099)
for i := range sgRulesCreateOpts {
fromPort := 1080 + i
toPort := tools.RandomInt(fromPort, 1099)

sgRulesCreateOpts[i] = rules.CreateOpts{
Description: description,
Description: "Rule description",
Direction: "ingress",
EtherType: "IPv4",
SecGroupID: secGroupID,
Expand Down
Loading