-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement integration test suite + fix to go mods for dockerized test (…
…#129) Also fixed some formatting in the unit test for azure-simple-hw to normalize casing on variable names.
- Loading branch information
Nicholas M. Iodice
authored
May 30, 2019
1 parent
54ca74c
commit 4c7add3
Showing
14 changed files
with
375 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 0 additions & 105 deletions
105
infra/templates/azure-simple-hw/test/integration/azure_simple_test.go
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
infra/templates/azure-simple-hw/tests/integration/azure_simple_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
httpClient "github.com/gruntwork-io/terratest/modules/http-helper" | ||
"github.com/gruntwork-io/terratest/modules/random" | ||
"github.com/gruntwork-io/terratest/modules/terraform" | ||
"github.com/microsoft/cobalt/test-harness/infratests" | ||
) | ||
|
||
var prefix = fmt.Sprintf("cobalt-int-tst-%s", random.UniqueId()) | ||
var datacenter = os.Getenv("DATACENTER_LOCATION") | ||
|
||
var tfOptions = &terraform.Options{ | ||
TerraformDir: "../../", | ||
Upgrade: true, | ||
Vars: map[string]interface{}{ | ||
"prefix": prefix, | ||
"location": datacenter, | ||
}, | ||
BackendConfig: map[string]interface{}{ | ||
"storage_account_name": os.Getenv("TF_VAR_remote_state_account"), | ||
"container_name": os.Getenv("TF_VAR_remote_state_container"), | ||
}, | ||
} | ||
|
||
// Validates that the service responds with HTTP 200 status code. A retry strategy | ||
// is used because it may take some time for the application to finish standing up. | ||
func httpGetRespondsWith200(goTest *testing.T, output infratests.TerraformOutput) { | ||
hostname := output["app_service_default_hostname"].(string) | ||
maxRetries := 20 | ||
timeBetweenRetries := 2 * time.Second | ||
expectedResponse := "Hello App Service!" | ||
|
||
err := httpClient.HttpGetWithRetryWithCustomValidationE( | ||
goTest, | ||
hostname, | ||
maxRetries, | ||
timeBetweenRetries, | ||
func(status int, content string) bool { | ||
return status == 200 && strings.Contains(content, expectedResponse) | ||
}, | ||
) | ||
if err != nil { | ||
goTest.Fatal(err) | ||
} | ||
} | ||
|
||
func TestAzureSimple(t *testing.T) { | ||
testFixture := infratests.IntegrationTestFixture{ | ||
GoTest: t, | ||
TfOptions: tfOptions, | ||
ExpectedTfOutputCount: 2, | ||
ExpectedTfOutput: infratests.TerraformOutput{ | ||
"app_service_name": fmt.Sprintf("%s-appservice", prefix), | ||
"app_service_default_hostname": strings.ToLower(fmt.Sprintf("https://%s-appservice.azurewebsites.net", prefix)), | ||
}, | ||
TfOutputAssertions: []infratests.TerraformOutputValidation{ | ||
httpGetRespondsWith200, | ||
}, | ||
} | ||
infratests.RunIntegrationTests(&testFixture) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.