forked from appleboy/drone-terraform-in-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
30 lines (27 loc) · 924 Bytes
/
main_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
package main
import (
"testing"
"time"
"github.com/gruntwork-io/terratest/modules/http-helper"
"github.com/gruntwork-io/terratest/modules/terraform"
)
func TestWebServer(t *testing.T) {
terraformOptions := &terraform.Options{
// The path to where your Terraform code is located
TerraformDir: "./",
}
// At the end of the test, run `terraform destroy`
defer terraform.Destroy(t, terraformOptions)
// Run `terraform init` and `terraform apply`
terraform.InitAndApply(t, terraformOptions)
// Run `terraform output` to get the value of an output variable
url := terraform.Output(t, terraformOptions, "alb_hostname")
url = url + "/healthz"
// Verify that we get back a 200 OK with the expected text. It
// takes ~1 min for the Instance to boot, so retry a few times.
status := 200
text := ""
retries := 100
sleep := 10 * time.Second
http_helper.HttpGetWithRetry(t, url, status, text, retries, sleep)
}