Skip to content

Commit

Permalink
[Test] Add list to lifecycle hooks test
Browse files Browse the repository at this point in the history
  • Loading branch information
muneeb-jan committed Oct 7, 2024
1 parent b42bae8 commit c520812
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions acceptance/openstack/autoscaling/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ func GetNotificationTopicURN(topicName string) (string, error) {

func DeleteTopic(t *testing.T, topicURN string) {
client, _ := clients.NewSmnV2Client()
t.Logf("Attempting to Delete Topic: %s", topicURN)
err := topics.Delete(client, topicURN).ExtractErr()
if err != nil {
t.Logf("Error while deleting the topic: %s", topicURN)
}
t.Logf("Deleted Topic: %s", topicURN)
}
12 changes: 10 additions & 2 deletions acceptance/openstack/autoscaling/v1/lifecycle_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ func TestLifecycleHooksLifecycle(t *testing.T) {
})

topicName := tools.RandomString("as-lifecycle-hooks-topic-", 3)
lifecycleHookName := tools.RandomString("as-lifecycle-hook-create-", 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,
LifecycleHookType: "INSTANCE_LAUNCHING",
Expand All @@ -41,7 +42,7 @@ func TestLifecycleHooksLifecycle(t *testing.T) {
t.Logf("Attempting to create Lifecycle Hook")
lifecycleHook, err := lifecyclehooks.Create(client, createOpts, groupID)
th.AssertNoErr(t, err)
t.Logf("Ceate Lifecycle Hook: %s", lifecycleHook.LifecycleHookName)
t.Logf("Created Lifecycle Hook: %s", lifecycleHook.LifecycleHookName)

requestedLifecycleHook, err := lifecyclehooks.Get(client, groupID, lifecycleHookName)
th.AssertNoErr(t, err)
Expand All @@ -58,6 +59,13 @@ func TestLifecycleHooksLifecycle(t *testing.T) {
th.AssertNoErr(t, err)
t.Logf("Updated Lifecycle Hook: %s", lifecycleHookName)

t.Logf("Listing all Lifecycle Hooks")
lifecycleHooks, err := lifecyclehooks.List(client, groupID)
th.AssertNoErr(t, err)
for _, lifecycleHook := range lifecycleHooks {
tools.PrintResource(t, lifecycleHook)
}

t.Logf("Attempting to delete Lifecycle Hook")
err = lifecyclehooks.Delete(client, groupID, lifecycleHookName)
th.AssertNoErr(t, err)
Expand Down

0 comments on commit c520812

Please sign in to comment.