Skip to content

Commit 3131fb4

Browse files
authored
chore(acceptance-tests): Support config.ListVariable and config.ObjectVariable (#1619)
STACKITTPR-637 Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
1 parent 03a8762 commit 3131fb4

24 files changed

Lines changed: 861 additions & 601 deletions

‎stackit/internal/services/alb/alb_acc_test.go‎

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,30 @@ var testConfigVarsMax = config.Variables{
6060
"tls_config_skip": config.BoolVariable(false),
6161
"tls_config_custom_ca": config.StringVariable("-----BEGIN CERTIFICATE-----\nMIIDCzCCAfOgAwIBAgIUTyPsTWC9ly7o+wNFYm0uu1+P8IEwDQYJKoZIhvcNAQEL\nBQAwFTETMBEGA1UEAwwKTXlDdXN0b21DQTAeFw0yNTAyMTkxOTI0MjBaFw0yNjAy\nMTkxOTI0MjBaMBUxEzARBgNVBAMMCk15Q3VzdG9tQ0EwggEiMA0GCSqGSIb3DQEB\nAQUAA4IBDwAwggEKAoIBAQCQMEYKbiNxU37fEwBOxkvCshBR+0MwxwLW8Mi3/pvo\nn3huxjcm7EaKW9r7kIaoHXbTS1tnO6rHAHKBDxzuoYD7C2SMSiLxddquNRvpkLaP\n8qAXneQY2VP7LzsAgsC04PKG0YC1NgF5sJGsiWIRGIm+csYLnPMnwaAGx4IvY6mH\nAmM64b6QRCg36LK+P6N9KTvSQLvvmFdkA2sDToCmN/Amp6xNDFq+aQGLwdQQqHDP\nTaUqPmEyiFHKvFUaFMNQVk8B1Om8ASo69m8U3Eat4ZOVW1titE393QkOdA6ZypMC\nrJJpeNNLLJq3mIOWOd7GEyAvjUfmJwGhqEFS7lMG67hnAgMBAAGjUzBRMB0GA1Ud\nDgQWBBSk/IM5jaOAJL3/Knyq3cVva04YZDAfBgNVHSMEGDAWgBSk/IM5jaOAJL3/\nKnyq3cVva04YZDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBe\nZ/mE8rNIbNbHQep/VppshaZUzgdy4nsmh0wvxMuHIQP0KHrxLCkhOn7A9fu4mY/P\nQ+8QqlnjTsM4cqiuFcd5V1Nk9VF/e5X3HXCDHh/jBFw+O5TGVAR/7DBw31lYv/Lt\nHakkjQCdawuvH3osO/UkElM/i2KC+iYBavTenm97AR7WGgW15/MIqxNaYE+nJth/\ndcVD0b5qSuYQaEmZ3CzMUi188R+go5ozCf2cOaa+3/LEYAaI3vKiSE8KTsshyoKm\nO6YZqrVxQCWCDTOsd28k7lHt8wJ+jzYcjCu60DUpg1ZpY+ZnmrE8vPPDb/zXhBn6\n/llXTWOUjmuTKnGsIDP5\n-----END CERTIFICATE-----"),
6262
"web_socket": config.BoolVariable(true),
63-
"query_parameters_name_1": config.StringVariable("a"),
64-
"query_parameters_exact_match_1": config.StringVariable("b"),
65-
"query_parameters_name_2": config.StringVariable("c"),
66-
"query_parameters_exact_match_2": config.StringVariable("d"),
67-
"headers_name_1": config.StringVariable("1"),
68-
"headers_exact_match_1": config.StringVariable("2"),
69-
"headers_name_2": config.StringVariable("3"),
70-
"headers_exact_match_2": config.StringVariable("4"),
71-
"headers_name_3": config.StringVariable("5"),
63+
"query_parameters": config.ListVariable(
64+
config.ObjectVariable(map[string]config.Variable{
65+
"name": config.StringVariable("a"),
66+
"exact_match": config.StringVariable("b"),
67+
}),
68+
config.ObjectVariable(map[string]config.Variable{
69+
"name": config.StringVariable("c"),
70+
"exact_match": config.StringVariable("d"),
71+
}),
72+
),
73+
"headers": config.ListVariable(
74+
config.ObjectVariable(map[string]config.Variable{
75+
"name": config.StringVariable("1"),
76+
"exact_match": config.StringVariable("2"),
77+
}),
78+
config.ObjectVariable(map[string]config.Variable{
79+
"name": config.StringVariable("3"),
80+
"exact_match": config.StringVariable("4"),
81+
}),
82+
// the third header intentionally omits exact_match (an optional field)
83+
config.ObjectVariable(map[string]config.Variable{
84+
"name": config.StringVariable("5"),
85+
}),
86+
),
7287
"host_1": config.StringVariable("*"),
7388
"host_3": config.StringVariable("www.example.org"),
7489
"host_4": config.StringVariable("www.*"),
@@ -123,15 +138,29 @@ func configVarsMaxUpdated() config.Variables {
123138
maps.Copy(tempConfig, testConfigVarsMax)
124139
tempConfig["ephemeral_address"] = config.BoolVariable(false)
125140
tempConfig["web_socket"] = config.BoolVariable(false)
126-
tempConfig["query_parameters_name_1"] = config.StringVariable("e")
127-
tempConfig["query_parameters_exact_match_1"] = config.StringVariable("f")
128-
tempConfig["query_parameters_name_2"] = config.StringVariable("g")
129-
tempConfig["query_parameters_exact_match_2"] = config.StringVariable("h")
130-
tempConfig["headers_name_1"] = config.StringVariable("6")
131-
tempConfig["headers_exact_match_1"] = config.StringVariable("7")
132-
tempConfig["headers_name_2"] = config.StringVariable("8")
133-
tempConfig["headers_exact_match_2"] = config.StringVariable("9")
134-
tempConfig["headers_name_3"] = config.StringVariable("0")
141+
tempConfig["query_parameters"] = config.ListVariable(
142+
config.ObjectVariable(map[string]config.Variable{
143+
"name": config.StringVariable("e"),
144+
"exact_match": config.StringVariable("f"),
145+
}),
146+
config.ObjectVariable(map[string]config.Variable{
147+
"name": config.StringVariable("g"),
148+
"exact_match": config.StringVariable("h"),
149+
}),
150+
)
151+
tempConfig["headers"] = config.ListVariable(
152+
config.ObjectVariable(map[string]config.Variable{
153+
"name": config.StringVariable("6"),
154+
"exact_match": config.StringVariable("7"),
155+
}),
156+
config.ObjectVariable(map[string]config.Variable{
157+
"name": config.StringVariable("8"),
158+
"exact_match": config.StringVariable("9"),
159+
}),
160+
config.ObjectVariable(map[string]config.Variable{
161+
"name": config.StringVariable("0"),
162+
}),
163+
)
135164
tempConfig["host_1"] = config.StringVariable("www.example.*")
136165
tempConfig["target_pool_port_1"] = config.StringVariable("444")
137166
tempConfig["ahc_http_ok_status_200"] = config.StringVariable("202")
@@ -343,15 +372,8 @@ func TestAccALBResourceMax(t *testing.T) {
343372
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.host", testutil.ConvertConfigVariable(testConfigVarsMax["host_1"])),
344373
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.target_pool", testutil.ConvertConfigVariable(testConfigVarsMax["target_pool_name_1"])),
345374
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.web_socket", testutil.ConvertConfigVariable(testConfigVarsMax["web_socket"])),
346-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.0.name", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_name_1"])),
347-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.0.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_exact_match_1"])),
348-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.1.name", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_name_2"])),
349-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.1.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_exact_match_2"])),
350-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.0.name", testutil.ConvertConfigVariable(testConfigVarsMax["headers_name_1"])),
351-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.0.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["headers_exact_match_1"])),
352-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.1.name", testutil.ConvertConfigVariable(testConfigVarsMax["headers_name_2"])),
353-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.1.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["headers_exact_match_2"])),
354-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.2.name", testutil.ConvertConfigVariable(testConfigVarsMax["headers_name_3"])),
375+
testutil.CheckListAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters", testConfigVarsMax["query_parameters"]),
376+
testutil.CheckListAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers", testConfigVarsMax["headers"]),
355377
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.path.prefix", testutil.ConvertConfigVariable(testConfigVarsMax["path_prefix_1"])),
356378
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.1.path.prefix", testutil.ConvertConfigVariable(testConfigVarsMax["path_prefix_2"])),
357379
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.1.target_pool", testutil.ConvertConfigVariable(testConfigVarsMax["target_pool_name_2"])),
@@ -439,15 +461,8 @@ func TestAccALBResourceMax(t *testing.T) {
439461
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.host", testutil.ConvertConfigVariable(testConfigVarsMax["host_1"])),
440462
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.target_pool", testutil.ConvertConfigVariable(testConfigVarsMax["target_pool_name_1"])),
441463
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.web_socket", testutil.ConvertConfigVariable(testConfigVarsMax["web_socket"])),
442-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.0.name", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_name_1"])),
443-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.0.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_exact_match_1"])),
444-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.1.name", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_name_2"])),
445-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.1.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["query_parameters_exact_match_2"])),
446-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.0.name", testutil.ConvertConfigVariable(testConfigVarsMax["headers_name_1"])),
447-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.0.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["headers_exact_match_1"])),
448-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.1.name", testutil.ConvertConfigVariable(testConfigVarsMax["headers_name_2"])),
449-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.1.exact_match", testutil.ConvertConfigVariable(testConfigVarsMax["headers_exact_match_2"])),
450-
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.2.name", testutil.ConvertConfigVariable(testConfigVarsMax["headers_name_3"])),
464+
testutil.CheckListAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters", testConfigVarsMax["query_parameters"]),
465+
testutil.CheckListAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers", testConfigVarsMax["headers"]),
451466
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.path.prefix", testutil.ConvertConfigVariable(testConfigVarsMax["path_prefix_1"])),
452467
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.1.path.prefix", testutil.ConvertConfigVariable(testConfigVarsMax["path_prefix_2"])),
453468
resource.TestCheckResourceAttr("data.stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.1.target_pool", testutil.ConvertConfigVariable(testConfigVarsMax["target_pool_name_2"])),
@@ -598,15 +613,8 @@ func TestAccALBResourceMax(t *testing.T) {
598613
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "options.ephemeral_address", testutil.ConvertConfigVariable(configVarsMaxUpdated()["ephemeral_address"])),
599614
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.host", testutil.ConvertConfigVariable(configVarsMaxUpdated()["host_1"])),
600615
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.web_socket", testutil.ConvertConfigVariable(configVarsMaxUpdated()["web_socket"])),
601-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.0.name", testutil.ConvertConfigVariable(configVarsMaxUpdated()["query_parameters_name_1"])),
602-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.0.exact_match", testutil.ConvertConfigVariable(configVarsMaxUpdated()["query_parameters_exact_match_1"])),
603-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.1.name", testutil.ConvertConfigVariable(configVarsMaxUpdated()["query_parameters_name_2"])),
604-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters.1.exact_match", testutil.ConvertConfigVariable(configVarsMaxUpdated()["query_parameters_exact_match_2"])),
605-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.0.name", testutil.ConvertConfigVariable(configVarsMaxUpdated()["headers_name_1"])),
606-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.0.exact_match", testutil.ConvertConfigVariable(configVarsMaxUpdated()["headers_exact_match_1"])),
607-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.1.name", testutil.ConvertConfigVariable(configVarsMaxUpdated()["headers_name_2"])),
608-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.1.exact_match", testutil.ConvertConfigVariable(configVarsMaxUpdated()["headers_exact_match_2"])),
609-
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers.2.name", testutil.ConvertConfigVariable(configVarsMaxUpdated()["headers_name_3"])),
616+
testutil.CheckListAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.query_parameters", configVarsMaxUpdated()["query_parameters"]),
617+
testutil.CheckListAttr("stackit_application_load_balancer.loadbalancer", "listeners.0.http.hosts.0.rules.0.headers", configVarsMaxUpdated()["headers"]),
610618
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "target_pools.0.target_port", testutil.ConvertConfigVariable(configVarsMaxUpdated()["target_pool_port_1"])),
611619
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "target_pools.0.active_health_check.timeout", testutil.ConvertConfigVariable(configVarsMaxUpdated()["ahc_timeout"])),
612620
resource.TestCheckResourceAttr("stackit_application_load_balancer.loadbalancer", "target_pools.0.active_health_check.healthy_threshold", testutil.ConvertConfigVariable(configVarsMaxUpdated()["ahc_healthy_threshold"])),

‎stackit/internal/services/alb/testfiles/resource-max.tf‎

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
variable "image_id" {
33
description = "A valid Image ID available in the project for the target server"
44
type = string
5-
default = "939249d1-6f48-4ab7-929b-95170728311a"
5+
default = "d2ef238d-7d1e-4b84-82cc-6f38a5d0c3de"
66
}
77
variable "availability_zone" {
88
description = "The availability zone"
@@ -53,15 +53,8 @@ variable "host_1" {}
5353
variable "target_pool_name_1" {}
5454
variable "target_pool_port_1" {}
5555
variable "web_socket" {}
56-
variable "query_parameters_name_1" {}
57-
variable "query_parameters_exact_match_1" {}
58-
variable "query_parameters_name_2" {}
59-
variable "query_parameters_exact_match_2" {}
60-
variable "headers_name_1" {}
61-
variable "headers_exact_match_1" {}
62-
variable "headers_name_2" {}
63-
variable "headers_exact_match_2" {}
64-
variable "headers_name_3" {}
56+
variable "query_parameters" {}
57+
variable "headers" {}
6558
variable "path_prefix_1" {}
6659
variable "path_prefix_2" {}
6760
variable "target_pool_name_2" {}
@@ -225,24 +218,10 @@ resource "stackit_application_load_balancer" "loadbalancer" {
225218
hosts = [{
226219
host = var.host_1
227220
rules = [{
228-
target_pool = var.target_pool_name_1
229-
web_socket = var.web_socket
230-
query_parameters = [{
231-
name = var.query_parameters_name_1
232-
exact_match = var.query_parameters_exact_match_1
233-
}, {
234-
name = var.query_parameters_name_2
235-
exact_match = var.query_parameters_exact_match_2
236-
}]
237-
headers = [{
238-
name = var.headers_name_1
239-
exact_match = var.headers_exact_match_1
240-
}, {
241-
name = var.headers_name_2
242-
exact_match = var.headers_exact_match_2
243-
}, {
244-
name = var.headers_name_3
245-
}]
221+
target_pool = var.target_pool_name_1
222+
web_socket = var.web_socket
223+
query_parameters = var.query_parameters
224+
headers = var.headers
246225
path = {
247226
prefix = var.path_prefix_1
248227
}

‎stackit/internal/services/alb/testfiles/resource-min.tf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
variable "image_id" {
33
description = "A valid Image ID available in the project for the target server"
44
type = string
5-
default = "939249d1-6f48-4ab7-929b-95170728311a"
5+
default = "d2ef238d-7d1e-4b84-82cc-6f38a5d0c3de"
66
}
77
variable "availability_zone" {
88
description = "The availability zone"

0 commit comments

Comments
 (0)