provider/openstack: Updating FWaaS and LBaaS v2 Acceptance Tests (#10959)
* provider/openstack: Updating FWaaS acceptance tests * provider/openstack: Updating LBaaS v2 acceptance tests
This commit is contained in:
parent
64051f9214
commit
b55cf9d601
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccOpenStackFWFirewallV1_importBasic(t *testing.T) {
|
||||
resourceName := "openstack_fw_firewall_v1.accept_test"
|
||||
resourceName := "openstack_fw_firewall_v1.fw_1"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -15,7 +15,7 @@ func TestAccOpenStackFWFirewallV1_importBasic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckFWFirewallV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallConfig,
|
||||
Config: testAccFWFirewallV1_basic_1,
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccOpenStackFWPolicyV1_importBasic(t *testing.T) {
|
||||
resourceName := "openstack_fw_policy_v1.accept_test"
|
||||
resourceName := "openstack_fw_policy_v1.policy_1"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -15,7 +15,7 @@ func TestAccOpenStackFWPolicyV1_importBasic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckFWPolicyV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallPolicyConfigAddRules,
|
||||
Config: testAccFWPolicyV1_addRules,
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccOpenStackFWRuleV1_importBasic(t *testing.T) {
|
||||
resourceName := "openstack_fw_rule_v1.accept_test"
|
||||
resourceName := "openstack_fw_rule_v1.rule_1"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -15,7 +15,7 @@ func TestAccOpenStackFWRuleV1_importBasic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckFWRuleV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallRuleConfig,
|
||||
Config: testAccFWRuleV1_basic_2,
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
)
|
||||
|
||||
func TestAccFWFirewallV1_basic(t *testing.T) {
|
||||
|
||||
var policyID *string
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
@ -21,15 +20,16 @@ func TestAccFWFirewallV1_basic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckFWFirewallV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallConfig,
|
||||
Config: testAccFWFirewallV1_basic_1,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWFirewallV1Exists("openstack_fw_firewall_v1.accept_test", "", "", policyID),
|
||||
testAccCheckFWFirewallV1Exists("openstack_fw_firewall_v1.fw_1", "", "", policyID),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testFirewallConfigUpdated,
|
||||
Config: testAccFWFirewallV1_basic_2,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWFirewallV1Exists("openstack_fw_firewall_v1.accept_test", "accept_test", "terraform acceptance test", policyID),
|
||||
testAccCheckFWFirewallV1Exists(
|
||||
"openstack_fw_firewall_v1.fw_1", "fw_1", "terraform acceptance test", policyID),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -37,11 +37,10 @@ func TestAccFWFirewallV1_basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckFWFirewallV1Destroy(s *terraform.State) error {
|
||||
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckOpenstackFirewallDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "openstack_firewall" {
|
||||
|
@ -60,9 +59,7 @@ func testAccCheckFWFirewallV1Destroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
func testAccCheckFWFirewallV1Exists(n, expectedName, expectedDescription string, policyID *string) resource.TestCheckFunc {
|
||||
|
||||
return func(s *terraform.State) error {
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
|
@ -75,7 +72,7 @@ func testAccCheckFWFirewallV1Exists(n, expectedName, expectedDescription string,
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckFirewallExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Exists) Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
var found *firewalls.Firewall
|
||||
|
@ -93,17 +90,21 @@ func testAccCheckFWFirewallV1Exists(n, expectedName, expectedDescription string,
|
|||
break
|
||||
}
|
||||
|
||||
if found.Name != expectedName {
|
||||
return fmt.Errorf("Expected Name to be <%s> but found <%s>", expectedName, found.Name)
|
||||
switch {
|
||||
case found.Name != expectedName:
|
||||
err = fmt.Errorf("Expected Name to be <%s> but found <%s>", expectedName, found.Name)
|
||||
case found.Description != expectedDescription:
|
||||
err = fmt.Errorf("Expected Description to be <%s> but found <%s>",
|
||||
expectedDescription, found.Description)
|
||||
case found.PolicyID == "":
|
||||
err = fmt.Errorf("Policy should not be empty")
|
||||
case policyID != nil && found.PolicyID == *policyID:
|
||||
err = fmt.Errorf("Policy had not been correctly updated. Went from <%s> to <%s>",
|
||||
expectedName, found.Name)
|
||||
}
|
||||
if found.Description != expectedDescription {
|
||||
return fmt.Errorf("Expected Description to be <%s> but found <%s>", expectedDescription, found.Description)
|
||||
}
|
||||
if found.PolicyID == "" {
|
||||
return fmt.Errorf("Policy should not be empty")
|
||||
}
|
||||
if policyID != nil && found.PolicyID == *policyID {
|
||||
return fmt.Errorf("Policy had not been correctly updated. Went from <%s> to <%s>", expectedName, found.Name)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
policyID = &found.PolicyID
|
||||
|
@ -112,25 +113,25 @@ func testAccCheckFWFirewallV1Exists(n, expectedName, expectedDescription string,
|
|||
}
|
||||
}
|
||||
|
||||
const testFirewallConfig = `
|
||||
resource "openstack_fw_firewall_v1" "accept_test" {
|
||||
policy_id = "${openstack_fw_policy_v1.accept_test_policy_1.id}"
|
||||
const testAccFWFirewallV1_basic_1 = `
|
||||
resource "openstack_fw_firewall_v1" "fw_1" {
|
||||
policy_id = "${openstack_fw_policy_v1.policy_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_fw_policy_v1" "accept_test_policy_1" {
|
||||
name = "policy-1"
|
||||
resource "openstack_fw_policy_v1" "policy_1" {
|
||||
name = "policy_1"
|
||||
}
|
||||
`
|
||||
|
||||
const testFirewallConfigUpdated = `
|
||||
resource "openstack_fw_firewall_v1" "accept_test" {
|
||||
name = "accept_test"
|
||||
description = "terraform acceptance test"
|
||||
policy_id = "${openstack_fw_policy_v1.accept_test_policy_2.id}"
|
||||
admin_state_up = true
|
||||
const testAccFWFirewallV1_basic_2 = `
|
||||
resource "openstack_fw_firewall_v1" "fw_1" {
|
||||
name = "fw_1"
|
||||
description = "terraform acceptance test"
|
||||
policy_id = "${openstack_fw_policy_v1.policy_2.id}"
|
||||
admin_state_up = true
|
||||
}
|
||||
|
||||
resource "openstack_fw_policy_v1" "accept_test_policy_2" {
|
||||
name = "policy-2"
|
||||
resource "openstack_fw_policy_v1" "policy_2" {
|
||||
name = "policy_2"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -18,11 +18,10 @@ func TestAccFWPolicyV1_basic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckFWPolicyV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallPolicyConfig,
|
||||
Config: testAccFWPolicyV1_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWPolicyV1Exists(
|
||||
"openstack_fw_policy_v1.accept_test",
|
||||
"", "", 0),
|
||||
"openstack_fw_policy_v1.policy_1", "", "", 0),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -36,11 +35,10 @@ func TestAccFWPolicyV1_addRules(t *testing.T) {
|
|||
CheckDestroy: testAccCheckFWPolicyV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallPolicyConfigAddRules,
|
||||
Config: testAccFWPolicyV1_addRules,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWPolicyV1Exists(
|
||||
"openstack_fw_policy_v1.accept_test",
|
||||
"accept_test", "terraform acceptance test", 2),
|
||||
"openstack_fw_policy_v1.policy_1", "policy_1", "terraform acceptance test", 2),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -54,11 +52,10 @@ func TestAccFWPolicyV1_deleteRules(t *testing.T) {
|
|||
CheckDestroy: testAccCheckFWPolicyV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallPolicyUpdateDeleteRule,
|
||||
Config: testAccFWPolicyV1_deleteRules,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWPolicyV1Exists(
|
||||
"openstack_fw_policy_v1.accept_test",
|
||||
"accept_test", "terraform acceptance test", 1),
|
||||
"openstack_fw_policy_v1.policy_1", "policy_1", "terraform acceptance test", 1),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -66,11 +63,10 @@ func TestAccFWPolicyV1_deleteRules(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckFWPolicyV1Destroy(s *terraform.State) error {
|
||||
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckOpenstackFirewallPolicyDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "openstack_fw_policy_v1" {
|
||||
|
@ -88,9 +84,7 @@ func testAccCheckFWPolicyV1Destroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
func testAccCheckFWPolicyV1Exists(n, name, description string, ruleCount int) resource.TestCheckFunc {
|
||||
|
||||
return func(s *terraform.State) error {
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
|
@ -103,7 +97,7 @@ func testAccCheckFWPolicyV1Exists(n, name, description string, ruleCount int) re
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckFirewallPolicyExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
var found *policies.Policy
|
||||
|
@ -121,60 +115,60 @@ func testAccCheckFWPolicyV1Exists(n, name, description string, ruleCount int) re
|
|||
break
|
||||
}
|
||||
|
||||
if name != found.Name {
|
||||
return fmt.Errorf("Expected name <%s>, but found <%s>", name, found.Name)
|
||||
switch {
|
||||
case name != found.Name:
|
||||
err = fmt.Errorf("Expected name <%s>, but found <%s>", name, found.Name)
|
||||
case description != found.Description:
|
||||
err = fmt.Errorf("Expected description <%s>, but found <%s>", description, found.Description)
|
||||
case ruleCount != len(found.Rules):
|
||||
err = fmt.Errorf("Expected rule count <%d>, but found <%d>", ruleCount, len(found.Rules))
|
||||
}
|
||||
|
||||
if description != found.Description {
|
||||
return fmt.Errorf("Expected description <%s>, but found <%s>", description, found.Description)
|
||||
}
|
||||
|
||||
if ruleCount != len(found.Rules) {
|
||||
return fmt.Errorf("Expected rule count <%d>, but found <%d>", ruleCount, len(found.Rules))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
const testFirewallPolicyConfig = `
|
||||
resource "openstack_fw_policy_v1" "accept_test" {
|
||||
|
||||
const testAccFWPolicyV1_basic = `
|
||||
resource "openstack_fw_policy_v1" "policy_1" {
|
||||
}
|
||||
`
|
||||
|
||||
const testFirewallPolicyConfigAddRules = `
|
||||
resource "openstack_fw_policy_v1" "accept_test" {
|
||||
name = "accept_test"
|
||||
description = "terraform acceptance test"
|
||||
rules = [
|
||||
"${openstack_fw_rule_v1.accept_test_udp_deny.id}",
|
||||
"${openstack_fw_rule_v1.accept_test_tcp_allow.id}"
|
||||
]
|
||||
const testAccFWPolicyV1_addRules = `
|
||||
resource "openstack_fw_policy_v1" "policy_1" {
|
||||
name = "policy_1"
|
||||
description = "terraform acceptance test"
|
||||
rules = [
|
||||
"${openstack_fw_rule_v1.udp_deny.id}",
|
||||
"${openstack_fw_rule_v1.tcp_allow.id}"
|
||||
]
|
||||
}
|
||||
|
||||
resource "openstack_fw_rule_v1" "accept_test_tcp_allow" {
|
||||
protocol = "tcp"
|
||||
action = "allow"
|
||||
resource "openstack_fw_rule_v1" "tcp_allow" {
|
||||
protocol = "tcp"
|
||||
action = "allow"
|
||||
}
|
||||
|
||||
resource "openstack_fw_rule_v1" "accept_test_udp_deny" {
|
||||
protocol = "udp"
|
||||
action = "deny"
|
||||
resource "openstack_fw_rule_v1" "udp_deny" {
|
||||
protocol = "udp"
|
||||
action = "deny"
|
||||
}
|
||||
`
|
||||
|
||||
const testFirewallPolicyUpdateDeleteRule = `
|
||||
resource "openstack_fw_policy_v1" "accept_test" {
|
||||
name = "accept_test"
|
||||
description = "terraform acceptance test"
|
||||
rules = [
|
||||
"${openstack_fw_rule_v1.accept_test_udp_deny.id}"
|
||||
]
|
||||
const testAccFWPolicyV1_deleteRules = `
|
||||
resource "openstack_fw_policy_v1" "policy_1" {
|
||||
name = "policy_1"
|
||||
description = "terraform acceptance test"
|
||||
rules = [
|
||||
"${openstack_fw_rule_v1.udp_deny.id}"
|
||||
]
|
||||
}
|
||||
|
||||
resource "openstack_fw_rule_v1" "accept_test_udp_deny" {
|
||||
protocol = "udp"
|
||||
action = "deny"
|
||||
resource "openstack_fw_rule_v1" "udp_deny" {
|
||||
protocol = "udp"
|
||||
action = "deny"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -13,60 +13,61 @@ import (
|
|||
)
|
||||
|
||||
func TestAccFWRuleV1_basic(t *testing.T) {
|
||||
rule1 := &rules.Rule{
|
||||
Name: "rule_1",
|
||||
Protocol: "udp",
|
||||
Action: "deny",
|
||||
IPVersion: 4,
|
||||
Enabled: true,
|
||||
}
|
||||
|
||||
rule2 := &rules.Rule{
|
||||
Name: "rule_1",
|
||||
Protocol: "udp",
|
||||
Action: "deny",
|
||||
Description: "Terraform accept test",
|
||||
IPVersion: 4,
|
||||
SourceIPAddress: "1.2.3.4",
|
||||
DestinationIPAddress: "4.3.2.0/24",
|
||||
SourcePort: "444",
|
||||
DestinationPort: "555",
|
||||
Enabled: true,
|
||||
}
|
||||
|
||||
rule3 := &rules.Rule{
|
||||
Name: "rule_1",
|
||||
Protocol: "tcp",
|
||||
Action: "allow",
|
||||
Description: "Terraform accept test updated",
|
||||
IPVersion: 4,
|
||||
SourceIPAddress: "1.2.3.0/24",
|
||||
DestinationIPAddress: "4.3.2.8",
|
||||
SourcePort: "666",
|
||||
DestinationPort: "777",
|
||||
Enabled: false,
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckFWRuleV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallRuleMinimalConfig,
|
||||
Config: testAccFWRuleV1_basic_1,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWRuleV1Exists(
|
||||
"openstack_fw_rule_v1.accept_test_minimal",
|
||||
&rules.Rule{
|
||||
Protocol: "udp",
|
||||
Action: "deny",
|
||||
IPVersion: 4,
|
||||
Enabled: true,
|
||||
}),
|
||||
testAccCheckFWRuleV1Exists("openstack_fw_rule_v1.rule_1", rule1),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testFirewallRuleConfig,
|
||||
Config: testAccFWRuleV1_basic_2,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWRuleV1Exists(
|
||||
"openstack_fw_rule_v1.accept_test",
|
||||
&rules.Rule{
|
||||
Name: "accept_test",
|
||||
Protocol: "udp",
|
||||
Action: "deny",
|
||||
Description: "Terraform accept test",
|
||||
IPVersion: 4,
|
||||
SourceIPAddress: "1.2.3.4",
|
||||
DestinationIPAddress: "4.3.2.0/24",
|
||||
SourcePort: "444",
|
||||
DestinationPort: "555",
|
||||
Enabled: true,
|
||||
}),
|
||||
testAccCheckFWRuleV1Exists("openstack_fw_rule_v1.rule_1", rule2),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testFirewallRuleUpdateAllFieldsConfig,
|
||||
Config: testAccFWRuleV1_basic_3,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWRuleV1Exists(
|
||||
"openstack_fw_rule_v1.accept_test",
|
||||
&rules.Rule{
|
||||
Name: "accept_test_updated_2",
|
||||
Protocol: "tcp",
|
||||
Action: "allow",
|
||||
Description: "Terraform accept test updated",
|
||||
IPVersion: 4,
|
||||
SourceIPAddress: "1.2.3.0/24",
|
||||
DestinationIPAddress: "4.3.2.8",
|
||||
SourcePort: "666",
|
||||
DestinationPort: "777",
|
||||
Enabled: false,
|
||||
}),
|
||||
testAccCheckFWRuleV1Exists("openstack_fw_rule_v1.rule_1", rule3),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -74,25 +75,25 @@ func TestAccFWRuleV1_basic(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestAccFWRuleV1_anyProtocol(t *testing.T) {
|
||||
rule := &rules.Rule{
|
||||
Name: "rule_1",
|
||||
Description: "Allow any protocol",
|
||||
Protocol: "",
|
||||
Action: "allow",
|
||||
IPVersion: 4,
|
||||
SourceIPAddress: "192.168.199.0/24",
|
||||
Enabled: true,
|
||||
}
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckFWRuleV1Destroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testFirewallRuleAnyProtocol,
|
||||
Config: testAccFWRuleV1_anyProtocol,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckFWRuleV1Exists(
|
||||
"openstack_fw_rule_v1.rule_1",
|
||||
&rules.Rule{
|
||||
Name: "rule_1",
|
||||
Description: "Allow any protocol",
|
||||
Protocol: "",
|
||||
Action: "allow",
|
||||
IPVersion: 4,
|
||||
SourceIPAddress: "192.168.199.0/24",
|
||||
Enabled: true,
|
||||
}),
|
||||
testAccCheckFWRuleV1Exists("openstack_fw_rule_v1.rule_1", rule),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -100,12 +101,12 @@ func TestAccFWRuleV1_anyProtocol(t *testing.T) {
|
|||
}
|
||||
|
||||
func testAccCheckFWRuleV1Destroy(s *terraform.State) error {
|
||||
|
||||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckOpenstackFirewallRuleDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "openstack_firewall_rule" {
|
||||
continue
|
||||
|
@ -122,9 +123,7 @@ func testAccCheckFWRuleV1Destroy(s *terraform.State) error {
|
|||
}
|
||||
|
||||
func testAccCheckFWRuleV1Exists(n string, expected *rules.Rule) resource.TestCheckFunc {
|
||||
|
||||
return func(s *terraform.State) error {
|
||||
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", n)
|
||||
|
@ -137,7 +136,7 @@ func testAccCheckFWRuleV1Exists(n string, expected *rules.Rule) resource.TestChe
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckFirewallRuleExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
var found *rules.Rule
|
||||
|
@ -168,16 +167,17 @@ func testAccCheckFWRuleV1Exists(n string, expected *rules.Rule) resource.TestChe
|
|||
}
|
||||
}
|
||||
|
||||
const testFirewallRuleMinimalConfig = `
|
||||
resource "openstack_fw_rule_v1" "accept_test_minimal" {
|
||||
const testAccFWRuleV1_basic_1 = `
|
||||
resource "openstack_fw_rule_v1" "rule_1" {
|
||||
name = "rule_1"
|
||||
protocol = "udp"
|
||||
action = "deny"
|
||||
}
|
||||
`
|
||||
|
||||
const testFirewallRuleConfig = `
|
||||
resource "openstack_fw_rule_v1" "accept_test" {
|
||||
name = "accept_test"
|
||||
const testAccFWRuleV1_basic_2 = `
|
||||
resource "openstack_fw_rule_v1" "rule_1" {
|
||||
name = "rule_1"
|
||||
description = "Terraform accept test"
|
||||
protocol = "udp"
|
||||
action = "deny"
|
||||
|
@ -190,9 +190,9 @@ resource "openstack_fw_rule_v1" "accept_test" {
|
|||
}
|
||||
`
|
||||
|
||||
const testFirewallRuleUpdateAllFieldsConfig = `
|
||||
resource "openstack_fw_rule_v1" "accept_test" {
|
||||
name = "accept_test_updated_2"
|
||||
const testAccFWRuleV1_basic_3 = `
|
||||
resource "openstack_fw_rule_v1" "rule_1" {
|
||||
name = "rule_1"
|
||||
description = "Terraform accept test updated"
|
||||
protocol = "tcp"
|
||||
action = "allow"
|
||||
|
@ -205,7 +205,7 @@ resource "openstack_fw_rule_v1" "accept_test" {
|
|||
}
|
||||
`
|
||||
|
||||
const testFirewallRuleAnyProtocol = `
|
||||
const testAccFWRuleV1_anyProtocol = `
|
||||
resource "openstack_fw_rule_v1" "rule_1" {
|
||||
name = "rule_1"
|
||||
description = "Allow any protocol"
|
||||
|
|
|
@ -20,14 +20,16 @@ func TestAccLBV2Listener_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: TestAccLBV2ListenerConfig_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV2ListenerExists(t, "openstack_lb_listener_v2.listener_1", &listener),
|
||||
testAccCheckLBV2ListenerExists("openstack_lb_listener_v2.listener_1", &listener),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: TestAccLBV2ListenerConfig_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("openstack_lb_listener_v2.listener_1", "name", "tf_test_listener_updated"),
|
||||
resource.TestCheckResourceAttr("openstack_lb_listener_v2.listener_1", "connection_limit", "100"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"openstack_lb_listener_v2.listener_1", "name", "listener_1_updated"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"openstack_lb_listener_v2.listener_1", "connection_limit", "100"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -38,7 +40,7 @@ func testAccCheckLBV2ListenerDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2ListenerDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -55,7 +57,7 @@ func testAccCheckLBV2ListenerDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV2ListenerExists(t *testing.T, n string, listener *listeners.Listener) resource.TestCheckFunc {
|
||||
func testAccCheckLBV2ListenerExists(n string, listener *listeners.Listener) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -69,7 +71,7 @@ func testAccCheckLBV2ListenerExists(t *testing.T, n string, listener *listeners.
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2ListenerExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := listeners.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -87,56 +89,56 @@ func testAccCheckLBV2ListenerExists(t *testing.T, n string, listener *listeners.
|
|||
}
|
||||
}
|
||||
|
||||
var TestAccLBV2ListenerConfig_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2ListenerConfig_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener"
|
||||
}
|
||||
`)
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
var TestAccLBV2ListenerConfig_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2ListenerConfig_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener_updated"
|
||||
connection_limit = 100
|
||||
admin_state_up = "true"
|
||||
}
|
||||
`)
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1_updated"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
connection_limit = 100
|
||||
admin_state_up = "true"
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -21,14 +21,17 @@ func TestAccLBV2LoadBalancer_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: TestAccLBV2LoadBalancerConfig_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV2LoadBalancerExists(t, "openstack_lb_loadbalancer_v2.loadbalancer_1", &lb),
|
||||
testAccCheckLBV2LoadBalancerExists("openstack_lb_loadbalancer_v2.loadbalancer_1", &lb),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: TestAccLBV2LoadBalancerConfig_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("openstack_lb_loadbalancer_v2.loadbalancer_1", "name", "tf_test_loadbalancer_v2_updated"),
|
||||
resource.TestMatchResourceAttr("openstack_lb_loadbalancer_v2.loadbalancer_1", "vip_port_id", regexp.MustCompile("^[a-f0-9-]+")),
|
||||
resource.TestCheckResourceAttr(
|
||||
"openstack_lb_loadbalancer_v2.loadbalancer_1", "name", "loadbalancer_1_updated"),
|
||||
resource.TestMatchResourceAttr(
|
||||
"openstack_lb_loadbalancer_v2.loadbalancer_1", "vip_port_id",
|
||||
regexp.MustCompile("^[a-f0-9-]+")),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -39,7 +42,7 @@ func testAccCheckLBV2LoadBalancerDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2LoadBalancerDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -56,7 +59,7 @@ func testAccCheckLBV2LoadBalancerDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV2LoadBalancerExists(t *testing.T, n string, lb *loadbalancers.LoadBalancer) resource.TestCheckFunc {
|
||||
func testAccCheckLBV2LoadBalancerExists(n string, lb *loadbalancers.LoadBalancer) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -70,7 +73,7 @@ func testAccCheckLBV2LoadBalancerExists(t *testing.T, n string, lb *loadbalancer
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2LoadBalancerExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := loadbalancers.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -88,40 +91,41 @@ func testAccCheckLBV2LoadBalancerExists(t *testing.T, n string, lb *loadbalancer
|
|||
}
|
||||
}
|
||||
|
||||
var TestAccLBV2LoadBalancerConfig_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2LoadBalancerConfig_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}`)
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
var TestAccLBV2LoadBalancerConfig_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2LoadBalancerConfig_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2_updated"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
`)
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1_updated"
|
||||
admin_state_up = "true"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestAccLBV2Member_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: TestAccLBV2MemberConfig_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV2MemberExists(t, "openstack_lb_member_v2.member_1", &member),
|
||||
testAccCheckLBV2MemberExists("openstack_lb_member_v2.member_1", &member),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
|
@ -37,7 +37,7 @@ func testAccCheckLBV2MemberDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2MemberDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -45,7 +45,8 @@ func testAccCheckLBV2MemberDestroy(s *terraform.State) error {
|
|||
continue
|
||||
}
|
||||
|
||||
_, err := pools.GetMember(networkingClient, rs.Primary.Attributes["pool_id"], rs.Primary.ID).Extract()
|
||||
poolId := rs.Primary.Attributes["pool_id"]
|
||||
_, err := pools.GetMember(networkingClient, poolId, rs.Primary.ID).Extract()
|
||||
if err == nil {
|
||||
return fmt.Errorf("Member still exists: %s", rs.Primary.ID)
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ func testAccCheckLBV2MemberDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV2MemberExists(t *testing.T, n string, member *pools.Member) resource.TestCheckFunc {
|
||||
func testAccCheckLBV2MemberExists(n string, member *pools.Member) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -68,10 +69,11 @@ func testAccCheckLBV2MemberExists(t *testing.T, n string, member *pools.Member)
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2MemberExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := pools.GetMember(networkingClient, rs.Primary.Attributes["pool_id"], rs.Primary.ID).Extract()
|
||||
poolId := rs.Primary.Attributes["pool_id"]
|
||||
found, err := pools.GetMember(networkingClient, poolId, rs.Primary.ID).Extract()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -86,82 +88,84 @@ func testAccCheckLBV2MemberExists(t *testing.T, n string, member *pools.Member)
|
|||
}
|
||||
}
|
||||
|
||||
var TestAccLBV2MemberConfig_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2MemberConfig_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener"
|
||||
}
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
name = "tf_test_pool"
|
||||
}
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v2" "member_1" {
|
||||
address = "192.168.199.10"
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
protocol_port = 8080
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}`)
|
||||
resource "openstack_lb_member_v2" "member_1" {
|
||||
address = "192.168.199.10"
|
||||
protocol_port = 8080
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
var TestAccLBV2MemberConfig_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2MemberConfig_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener"
|
||||
}
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
name = "tf_test_pool"
|
||||
}
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_member_v2" "member_1" {
|
||||
address = "192.168.199.10"
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
protocol_port = 8080
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
weight = 10
|
||||
admin_state_up = "true"
|
||||
}`)
|
||||
resource "openstack_lb_member_v2" "member_1" {
|
||||
address = "192.168.199.10"
|
||||
protocol_port = 8080
|
||||
weight = 10
|
||||
admin_state_up = "true"
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -26,7 +26,8 @@ func TestAccLBV2Monitor_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: TestAccLBV2MonitorConfig_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("openstack_lb_monitor_v2.monitor_1", "name", "tf_test_monitor_updated"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"openstack_lb_monitor_v2.monitor_1", "name", "monitor_1_updated"),
|
||||
resource.TestCheckResourceAttr("openstack_lb_monitor_v2.monitor_1", "delay", "30"),
|
||||
resource.TestCheckResourceAttr("openstack_lb_monitor_v2.monitor_1", "timeout", "15"),
|
||||
),
|
||||
|
@ -39,7 +40,7 @@ func testAccCheckLBV2MonitorDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2MonitorDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -70,7 +71,7 @@ func testAccCheckLBV2MonitorExists(t *testing.T, n string, monitor *monitors.Mon
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2MonitorExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := monitors.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -88,85 +89,87 @@ func testAccCheckLBV2MonitorExists(t *testing.T, n string, monitor *monitors.Mon
|
|||
}
|
||||
}
|
||||
|
||||
var TestAccLBV2MonitorConfig_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2MonitorConfig_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener"
|
||||
}
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
name = "tf_test_pool"
|
||||
}
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_monitor_v2" "monitor_1" {
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
type = "PING"
|
||||
delay = 20
|
||||
timeout = 10
|
||||
max_retries = 5
|
||||
name = "tf_test_monitor"
|
||||
}`)
|
||||
resource "openstack_lb_monitor_v2" "monitor_1" {
|
||||
name = "monitor_1"
|
||||
type = "PING"
|
||||
delay = 20
|
||||
timeout = 10
|
||||
max_retries = 5
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
var TestAccLBV2MonitorConfig_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2MonitorConfig_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener"
|
||||
}
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
name = "tf_test_pool"
|
||||
}
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_monitor_v2" "monitor_1" {
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
type = "PING"
|
||||
delay = 30
|
||||
timeout = 15
|
||||
max_retries = 10
|
||||
name = "tf_test_monitor_updated"
|
||||
admin_state_up = "true"
|
||||
}`)
|
||||
resource "openstack_lb_monitor_v2" "monitor_1" {
|
||||
name = "monitor_1_updated"
|
||||
type = "PING"
|
||||
delay = 30
|
||||
timeout = 15
|
||||
max_retries = 10
|
||||
admin_state_up = "true"
|
||||
pool_id = "${openstack_lb_pool_v2.pool_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -20,13 +20,13 @@ func TestAccLBV2Pool_basic(t *testing.T) {
|
|||
resource.TestStep{
|
||||
Config: TestAccLBV2PoolConfig_basic,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckLBV2PoolExists(t, "openstack_lb_pool_v2.pool_1", &pool),
|
||||
testAccCheckLBV2PoolExists("openstack_lb_pool_v2.pool_1", &pool),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: TestAccLBV2PoolConfig_update,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("openstack_lb_pool_v2.pool_1", "name", "tf_test_pool_update"),
|
||||
resource.TestCheckResourceAttr("openstack_lb_pool_v2.pool_1", "name", "pool_1_updated"),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -37,7 +37,7 @@ func testAccCheckLBV2PoolDestroy(s *terraform.State) error {
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2PoolDestroy) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
|
@ -54,7 +54,7 @@ func testAccCheckLBV2PoolDestroy(s *terraform.State) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func testAccCheckLBV2PoolExists(t *testing.T, n string, pool *pools.Pool) resource.TestCheckFunc {
|
||||
func testAccCheckLBV2PoolExists(n string, pool *pools.Pool) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
rs, ok := s.RootModule().Resources[n]
|
||||
if !ok {
|
||||
|
@ -68,7 +68,7 @@ func testAccCheckLBV2PoolExists(t *testing.T, n string, pool *pools.Pool) resour
|
|||
config := testAccProvider.Meta().(*Config)
|
||||
networkingClient, err := config.networkingV2Client(OS_REGION_NAME)
|
||||
if err != nil {
|
||||
return fmt.Errorf("(testAccCheckLBV2PoolExists) Error creating OpenStack networking client: %s", err)
|
||||
return fmt.Errorf("Error creating OpenStack networking client: %s", err)
|
||||
}
|
||||
|
||||
found, err := pools.Get(networkingClient, rs.Primary.ID).Extract()
|
||||
|
@ -86,67 +86,69 @@ func testAccCheckLBV2PoolExists(t *testing.T, n string, pool *pools.Pool) resour
|
|||
}
|
||||
}
|
||||
|
||||
var TestAccLBV2PoolConfig_basic = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2PoolConfig_basic = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener"
|
||||
}
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
name = "tf_test_pool"
|
||||
}`)
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
name = "pool_1"
|
||||
protocol = "HTTP"
|
||||
lb_method = "ROUND_ROBIN"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
}
|
||||
`
|
||||
|
||||
var TestAccLBV2PoolConfig_update = fmt.Sprintf(`
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "tf_test_network"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
const TestAccLBV2PoolConfig_update = `
|
||||
resource "openstack_networking_network_v2" "network_1" {
|
||||
name = "network_1"
|
||||
admin_state_up = "true"
|
||||
}
|
||||
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
name = "tf_test_subnet"
|
||||
}
|
||||
resource "openstack_networking_subnet_v2" "subnet_1" {
|
||||
name = "subnet_1"
|
||||
cidr = "192.168.199.0/24"
|
||||
ip_version = 4
|
||||
network_id = "${openstack_networking_network_v2.network_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
name = "tf_test_loadbalancer_v2"
|
||||
}
|
||||
resource "openstack_lb_loadbalancer_v2" "loadbalancer_1" {
|
||||
name = "loadbalancer_1"
|
||||
vip_subnet_id = "${openstack_networking_subnet_v2.subnet_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
name = "tf_test_listener"
|
||||
}
|
||||
resource "openstack_lb_listener_v2" "listener_1" {
|
||||
name = "listener_1"
|
||||
protocol = "HTTP"
|
||||
protocol_port = 8080
|
||||
loadbalancer_id = "${openstack_lb_loadbalancer_v2.loadbalancer_1.id}"
|
||||
}
|
||||
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
protocol = "HTTP"
|
||||
lb_method = "LEAST_CONNECTIONS"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
name = "tf_test_pool_update"
|
||||
admin_state_up = "true"
|
||||
}`)
|
||||
resource "openstack_lb_pool_v2" "pool_1" {
|
||||
name = "pool_1_updated"
|
||||
protocol = "HTTP"
|
||||
lb_method = "LEAST_CONNECTIONS"
|
||||
admin_state_up = "true"
|
||||
listener_id = "${openstack_lb_listener_v2.listener_1.id}"
|
||||
}
|
||||
`
|
||||
|
|
Loading…
Reference in New Issue