Skip to content

Commit

Permalink
Address more review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tisutisu committed Mar 12, 2024
1 parent 400ddf5 commit 80e1b20
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions tests/build/multi-platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
Ec2User = "ec2-user"
AwsRegion = "us-east-1"
AwsPlatform = "linux/arm64"
DynamicInstanceTag = "dynamic-test-instance"
DynamicMaxInstances = "3"
MultiPlatformSecretKey = "build.appstudio.redhat.com/multi-platform-secret"
MultiPlatformConfigKey = "build.appstudio.redhat.com/multi-platform-config"
)
Expand Down Expand Up @@ -237,7 +237,7 @@ var _ = framework.MultiPlatformBuildSuiteDescribe("Multi Platform Controller E2E
})
})
Describe("aws dynamic allocation", Label("aws-dynamic"), func() {
var testNamespace, applicationName, componentName, multiPlatformSecretName, multiPlatformTaskName, instanceId string
var testNamespace, applicationName, componentName, multiPlatformSecretName, multiPlatformTaskName, dynamicInstanceTag, instanceId string
var component *appservice.Component
var timeout, interval time.Duration

Expand Down Expand Up @@ -271,6 +271,9 @@ var _ = framework.MultiPlatformBuildSuiteDescribe("Multi Platform Controller E2E
Expect(testNamespace).NotTo(BeNil(), "failed to create sandbox user namespace")
Expect(err).ShouldNot(HaveOccurred())

dynamicInstanceTag := "dynamic-instance" + "-" + util.GenerateRandomString(4)
GinkgoWriter.Printf("Generated dynamic instance tag: %q\n", dynamicInstanceTag)

// Restart multi-platform-controller pod to reload configMap again
podList, err := f.AsKubeAdmin.CommonController.ListAllPods(ControllerNamespace)
Expect(err).ShouldNot(HaveOccurred())
Expand All @@ -286,7 +289,7 @@ var _ = framework.MultiPlatformBuildSuiteDescribe("Multi Platform Controller E2E
// sleep for 10 sec so that multi-platform-controller pod comes up
time.Sleep(10 * time.Second)

err = createConfigMapForDynamicInstance(f)
err = createConfigMapForDynamicInstance(f, dynamicInstanceTag)
Expect(err).ShouldNot(HaveOccurred())

err = createSecretsForDynamicInstance(f)
Expand Down Expand Up @@ -382,6 +385,7 @@ var _ = framework.MultiPlatformBuildSuiteDescribe("Multi Platform Controller E2E
Expect(err).ShouldNot(HaveOccurred())
instanceId = taskRun.Annotations["build.appstudio.redhat.com/cloud-instance-id"]
GinkgoWriter.Printf("INSTANCE ID: %s\n", instanceId)
Expect(instanceId).ShouldNot(BeEmpty())
})

It("that PipelineRun completes successfully", func() {
Expand All @@ -394,7 +398,7 @@ var _ = framework.MultiPlatformBuildSuiteDescribe("Multi Platform Controller E2E

It("check cleanup happened successfully", func() {
Eventually(func() error {
instances, err := getDynamicAwsInstance(DynamicInstanceTag)
instances, err := getDynamicAwsInstance(dynamicInstanceTag)
if err != nil {
return err
}
Expand Down Expand Up @@ -475,24 +479,24 @@ func createConfigMapForHostPool(f *framework.Framework) error {
return nil
}

func createConfigMapForDynamicInstance(f *framework.Framework) error {
func createConfigMapForDynamicInstance(f *framework.Framework, instanceTag string) error {
hostConfig := &v1.ConfigMap{}
hostConfig.Name = HostConfig
hostConfig.Namespace = ControllerNamespace
hostConfig.Labels = map[string]string{MultiPlatformConfigKey: "hosts"}

hostConfig.Data = map[string]string{}
hostConfig.Data["dynamic-platforms"] = AwsPlatform
hostConfig.Data["instance-tag"] = DynamicInstanceTag
hostConfig.Data["instance-tag"] = instanceTag
hostConfig.Data["dynamic.linux-arm64.type"] = "aws"
hostConfig.Data["dynamic.linux-arm64.region"] = AwsRegion
hostConfig.Data["dynamic.linux-arm64.ami"] = "ami-09d5d0912f52f9514"
hostConfig.Data["dynamic.linux-arm64.instance-type"] = "t4g.medium"
hostConfig.Data["dynamic.linux-arm64.instance-type"] = "t4g.micro"
hostConfig.Data["dynamic.linux-arm64.key-name"] = "multi-platform-e2e"
hostConfig.Data["dynamic.linux-arm64.aws-secret"] = AwsSecretName
hostConfig.Data["dynamic.linux-arm64.ssh-secret"] = SshSecretName
hostConfig.Data["dynamic.linux-arm64.security-group"] = "launch-wizard-7"
hostConfig.Data["dynamic.linux-arm64.max-instances"] = "1"
hostConfig.Data["dynamic.linux-arm64.max-instances"] = DynamicMaxInstances

_, err := f.AsKubeAdmin.CommonController.CreateConfigMap(hostConfig, ControllerNamespace)
if err != nil {
Expand Down

0 comments on commit 80e1b20

Please sign in to comment.