github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/ultradns/resource_ultradns_probe_http_test.go (about) 1 package ultradns 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/Ensighten/udnssdk" 8 "github.com/hashicorp/terraform/helper/resource" 9 ) 10 11 func TestAccUltradnsProbeHTTP(t *testing.T) { 12 var record udnssdk.RRSet 13 domain := "ultradns.phinze.com" 14 15 resource.Test(t, resource.TestCase{ 16 PreCheck: func() { testAccPreCheck(t) }, 17 Providers: testAccProviders, 18 CheckDestroy: testAccTcpoolCheckDestroy, 19 Steps: []resource.TestStep{ 20 resource.TestStep{ 21 Config: fmt.Sprintf(testCfgProbeHTTPMinimal, domain, domain), 22 Check: resource.ComposeTestCheckFunc( 23 testAccCheckUltradnsRecordExists("ultradns_tcpool.test-probe-http-minimal", &record), 24 // Specified 25 resource.TestCheckResourceAttr("ultradns_probe_http.it", "zone", domain), 26 resource.TestCheckResourceAttr("ultradns_probe_http.it", "name", "test-probe-http-minimal"), 27 resource.TestCheckResourceAttr("ultradns_probe_http.it", "pool_record", "10.2.0.1"), 28 resource.TestCheckResourceAttr("ultradns_probe_http.it", "agents.4091180299", "DALLAS"), 29 resource.TestCheckResourceAttr("ultradns_probe_http.it", "agents.2144410488", "AMSTERDAM"), 30 resource.TestCheckResourceAttr("ultradns_probe_http.it", "interval", "ONE_MINUTE"), 31 resource.TestCheckResourceAttr("ultradns_probe_http.it", "threshold", "2"), 32 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.method", "GET"), 33 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.url", "http://localhost/index"), 34 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.#", "2"), 35 36 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.name", "connect"), 37 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.warning", "20"), 38 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.critical", "20"), 39 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.fail", "20"), 40 41 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.name", "run"), 42 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.warning", "60"), 43 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.critical", "60"), 44 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.fail", "60"), 45 ), 46 }, 47 resource.TestStep{ 48 Config: fmt.Sprintf(testCfgProbeHTTPMaximal, domain, domain), 49 Check: resource.ComposeTestCheckFunc( 50 testAccCheckUltradnsRecordExists("ultradns_tcpool.test-probe-http-maximal", &record), 51 // Specified 52 resource.TestCheckResourceAttr("ultradns_probe_http.it", "zone", domain), 53 resource.TestCheckResourceAttr("ultradns_probe_http.it", "name", "test-probe-http-maximal"), 54 resource.TestCheckResourceAttr("ultradns_probe_http.it", "pool_record", "10.2.1.1"), 55 resource.TestCheckResourceAttr("ultradns_probe_http.it", "agents.4091180299", "DALLAS"), 56 resource.TestCheckResourceAttr("ultradns_probe_http.it", "agents.2144410488", "AMSTERDAM"), 57 resource.TestCheckResourceAttr("ultradns_probe_http.it", "interval", "ONE_MINUTE"), 58 resource.TestCheckResourceAttr("ultradns_probe_http.it", "threshold", "2"), 59 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.method", "POST"), 60 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.url", "http://localhost/index"), 61 62 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.#", "4"), 63 64 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.name", "run"), 65 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.warning", "1"), 66 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.critical", "2"), 67 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1349952704.fail", "3"), 68 69 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.2720402232.name", "avgConnect"), 70 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.2720402232.warning", "4"), 71 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.2720402232.critical", "5"), 72 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.2720402232.fail", "6"), 73 74 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.896769211.name", "avgRun"), 75 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.896769211.warning", "7"), 76 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.896769211.critical", "8"), 77 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.896769211.fail", "9"), 78 79 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.name", "connect"), 80 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.warning", "10"), 81 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.critical", "11"), 82 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.transaction.0.limit.1959786783.fail", "12"), 83 84 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.total_limits.0.warning", "13"), 85 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.total_limits.0.critical", "14"), 86 resource.TestCheckResourceAttr("ultradns_probe_http.it", "http_probe.0.total_limits.0.fail", "15"), 87 ), 88 }, 89 }, 90 }) 91 } 92 93 const testCfgProbeHTTPMinimal = ` 94 resource "ultradns_tcpool" "test-probe-http-minimal" { 95 zone = "%s" 96 name = "test-probe-http-minimal" 97 98 ttl = 30 99 description = "traffic controller pool with probes" 100 101 run_probes = true 102 act_on_probes = true 103 max_to_lb = 2 104 105 rdata { 106 host = "10.2.0.1" 107 108 state = "NORMAL" 109 run_probes = true 110 priority = 1 111 failover_delay = 0 112 threshold = 1 113 weight = 2 114 } 115 116 rdata { 117 host = "10.2.0.2" 118 119 state = "NORMAL" 120 run_probes = true 121 priority = 2 122 failover_delay = 0 123 threshold = 1 124 weight = 2 125 } 126 127 backup_record_rdata = "10.2.0.3" 128 } 129 130 resource "ultradns_probe_http" "it" { 131 zone = "%s" 132 name = "test-probe-http-minimal" 133 134 pool_record = "10.2.0.1" 135 136 agents = ["DALLAS", "AMSTERDAM"] 137 138 interval = "ONE_MINUTE" 139 threshold = 2 140 141 http_probe { 142 transaction { 143 method = "GET" 144 url = "http://localhost/index" 145 146 limit { 147 name = "run" 148 warning = 60 149 critical = 60 150 fail = 60 151 } 152 153 limit { 154 name = "connect" 155 warning = 20 156 critical = 20 157 fail = 20 158 } 159 } 160 } 161 162 depends_on = ["ultradns_tcpool.test-probe-http-minimal"] 163 } 164 ` 165 166 const testCfgProbeHTTPMaximal = ` 167 resource "ultradns_tcpool" "test-probe-http-maximal" { 168 zone = "%s" 169 name = "test-probe-http-maximal" 170 171 ttl = 30 172 description = "traffic controller pool with probes" 173 174 run_probes = true 175 act_on_probes = true 176 max_to_lb = 2 177 178 rdata { 179 host = "10.2.1.1" 180 181 state = "NORMAL" 182 run_probes = true 183 priority = 1 184 failover_delay = 0 185 threshold = 1 186 weight = 2 187 } 188 189 rdata { 190 host = "10.2.1.2" 191 192 state = "NORMAL" 193 run_probes = true 194 priority = 2 195 failover_delay = 0 196 threshold = 1 197 weight = 2 198 } 199 200 backup_record_rdata = "10.2.1.3" 201 } 202 203 resource "ultradns_probe_http" "it" { 204 zone = "%s" 205 name = "test-probe-http-maximal" 206 207 pool_record = "10.2.1.1" 208 209 agents = ["DALLAS", "AMSTERDAM"] 210 211 interval = "ONE_MINUTE" 212 threshold = 2 213 214 http_probe { 215 transaction { 216 method = "POST" 217 url = "http://localhost/index" 218 transmitted_data = "{}" 219 follow_redirects = true 220 221 limit { 222 name = "run" 223 224 warning = 1 225 critical = 2 226 fail = 3 227 } 228 limit { 229 name = "avgConnect" 230 231 warning = 4 232 critical = 5 233 fail = 6 234 } 235 limit { 236 name = "avgRun" 237 238 warning = 7 239 critical = 8 240 fail = 9 241 } 242 limit { 243 name = "connect" 244 245 warning = 10 246 critical = 11 247 fail = 12 248 } 249 } 250 251 total_limits { 252 warning = 13 253 critical = 14 254 fail = 15 255 } 256 } 257 258 depends_on = ["ultradns_tcpool.test-probe-http-maximal"] 259 } 260 `