// To test this on CircleCI you need two URLs set a environment variables(VAULT_PACKER_TEMPLATE_VAR_VAULT_DOWNLOAD_URL)
// so the Vault Enterprise versions can be downloaded. You would also need to set these two variables locally to run the
// tests. The reason behind this is to prevent the actual url from being visible in the code and logs.
To test this on CircleCI you need two URLs set a environment variables(VAULT_PACKER_TEMPLATE_VAR_VAULT_DOWNLOAD_URL)
so the Vault Enterprise versions can be downloaded. You would also need to set these two variables locally to run the
tests. The reason behind this is to prevent the actual url from being visible in the code and logs.
// To test this on CircleCI you need two URLs set a environment variables ( VAULT_PACKER_TEMPLATE_VAR_VAULT_DOWNLOAD_URL ) // so the Vault Enterprise versions can be downloaded . You would also need to set these two variables locally to run the // tests . The reason behind this is to prevent the actual url from being visible in the code and logs .
func TestMainVaultCluster(t *testing.T) {
	t.Parallel()
	test_structure.RunTestStage(t, "build_images", func() {
		vaultDownloadUrl := getUrlFromEnv(t, "VAULT_PACKER_TEMPLATE_VAR_VAULT_DOWNLOAD_URL")
		projectId := gcp.GetGoogleProjectIDFromEnvVar(t)
		region := gcp.GetRandomRegion(t, projectId, []string{"us-east1"}, nil)
		zone := gcp.GetRandomZoneForRegion(t, projectId, region)
		test_structure.SaveString(t, WORK_DIR, SAVED_GCP_PROJECT_ID, projectId)
		test_structure.SaveString(t, WORK_DIR, SAVED_GCP_REGION_NAME, region)
		test_structure.SaveString(t, WORK_DIR, SAVED_GCP_ZONE_NAME, zone)
		tlsCert := generateSelfSignedTlsCert(t)
		saveTLSCert(t, WORK_DIR, tlsCert)
		packerImageOptions := map[string]*packer.Options{}
		for _, packerBuildItem := range packerBuilds {
			packerImageOptions[packerBuildItem.SaveName] = composeImageOptions(t, packerBuildItem.PackerBuildName, WORK_DIR, packerBuildItem.useEnterpriseVault, vaultDownloadUrl)
		}
		imageIds := packer.BuildArtifacts(t, packerImageOptions)
		for imageKey, imageId := range imageIds {
			test_structure.SaveString(t, WORK_DIR, imageKey, imageId)
		}
	})
	defer test_structure.RunTestStage(t, "delete_images", func() {
		projectID := test_structure.LoadString(t, WORK_DIR, SAVED_GCP_PROJECT_ID)
		for _, packerBuildItem := range packerBuilds {
			deleteVaultImage(t, WORK_DIR, projectID, packerBuildItem.SaveName)
		}
		tlsCert := loadTLSCert(t, WORK_DIR)
		cleanupTLSCertFiles(tlsCert)
	})
	t.Run("group", func(t *testing.T) {
		runAllTests(t)
	})
}
func TestMainVaultCluster ( t * testing . T ) { t . Parallel ( ) test_structure . RunTestStage ( t , " " , func ( ) { vaultDownloadUrl := getUrlFromEnv ( t , " " ) projectId := gcp . GetGoogleProjectIDFromEnvVar ( t ) region := gcp . GetRandomRegion ( t , projectId , [ ] string { " " } , nil ) zone := gcp . GetRandomZoneForRegion ( t , projectId , region ) test_structure . SaveString ( t , WORK_DIR , SAVED_GCP_PROJECT_ID , projectId ) test_structure . SaveString ( t , WORK_DIR , SAVED_GCP_REGION_NAME , region ) test_structure . SaveString ( t , WORK_DIR , SAVED_GCP_ZONE_NAME , zone ) tlsCert := generateSelfSignedTlsCert ( t ) saveTLSCert ( t , WORK_DIR , tlsCert ) packerImageOptions := map [ string ] * packer . Options { } for _ , packerBuildItem := range packerBuilds { packerImageOptions [ packerBuildItem . SaveName ] = composeImageOptions ( t , packerBuildItem . PackerBuildName , WORK_DIR , packerBuildItem . useEnterpriseVault , vaultDownloadUrl ) } imageIds := packer . BuildArtifacts ( t , packerImageOptions ) for imageKey , imageId := range imageIds { test_structure . SaveString ( t , WORK_DIR , imageKey , imageId ) } } ) defer test_structure . RunTestStage ( t , " " , func ( ) { projectID := test_structure . LoadString ( t , WORK_DIR , SAVED_GCP_PROJECT_ID ) for _ , packerBuildItem := range packerBuilds { deleteVaultImage ( t , WORK_DIR , projectID , packerBuildItem . SaveName ) } tlsCert := loadTLSCert ( t , WORK_DIR ) cleanupTLSCertFiles ( tlsCert ) } ) t . Run ( " " , func ( t * testing . T ) { runAllTests ( t ) } ) }
To test this on CircleCI you need two URLs set a environment variables(VAULT_PACKER_TEMPLATE_VAR_VAULT_DOWNLOAD_URL)
so the Vault Enterprise versions can be downloaded.
To test this on CircleCI you need two URLs set a environment variables ( VAULT_PACKER_TEMPLATE_VAR_VAULT_DOWNLOAD_URL ) so the Vault Enterprise versions can be downloaded .
// GCP sets quotas at a low limit for In-use IP addresses and CPUs which fail the tests // these have to be requested manually for each region and will break tests every time // a new region is introduced. For this reason, I am limiting the tests to us-east1