Skip to content

Commit 1c81e66

Browse files
authored
Merge pull request #4008 from Skarlso/fix-missing-bootstrapsettings-in-testsuite
Reorder the bootstrapping logic so AWSSession is available in afterSuite
2 parents b7df703 + 37543d1 commit 1c81e66

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

test/e2e/shared/aws.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func createCloudFormationStack(prov client.ConfigProvider, t *cfn_bootstrap.Temp
413413
err := cfnSvc.ReconcileBootstrapStack(t.Spec.StackName, *renderCustomCloudFormation(t), tags)
414414
output, err1 := CFN.DescribeStackEvents(&cfn.DescribeStackEventsInput{StackName: aws.String(t.Spec.StackName), NextToken: aws.String("1")})
415415
for _, event := range output.StackEvents {
416-
By(fmt.Sprintf("Event details for %s : Resource: %s, Status: %s", aws.StringValue(event.LogicalResourceId), aws.StringValue(event.ResourceType), aws.StringValue(event.ResourceStatus)))
416+
By(fmt.Sprintf("Event details for %s : Resource: %s, Status: %s, Reason: %s", aws.StringValue(event.LogicalResourceId), aws.StringValue(event.ResourceType), aws.StringValue(event.ResourceStatus), aws.StringValue(event.ResourceStatusReason)))
417417
}
418418
return err == nil && err1 == nil
419419
}, 2*time.Minute).Should(Equal(true))
@@ -870,7 +870,13 @@ func DumpEKSClusters(ctx context.Context, e2eCtx *E2EContext) {
870870
fmt.Fprintf(GinkgoWriter, "folder created for eks clusters: %s\n", logPath)
871871

872872
input := &eks.ListClustersInput{}
873-
eksClient := eks.New(e2eCtx.BootstrapUserAWSSession)
873+
var eksClient *eks.EKS
874+
if e2eCtx.BootstrapUserAWSSession == nil {
875+
eksClient = eks.New(e2eCtx.AWSSession)
876+
} else {
877+
eksClient = eks.New(e2eCtx.BootstrapUserAWSSession)
878+
}
879+
874880
output, err := eksClient.ListClusters(input)
875881
if err != nil {
876882
fmt.Fprintf(GinkgoWriter, "couldn't list EKS clusters: err=%s", err)

test/e2e/shared/suite.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,23 @@ func Node1BeforeSuite(e2eCtx *E2EContext) []byte {
125125

126126
Expect(err).NotTo(HaveOccurred())
127127
e2eCtx.AWSSession = NewAWSSession()
128-
boostrapTemplate := getBootstrapTemplate(e2eCtx)
128+
bootstrapTemplate := getBootstrapTemplate(e2eCtx)
129129
bootstrapTags := map[string]string{"capa-e2e-test": "true"}
130-
e2eCtx.CloudFormationTemplate = renderCustomCloudFormation(boostrapTemplate)
130+
e2eCtx.CloudFormationTemplate = renderCustomCloudFormation(bootstrapTemplate)
131+
131132
if !e2eCtx.Settings.SkipCloudFormationCreation {
132-
err = createCloudFormationStack(e2eCtx.AWSSession, boostrapTemplate, bootstrapTags)
133+
err = createCloudFormationStack(e2eCtx.AWSSession, bootstrapTemplate, bootstrapTags)
133134
if err != nil {
134-
deleteCloudFormationStack(e2eCtx.AWSSession, boostrapTemplate)
135-
err = createCloudFormationStack(e2eCtx.AWSSession, boostrapTemplate, bootstrapTags)
135+
deleteCloudFormationStack(e2eCtx.AWSSession, bootstrapTemplate)
136+
err = createCloudFormationStack(e2eCtx.AWSSession, bootstrapTemplate, bootstrapTags)
136137
Expect(err).NotTo(HaveOccurred())
137138
}
138139
}
139-
ensureStackTags(e2eCtx.AWSSession, boostrapTemplate.Spec.StackName, bootstrapTags)
140+
141+
ensureStackTags(e2eCtx.AWSSession, bootstrapTemplate.Spec.StackName, bootstrapTags)
140142
ensureNoServiceLinkedRoles(e2eCtx.AWSSession)
141143
ensureSSHKeyPair(e2eCtx.AWSSession, DefaultSSHKeyPairName)
142-
e2eCtx.Environment.BootstrapAccessKey = newUserAccessKey(e2eCtx.AWSSession, boostrapTemplate.Spec.BootstrapUser.UserName)
144+
e2eCtx.Environment.BootstrapAccessKey = newUserAccessKey(e2eCtx.AWSSession, bootstrapTemplate.Spec.BootstrapUser.UserName)
143145
e2eCtx.BootstrapUserAWSSession = NewAWSSessionWithKey(e2eCtx.Environment.BootstrapAccessKey)
144146
Expect(ensureTestImageUploaded(e2eCtx)).NotTo(HaveOccurred())
145147

@@ -154,7 +156,7 @@ func Node1BeforeSuite(e2eCtx *E2EContext) []byte {
154156
By("Setting up the bootstrap cluster")
155157
e2eCtx.Environment.BootstrapClusterProvider, e2eCtx.Environment.BootstrapClusterProxy = setupBootstrapCluster(e2eCtx.E2EConfig, e2eCtx.Environment.Scheme, e2eCtx.Settings.UseExistingCluster)
156158

157-
base64EncodedCredentials := encodeCredentials(e2eCtx.Environment.BootstrapAccessKey, boostrapTemplate.Spec.Region)
159+
base64EncodedCredentials := encodeCredentials(e2eCtx.Environment.BootstrapAccessKey, bootstrapTemplate.Spec.Region)
158160
SetEnvVar("AWS_B64ENCODED_CREDENTIALS", base64EncodedCredentials, true)
159161

160162
if !e2eCtx.Settings.SkipQuotas {

0 commit comments

Comments
 (0)