Skip to content

Commit 6b57489

Browse files
authored
Merge pull request gophercloud#3400 from shiftstack/fix-gate
Fix broken build from gophercloud#3332
2 parents 7ace507 + f08dd3e commit 6b57489

6 files changed

Lines changed: 29 additions & 24 deletions

File tree

internal/acceptance/openstack/blockstorage/v3/blockstorage.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,15 +789,20 @@ func Unmanage(t *testing.T, client *gophercloud.ServiceClient, volume *volumes.V
789789
return err
790790
}
791791

792-
gophercloud.WaitFor(context.TODO(), func(ctx context.Context) (bool, error) {
792+
err = gophercloud.WaitFor(context.TODO(), func(ctx context.Context) (bool, error) {
793793
if _, err := volumes.Get(ctx, client, volume.ID).Extract(); err != nil {
794-
if _, ok := err.(gophercloud.ErrResourceNotFound); ok {
795-
return true, nil
794+
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
795+
if errCode.Actual == 404 {
796+
return true, nil
797+
}
796798
}
797799
return false, err
798800
}
799801
return false, nil
800802
})
803+
if err != nil {
804+
return err
805+
}
801806

802807
t.Logf("Successfully unmanaged volume %s", volume.ID)
803808

openstack/blockstorage/v3/manageablevolumes/testing/fixtures_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
fake "github.com/gophercloud/gophercloud/v2/testhelper/client"
1010
)
1111

12-
func MockManageExistingResponse(t *testing.T) {
13-
th.Mux.HandleFunc("/manageable_volumes", func(w http.ResponseWriter, r *http.Request) {
12+
func MockManageExistingResponse(t *testing.T, fakeServer th.FakeServer) {
13+
fakeServer.Mux.HandleFunc("/manageable_volumes", func(w http.ResponseWriter, r *http.Request) {
1414
th.TestMethod(t, r, "POST")
1515
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
1616
th.TestHeader(t, r, "Content-Type", "application/json")

openstack/blockstorage/v3/manageablevolumes/testing/requests_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import (
1010
)
1111

1212
func TestManageExisting(t *testing.T) {
13-
th.SetupHTTP()
14-
defer th.TeardownHTTP()
13+
fakeServer := th.SetupHTTP()
14+
defer fakeServer.Teardown()
1515

16-
MockManageExistingResponse(t)
16+
MockManageExistingResponse(t, fakeServer)
1717

1818
options := &manageablevolumes.ManageExistingOpts{
1919
Host: "host@lvm#LVM",
@@ -28,7 +28,7 @@ func TestManageExisting(t *testing.T) {
2828
"key2": "value2",
2929
},
3030
}
31-
n, err := manageablevolumes.ManageExisting(context.TODO(), client.ServiceClient(), options).Extract()
31+
n, err := manageablevolumes.ManageExisting(context.TODO(), client.ServiceClient(fakeServer), options).Extract()
3232
th.AssertNoErr(t, err)
3333

3434
th.AssertEquals(t, n.Host, "host@lvm#LVM")

openstack/blockstorage/v3/volumes/testing/fixtures_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,11 @@ func MockResetStatusResponse(t *testing.T, fakeServer th.FakeServer) {
649649
})
650650
}
651651

652-
func MockUnmanageResponse(t *testing.T) {
653-
th.Mux.HandleFunc("/volumes/cd281d77-8217-4830-be95-9528227c105c/action",
652+
func MockUnmanageResponse(t *testing.T, fakeServer th.FakeServer) {
653+
fakeServer.Mux.HandleFunc("/volumes/cd281d77-8217-4830-be95-9528227c105c/action",
654654
func(w http.ResponseWriter, r *http.Request) {
655655
th.TestMethod(t, r, "POST")
656-
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
656+
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
657657
th.TestHeader(t, r, "Content-Type", "application/json")
658658
th.TestJSONRequest(t, r, `
659659
{

openstack/blockstorage/v3/volumes/testing/requests_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,11 +540,11 @@ func TestResetStatus(t *testing.T) {
540540
}
541541

542542
func TestUnmanage(t *testing.T) {
543-
th.SetupHTTP()
544-
defer th.TeardownHTTP()
543+
fakeServer := th.SetupHTTP()
544+
defer fakeServer.Teardown()
545545

546-
MockUnmanageResponse(t)
546+
MockUnmanageResponse(t, fakeServer)
547547

548-
err := volumes.Unmanage(context.TODO(), client.ServiceClient(), "cd281d77-8217-4830-be95-9528227c105c").ExtractErr()
548+
err := volumes.Unmanage(context.TODO(), client.ServiceClient(fakeServer), "cd281d77-8217-4830-be95-9528227c105c").ExtractErr()
549549
th.AssertNoErr(t, err)
550550
}

script/getenvvar

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ if 'username' not in auth or 'password' not in auth:
7373
# """.strip()
7474

7575
result = f"""
76-
unset OS_CLOUD
77-
export OS_AUTH_URL={auth['auth_url']}
78-
export OS_USERNAME={auth['username']}
79-
export OS_PASSWORD={auth['password']}
80-
export OS_PROJECT_NAME={auth['project_name']}
81-
export OS_DOMAIN_ID={auth['user_domain_id']}
82-
export OS_REGION_NAME={cloud['region_name']}
76+
unset OS_CLOUD;
77+
export OS_AUTH_URL={auth['auth_url']};
78+
export OS_USERNAME={auth['username']};
79+
export OS_PASSWORD={auth['password']};
80+
export OS_PROJECT_NAME={auth['project_name']};
81+
export OS_DOMAIN_ID={auth['user_domain_id']};
82+
export OS_REGION_NAME={cloud['region_name']};
8383
"""
8484

85-
print(result)
85+
print(result.strip())

0 commit comments

Comments
 (0)