forked from oracle/terraform-provider-oci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_source_obmcs_loadbalancer_backends_test.go
100 lines (88 loc) · 3.1 KB
/
data_source_obmcs_loadbalancer_backends_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
package main
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccDatasourceLoadBalancerBackends_basic(t *testing.T) {
providers := testAccProviders
config := testProviderConfig() + `
data "oci_identity_availability_domains" "ADs" {
compartment_id = "${var.compartment_id}"
}
resource "oci_core_virtual_network" "t" {
compartment_id = "${var.compartment_id}"
cidr_block = "10.0.0.0/16"
display_name = "-tf-vcn"
}
resource "oci_core_subnet" "t" {
compartment_id = "${var.compartment_id}"
vcn_id = "${oci_core_virtual_network.t.id}"
availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[0],"name")}"
route_table_id = "${oci_core_virtual_network.t.default_route_table_id}"
security_list_ids = ["${oci_core_virtual_network.t.default_security_list_id}"]
dhcp_options_id = "${oci_core_virtual_network.t.default_dhcp_options_id}"
cidr_block = "10.0.0.0/24"
display_name = "-tf-subnet"
}
resource "oci_load_balancer" "t" {
shape = "100Mbps"
compartment_id = "${var.compartment_id}"
subnet_ids = ["${oci_core_subnet.t.id}"]
display_name = "-tf-lb"
is_private = true
}
resource "oci_load_balancer_backendset" "t" {
load_balancer_id = "${oci_load_balancer.t.id}"
name = "-tf-backend-set"
policy = "ROUND_ROBIN"
health_checker {
interval_ms = 30000
port = 1234
protocol = "TCP"
response_body_regex = ".*"
url_path = "/"
}
}
resource "oci_load_balancer_backend" "t" {
load_balancer_id = "${oci_load_balancer.t.id}"
backendset_name = "${oci_load_balancer_backendset.t.name}"
ip_address = "1.2.3.4"
port = 8080
backup = false
drain = false
offline = false
weight = 1
}
data "oci_load_balancer_backends" "t" {
load_balancer_id = "${oci_load_balancer.t.id}"
backendset_name = "${oci_load_balancer_backendset.t.name}"
}`
resourceName := "data.oci_load_balancer_backends.t"
resource.Test(t, resource.TestCase{
PreventPostDestroyRefresh: true,
Providers: providers,
Steps: []resource.TestStep{
{
ImportState: true,
ImportStateVerify: true,
Config: config,
},
{
Config: config,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet(resourceName, "load_balancer_id"),
resource.TestCheckResourceAttrSet(resourceName, "backendset_name"),
resource.TestCheckResourceAttrSet(resourceName, "backends.#"),
resource.TestCheckResourceAttr(resourceName, "backends.#", "1"),
resource.TestCheckResourceAttr(resourceName, "backends.0.ip_address", "1.2.3.4"),
resource.TestCheckResourceAttr(resourceName, "backends.0.port", "8080"),
resource.TestCheckResourceAttr(resourceName, "backends.0.backup", "false"),
resource.TestCheckResourceAttr(resourceName, "backends.0.drain", "false"),
resource.TestCheckResourceAttr(resourceName, "backends.0.offline", "false"),
resource.TestCheckResourceAttr(resourceName, "backends.0.weight", "1"),
),
},
},
})
}