Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions test/e2e/shared/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -2405,63 +2405,3 @@ func GetMountTargetState(ctx context.Context, e2eCtx *E2EContext, mountTargetID
state := string(result.LifeCycleState)
return &state, nil
}

func getAvailabilityZone(e2eCtx *E2EContext) string {
az := e2eCtx.E2EConfig.MustGetVariable(AwsAvailabilityZone1)
return az
}

func getInstanceFamily(e2eCtx *E2EContext) string {
machineType := e2eCtx.E2EConfig.MustGetVariable(AwsNodeMachineType)
// from instance type get instace family behind the dot
// for example: t3a.medium -> t3
machineTypeSplit := strings.Split(machineType, ".")
if len(machineTypeSplit) > 0 {
return machineTypeSplit[0]
}
return "t3"
}

func AllocateHost(ctx context.Context, e2eCtx *E2EContext) (string, error) {
ec2Svc := ec2.NewFromConfig(*e2eCtx.AWSSession)
input := &ec2.AllocateHostsInput{
AvailabilityZone: aws.String(getAvailabilityZone(e2eCtx)),
InstanceFamily: aws.String(getInstanceFamily(e2eCtx)),
Quantity: aws.Int32(1),
}
output, err := ec2Svc.AllocateHosts(ctx, input)
Expect(err).ToNot(HaveOccurred(), "Failed to allocate host")
Expect(len(output.HostIds)).To(BeNumerically(">", 0), "No dedicated host ID returned")
fmt.Println("Allocated Host ID: ", output.HostIds[0])
hostID := output.HostIds[0]
return hostID, nil
}

func ReleaseHost(ctx context.Context, e2eCtx *E2EContext, hostID string) {
ec2Svc := ec2.NewFromConfig(*e2eCtx.AWSSession)

input := &ec2.ReleaseHostsInput{
HostIds: []string{hostID},
}

_, err := ec2Svc.ReleaseHosts(ctx, input)
Expect(err).ToNot(HaveOccurred(), "Failed to release host %s", hostID)
fmt.Println("Released Host ID: ", hostID)
}

func GetHostID(ctx context.Context, e2eCtx *E2EContext, instanceID string) string {
ec2Svc := ec2.NewFromConfig(*e2eCtx.AWSSession)

input := &ec2.DescribeInstancesInput{
InstanceIds: []string{instanceID},
}

result, err := ec2Svc.DescribeInstances(ctx, input)
Expect(err).ToNot(HaveOccurred(), "Failed to get host ID for instance %s", instanceID)
Expect(len(result.Reservations)).To(BeNumerically(">", 0), "No reservation returned")
Expect(len(result.Reservations[0].Instances)).To(BeNumerically(">", 0), "No instance returned")
placement := *result.Reservations[0].Instances[0].Placement
hostID := *placement.HostId
fmt.Println("Host ID: ", hostID)
return hostID
}
2 changes: 0 additions & 2 deletions test/e2e/shared/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ const (

ClassicElbTestKubernetesFrom = "CLASSICELB_TEST_KUBERNETES_VERSION_FROM"
ClassicElbTestKubernetesTo = "CLASSICELB_TEST_KUBERNETES_VERSION_TO"

DedicatedHostFlavor = "dedicated-host"
)

// ResourceQuotaFilePath is the path to the file that contains the resource usage.
Expand Down
Loading