@@ -5,6 +5,7 @@ package integration_test
55import (
66 "context"
77 "os"
8+ "strings"
89 "testing"
910
1011 "github.com/joho/godotenv"
@@ -14,7 +15,7 @@ import (
1415)
1516
1617// Use .env file or run tests with environment variables:
17- // AWS_PROFILE=default AWS_INSTANCE_ID =i-1234567890abcdef0 go test -v ./pkg/cloudprovider/aws/test/...
18+ // AWS_PROFILE=default AWS_INSTANCE_IDS =i-1234567890abcdef0,i-0987654321fedcba0 go test -v ./pkg/cloudprovider/aws/test/...
1819func init () {
1920 _ = godotenv .Load (".env" )
2021}
@@ -60,34 +61,34 @@ func TestGetStorageState(t *testing.T) {
6061
6162 p := provider .(* aws.Provider )
6263
63- // Test storage state refresh with instance ID
64- instanceID := os .Getenv ("AWS_INSTANCE_ID" )
65- if instanceID == "" {
66- t .Fatal ("AWS_INSTANCE_ID not set" )
64+ instanceIDsStr := os .Getenv ("AWS_INSTANCE_IDS" )
65+ if instanceIDsStr == "" {
66+ t .Fatal ("AWS_INSTANCE_IDS not set" )
6767 }
6868
69- // Get the cached storage state
70- state , err := p .GetStorageState (ctx , instanceID )
71- if err != nil {
72- t .Fatalf ("GetStorageState failed: %v" , err )
69+ instanceIDs := strings .Split (instanceIDsStr , "," )
70+ for i := range instanceIDs {
71+ instanceIDs [i ] = strings .TrimSpace (instanceIDs [i ])
7372 }
7473
75- volumes , ok := state . InstanceVolumes [ instanceID ]
76- if ! ok {
77- t .Fatalf ("No volumes found for instance %s " , instanceID )
74+ state , err := p . GetStorageState ( ctx , instanceIDs ... )
75+ if err != nil {
76+ t .Fatalf ("GetStorageState failed: %v " , err )
7877 }
7978
80- t .Logf ("Found %d volumes attached to instance %s:" , len (volumes ), instanceID )
81- for _ , v := range volumes {
82- t .Logf (" Volume:" )
83- t .Logf (" VolumeID: %s" , v .VolumeID )
84- t .Logf (" VolumeType: %s" , v .VolumeType )
85- t .Logf (" VolumeState: %s" , v .VolumeState )
86- t .Logf (" SizeBytes: %d" , v .SizeBytes )
87- t .Logf (" AvailabilityZone: %s" , v .Zone )
88- t .Logf (" Encrypted: %v" , v .Encrypted )
89- t .Logf (" IOPS: %d" , v .IOPS )
90- t .Logf (" ThroughputBytes: %d B/s" , v .ThroughputBytes )
79+ for instanceID , volumes := range state .InstanceVolumes {
80+ t .Logf ("Found %d volumes attached to instance %s:" , len (volumes ), instanceID )
81+ for _ , v := range volumes {
82+ t .Logf (" Volume:" )
83+ t .Logf (" VolumeID: %s" , v .VolumeID )
84+ t .Logf (" VolumeType: %s" , v .VolumeType )
85+ t .Logf (" VolumeState: %s" , v .VolumeState )
86+ t .Logf (" SizeBytes: %d" , v .SizeBytes )
87+ t .Logf (" Zone: %s" , v .Zone )
88+ t .Logf (" Encrypted: %v" , v .Encrypted )
89+ t .Logf (" IOPS: %d" , v .IOPS )
90+ t .Logf (" ThroughputBytes: %d B/s" , v .ThroughputBytes )
91+ }
9192 }
9293}
9394
0 commit comments