-
Notifications
You must be signed in to change notification settings - Fork 106
TPT-3909: Integration tests for IAM volumes io_ready #934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mawilk90
wants to merge
12
commits into
linode:main
Choose a base branch
from
mawilk90:feature/TPT-3909-iam-volumes-io-ready-add-integration-tests-for-sdks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fa612a5
Add IO ready int tests for attached and detached volume
mawilk90 6bc1545
Update assertions; add detachVolume param to setupVolumeAttachedToLinode
mawilk90 439f804
Add IO ready int tests for updated volume
mawilk90 2109e75
Add IO ready int tests for cloned and resized volume
mawilk90 e8b276b
Add FOR to iterate over volumeList in TestIAM_GetIOReadyForNotAttache…
mawilk90 b0c7e4d
Remove setupInstance from setupVolumeAttachedToLinode as it uses diff…
mawilk90 8c66c46
Add fixtures for TestIAM_GetIOReadyFor tests
mawilk90 2ae068c
Refactor error msg in WaitForVolumeIOReadyStatus
mawilk90 eb66367
Merge branch 'main' into feature/TPT-3909-iam-volumes-io-ready-add-in…
mawilk90 c71f063
Copilot remarks
mawilk90 cf66506
Copilot remarks
mawilk90 0213e4c
Refactor
mawilk90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1,953 changes: 1,953 additions & 0 deletions
1,953
test/integration/fixtures/TestIAM_GetIOReadyForAttachedDetachedVolume.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
730 changes: 730 additions & 0 deletions
730
test/integration/fixtures/TestIAM_GetIOReadyForNotAttachedVolume.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
1,958 changes: 1,958 additions & 0 deletions
1,958
test/integration/fixtures/TestIAM_GetIOReadyForResizedVolume.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
1,892 changes: 1,892 additions & 0 deletions
1,892
test/integration/fixtures/TestIAM_GetIOReadyForUpdatedVolume.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,240 @@ | ||
| package integration | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/linode/linodego" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func setupVolumeAttachedToLinode( | ||
| t *testing.T, | ||
| fixturesYaml string, | ||
| detachVolume bool, | ||
| ) (*linodego.Client, *linodego.Volume, *linodego.Instance, func()) { | ||
| t.Helper() | ||
| var fixtureTeardown func() | ||
|
|
||
| client, fixtureTeardown := createTestClient(t, fixturesYaml) | ||
|
|
||
| instance, err := createInstance(t, client, true, func(l *linodego.Client, options *linodego.InstanceCreateOptions) { | ||
| options.Booted = linodego.Pointer(true) | ||
| }) | ||
| require.NoErrorf(t, err, "Error setting up Linode instance: %v", err) | ||
|
|
||
| teardownInstance := func() { | ||
| err = client.DeleteInstance(context.Background(), instance.ID) | ||
| require.NoErrorf(t, err, "Error deleting instance: %v", err) | ||
| } | ||
|
|
||
| instance, err = client.WaitForInstanceStatus(context.Background(), instance.ID, linodego.InstanceRunning, 180) | ||
| require.NoErrorf(t, err, "Error waiting for instance to be running: %v", err) | ||
|
|
||
| volume, teardownVolume, err := createVolume(t, client, func(l *linodego.Client, options *linodego.VolumeCreateOptions) { | ||
| options.Region = instance.Region | ||
| }) | ||
| require.NoErrorf(t, err, "Error creating volume: %v", err) | ||
|
|
||
| volume, err = client.AttachVolume(context.Background(), volume.ID, &linodego.VolumeAttachOptions{LinodeID: instance.ID}) | ||
| require.NoErrorf(t, err, "Error attaching volume to instance: %v", err) | ||
|
|
||
| volume, err = client.WaitForVolumeIOReadyStatus(context.Background(), volume.ID, true, 45) | ||
| require.NoErrorf(t, err, "Error waiting for IO Ready status of attached volume: %v", err) | ||
|
|
||
| teardown := func() { | ||
| if detachVolume { | ||
| err = client.DetachVolume(context.Background(), volume.ID) | ||
| require.NoErrorf(t, err, "Error detaching volume: %v", err) | ||
|
|
||
| _, err = client.WaitForVolumeIOReadyStatus(context.Background(), volume.ID, false, 45) | ||
| require.NoErrorf(t, err, "Error waiting for IO Ready status of detached volume: %v", err) | ||
| } | ||
| teardownVolume() | ||
| teardownInstance() | ||
| fixtureTeardown() | ||
| } | ||
|
|
||
| return client, volume, instance, teardown | ||
| } | ||
|
|
||
| func TestIAM_GetIOReadyForNotAttachedVolume(t *testing.T) { | ||
| client, recordStopper := createTestClient(t, "fixtures/TestIAM_GetIOReadyForNotAttachedVolume") | ||
| defer recordStopper() | ||
|
|
||
| volume, teardown, err := createVolume(t, client, func(l *linodego.Client, options *linodego.VolumeCreateOptions) { | ||
| options.Label = label | ||
| }) | ||
| defer teardown() | ||
| require.NoErrorf(t, err, "Error creating not attached volume: %v", err) | ||
|
|
||
| volume, err = client.WaitForVolumeStatus(context.Background(), volume.ID, linodego.VolumeActive, 30) | ||
| require.NoErrorf(t, err, "Error waiting for volume to be active: %v", err) | ||
|
|
||
| volumeList, err := client.ListVolumes(context.Background(), nil) | ||
| require.NoErrorf(t, err, "Error listing volumes: %v", err) | ||
| for _, vol := range volumeList { | ||
| if vol.Label == label { | ||
| assert.Equal(t, linodego.VolumeActive, volumeList[0].Status) | ||
| assert.Empty(t, volumeList[0].LinodeID) | ||
| assert.Empty(t, volumeList[0].LinodeLabel) | ||
| assert.False(t, volumeList[0].IOReady) | ||
| } | ||
| } | ||
|
|
||
| volume, err = client.GetVolume(context.Background(), volume.ID) | ||
| require.NoErrorf(t, err, "Error getting not attached volume: %v", err) | ||
| assert.Equal(t, label, volume.Label) | ||
| assert.Equal(t, linodego.VolumeActive, volume.Status) | ||
| assert.Empty(t, volume.LinodeID) | ||
| assert.Empty(t, volume.LinodeLabel) | ||
| assert.False(t, volume.IOReady) | ||
| } | ||
|
|
||
| func TestIAM_GetIOReadyForAttachedDetachedVolume(t *testing.T) { | ||
| client, volume, instance, teardown := setupVolumeAttachedToLinode(t, "fixtures/TestIAM_GetIOReadyForAttachedDetachedVolume", false) | ||
| defer teardown() | ||
|
|
||
| instanceVolumes, err := client.ListInstanceVolumes(context.Background(), instance.ID, nil) | ||
| require.NoErrorf(t, err, "Error listing instance volumes: %v", err) | ||
| require.Len(t, instanceVolumes, 1, "Expected 1 volume attached to instance, got %d", len(instanceVolumes)) | ||
| assert.Equal(t, instance.ID, *instanceVolumes[0].LinodeID) | ||
| assert.Equal(t, instance.Label, instanceVolumes[0].LinodeLabel) | ||
| assert.True(t, instanceVolumes[0].IOReady) | ||
|
|
||
| volume, err = client.GetVolume(context.Background(), volume.ID) | ||
| require.NoErrorf(t, err, "Error getting attached volume: %v", err) | ||
| assert.Equal(t, instance.ID, *volume.LinodeID) | ||
| assert.Equal(t, instance.Label, volume.LinodeLabel) | ||
| assert.True(t, volume.IOReady) | ||
|
|
||
| err = client.DetachVolume(context.Background(), volume.ID) | ||
| require.NoErrorf(t, err, "Error detaching volume: %v", err) | ||
|
|
||
| volume, err = client.WaitForVolumeIOReadyStatus(context.Background(), volume.ID, false, 45) | ||
| require.NoErrorf(t, err, "Error waiting for IO Ready status of detached volume: %v", err) | ||
|
|
||
| instanceVolumes, err = client.ListInstanceVolumes(context.Background(), instance.ID, nil) | ||
| require.NoErrorf(t, err, "Error listing instance volumes after detach: %v", err) | ||
| require.Len(t, instanceVolumes, 0, "Expected no volumes attached to instance, got %d", len(instanceVolumes)) | ||
|
|
||
| volume, err = client.GetVolume(context.Background(), volume.ID) | ||
| require.NoErrorf(t, err, "Error getting volume after detach: %v", err) | ||
| assert.Empty(t, volume.LinodeID) | ||
| assert.Empty(t, volume.LinodeLabel) | ||
| assert.False(t, volume.IOReady) | ||
| } | ||
|
|
||
| func TestIAM_GetIOReadyForUpdatedVolume(t *testing.T) { | ||
| client, volume, instance, teardown := setupVolumeAttachedToLinode(t, "fixtures/TestIAM_GetIOReadyForUpdatedVolume", true) | ||
| defer teardown() | ||
| assert.Equal(t, instance.ID, *volume.LinodeID) | ||
| assert.Equal(t, instance.Label, volume.LinodeLabel) | ||
| assert.NotContains(t, "-updated", volume.Label) | ||
| assert.Empty(t, volume.Tags) | ||
| assert.True(t, volume.IOReady) | ||
|
|
||
| labelUpdated := volume.Label + "-updated" | ||
| tagsUpdated := []string{"updated"} | ||
|
|
||
| updateOpts := linodego.VolumeUpdateOptions{ | ||
| Label: labelUpdated, | ||
| Tags: &tagsUpdated, | ||
| } | ||
| volume, err := client.UpdateVolume(context.Background(), volume.ID, updateOpts) | ||
| require.NoErrorf(t, err, "Error updating volume: %v", err) | ||
|
|
||
| instanceVolumes, err := client.ListInstanceVolumes(context.Background(), instance.ID, nil) | ||
| require.NoErrorf(t, err, "Error listing instance volumes: %v", err) | ||
| require.Len(t, instanceVolumes, 1, "Expected 1 volume attached to instance, got %d", len(instanceVolumes)) | ||
| assert.Equal(t, instance.ID, *instanceVolumes[0].LinodeID) | ||
| assert.Equal(t, instance.Label, instanceVolumes[0].LinodeLabel) | ||
| assert.Equal(t, labelUpdated, instanceVolumes[0].Label) | ||
| assert.Equal(t, tagsUpdated, instanceVolumes[0].Tags) | ||
| assert.True(t, instanceVolumes[0].IOReady) | ||
|
|
||
| volume, err = client.GetVolume(context.Background(), volume.ID) | ||
| require.NoErrorf(t, err, "Error getting updated volume: %v", err) | ||
| assert.Equal(t, instance.ID, *volume.LinodeID) | ||
| assert.Equal(t, instance.Label, volume.LinodeLabel) | ||
| assert.Equal(t, labelUpdated, volume.Label) | ||
| assert.Equal(t, tagsUpdated, volume.Tags) | ||
| assert.True(t, volume.IOReady) | ||
| } | ||
|
|
||
| func TestIAM_GetIOReadyForClonedVolume(t *testing.T) { | ||
| t.Skip("Skipping test due to possible API defect - JIRA ticket: STORENGSUP-855") | ||
|
|
||
| client, volume, instance, teardown := setupVolumeAttachedToLinode(t, "fixtures/TestIAM_GetIOReadyForClonedVolume", true) | ||
| defer teardown() | ||
| assert.Equal(t, instance.ID, *volume.LinodeID) | ||
| assert.Equal(t, instance.Label, volume.LinodeLabel) | ||
| assert.True(t, volume.IOReady) | ||
|
|
||
| labelCloned := volume.Label + "-cloned" | ||
|
|
||
| instanceVolumes, err := client.ListInstanceVolumes(context.Background(), instance.ID, nil) | ||
| require.NoErrorf(t, err, "Error listing instance volumes: %v", err) | ||
| require.Len(t, instanceVolumes, 1, "Expected 1 volume attached to instance, got %d", len(instanceVolumes)) | ||
|
|
||
| volumeCloned, err := client.CloneVolume(context.Background(), volume.ID, labelCloned) | ||
| require.NoErrorf(t, err, "Error cloning volume: %v", err) | ||
|
|
||
| instanceVolumes, err = client.ListInstanceVolumes(context.Background(), instance.ID, nil) | ||
| require.NoErrorf(t, err, "Error listing instance volumes: %v", err) | ||
| require.Len(t, instanceVolumes, 2, "Expected 2 volumes attached to instance, got %d", len(instanceVolumes)) | ||
| for _, vol := range instanceVolumes { | ||
| assert.Equal(t, instance.ID, *vol.LinodeID) | ||
| assert.Equal(t, instance.Label, vol.LinodeLabel) | ||
| assert.True(t, vol.IOReady) | ||
| } | ||
|
|
||
| volumeCloned, err = client.GetVolume(context.Background(), volumeCloned.ID) | ||
| require.NoErrorf(t, err, "Error getting cloned volume: %v", err) | ||
| assert.Equal(t, labelCloned, volumeCloned.Label) | ||
| assert.Equal(t, instance.ID, *volumeCloned.LinodeID) | ||
| assert.Equal(t, instance.Label, volumeCloned.LinodeLabel) | ||
| assert.True(t, volume.IOReady) | ||
|
mawilk90 marked this conversation as resolved.
Outdated
|
||
|
|
||
| // Cleaning the cloned volume | ||
| err = client.DetachVolume(context.Background(), volumeCloned.ID) | ||
| require.NoErrorf(t, err, "Error detaching cloned volume: %v", err) | ||
|
|
||
| _, err = client.WaitForVolumeIOReadyStatus(context.Background(), volume.ID, false, 15) | ||
|
mawilk90 marked this conversation as resolved.
Outdated
|
||
| require.NoErrorf(t, err, "Error waiting for IO Ready status of detached volume: %v", err) | ||
|
|
||
| err = client.DeleteVolume(context.Background(), volumeCloned.ID) | ||
| require.NoErrorf(t, err, "Error deleting cloned volume: %v", err) | ||
| } | ||
|
|
||
| func TestIAM_GetIOReadyForResizedVolume(t *testing.T) { | ||
| client, volume, instance, teardown := setupVolumeAttachedToLinode(t, "fixtures/TestIAM_GetIOReadyForResizedVolume", true) | ||
| defer teardown() | ||
| assert.Equal(t, instance.ID, *volume.LinodeID) | ||
| assert.Equal(t, instance.Label, volume.LinodeLabel) | ||
| assert.True(t, volume.IOReady) | ||
|
|
||
| newSize := volume.Size + 10 | ||
|
|
||
| err := client.ResizeVolume(context.Background(), volume.ID, newSize) | ||
| require.NoErrorf(t, err, "Error resizing volume: %v", err) | ||
|
|
||
| _, err = client.WaitForVolumeStatus(context.Background(), volume.ID, linodego.VolumeActive, 30) | ||
| require.NoErrorf(t, err, "Error waiting for volume to be active: %v", err) | ||
|
|
||
| instanceVolumes, err := client.ListInstanceVolumes(context.Background(), instance.ID, nil) | ||
| require.NoErrorf(t, err, "Error listing instance volumes: %v", err) | ||
| require.Len(t, instanceVolumes, 1, "Expected 1 volume attached to instance, got %d", len(instanceVolumes)) | ||
| assert.Equal(t, instance.ID, *instanceVolumes[0].LinodeID) | ||
| assert.Equal(t, instance.Label, instanceVolumes[0].LinodeLabel) | ||
| assert.Equal(t, newSize, instanceVolumes[0].Size) | ||
| assert.True(t, instanceVolumes[0].IOReady) | ||
|
|
||
| volume, err = client.GetVolume(context.Background(), volume.ID) | ||
| require.NoErrorf(t, err, "Error getting updated volume: %v", err) | ||
| assert.Equal(t, instance.ID, *volume.LinodeID) | ||
| assert.Equal(t, instance.Label, volume.LinodeLabel) | ||
| assert.Equal(t, newSize, volume.Size) | ||
| assert.True(t, volume.IOReady) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.