Skip to content

Commit

Permalink
[Fix] Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
muneeb-jan committed Oct 7, 2024
1 parent c520812 commit e87c42d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions acceptance/openstack/autoscaling/v1/lifecycle_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,24 @@ import (
)

func TestLifecycleHooksLifecycle(t *testing.T) {
client, err := clients.NewAutoscalingV1Client()
th.AssertNoErr(t, err)

networkID := clients.EnvOS.GetEnv("NETWORK_ID")
vpcID := clients.EnvOS.GetEnv("VPC_ID")
if networkID == "" || vpcID == "" {
t.Skip("OS_NETWORK_ID or OS_VPC_ID env vars are missing but are required for AS Lifecycle Hooks test")
}

client, err := clients.NewAutoscalingV1Client()
th.AssertNoErr(t, err)

groupID := autoscaling.CreateAutoScalingGroup(t, client, networkID, vpcID, tools.RandomString("as-group-create-", 3))
t.Cleanup(func() {
autoscaling.DeleteAutoScalingGroup(t, client, groupID)
})

topicName := tools.RandomString("as-lifecycle-hooks-topic-", 3)
t.Logf("Attempting to create Topic: %s", topicName)
topicURN, err := autoscaling.GetNotificationTopicURN(topicName)
if err != nil {
t.Logf("Error while creating the notification topic: %s", topicName)
}
defer autoscaling.DeleteTopic(t, topicURN)
lifecycleHookName := tools.RandomString("as-lifecycle-hook-create-", 3)
createOpts := lifecyclehooks.CreateOpts{
LifecycleHookName: lifecycleHookName,
Expand Down Expand Up @@ -66,8 +63,13 @@ func TestLifecycleHooksLifecycle(t *testing.T) {
tools.PrintResource(t, lifecycleHook)
}

t.Logf("Attempting to delete Lifecycle Hook")
err = lifecyclehooks.Delete(client, groupID, lifecycleHookName)
th.AssertNoErr(t, err)
t.Logf("Deleted Lifecycle Hook: %s", lifecycleHookName)
t.Cleanup(func() {
t.Logf("Attempting to delete Lifecycle Hook")
err = lifecyclehooks.Delete(client, groupID, lifecycleHookName)
th.AssertNoErr(t, err)
t.Logf("Deleted Lifecycle Hook: %s", lifecycleHookName)

autoscaling.DeleteTopic(t, topicURN)
autoscaling.DeleteAutoScalingGroup(t, client, groupID)
})
}

0 comments on commit e87c42d

Please sign in to comment.