Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[v2] Add versioned endpoint discovery #3435

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
wants to merge 24 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
43f2c9c
tests: Avoid use of global objects
stephenfin Jul 17, 2024
e918088
tests: Add missing fake servers
stephenfin Jul 17, 2024
fcf44f4
[nova] fix pagination of hypervisors.List()
majewsky Oct 21, 2024
dd4d795
trivial: Remove duplicate imports
stephenfin Jul 17, 2024
2de3b17
tests: Consistent testhelper client naming
stephenfin May 20, 2025
da5ed91
tests: Remove duplicate fake client method
stephenfin Jul 17, 2024
bf9b2d2
tests: Avoid use of global mocked server
stephenfin Jul 17, 2024
edf832f
Randomize test order for unit tests
stephenfin May 20, 2025
33ebd78
trivial: Simplify endpoint filtering
stephenfin Apr 16, 2025
9d63afe
Add EndpointOpts.Version field
stephenfin Apr 16, 2025
f9db8b4
Add BaseVersionedEndpoint helper
stephenfin Apr 17, 2025
d756575
Add new service discovery helper
stephenfin Apr 17, 2025
5c1572f
Add V2Endpoint, V3Endpoint helpers
stephenfin Apr 17, 2025
f7e8b9d
Add endpoint discovery support
stephenfin Apr 17, 2025
1e8d4ac
Add implied version check
stephenfin Apr 17, 2025
3d5fab4
Switch clients to versioned endpoint discovery helpers
stephenfin Apr 17, 2025
2473a60
Move discovery logic to its own file
stephenfin Jun 16, 2025
12f9809
Rework discovery tests
stephenfin Jun 16, 2025
d58f3cb
Add tests for GetServiceVersions
stephenfin Jun 18, 2025
d21f3a8
Consider API major version, not API microversion major version
stephenfin Jun 18, 2025
4c45857
Support different types of version documents
stephenfin Jun 11, 2025
04925bd
Infer version from URL where possible
stephenfin Jun 18, 2025
da7a664
Trigger functional tests for changes to common code
stephenfin Jun 11, 2025
14f6c35
tests: Fix TestVLANTransparentCRUD test
stephenfin Jun 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .github/workflows/functional-baremetal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-baremetal
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**baremetal**'
- '.github/workflows/functional-baremetal.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-blockstorage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-blockstorage
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**blockstorage**'
- '.github/workflows/functional-blockstorage.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-compute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-compute
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**compute**'
- '.github/workflows/functional-compute.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-containerinfra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-containerinfra
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**containerinfra**'
- '.github/workflows/functional-containerinfra.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-dns
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**dns**'
- '.github/workflows/functional-dns.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-fwaas_v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ name: functional-fwaas_v2
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**networking/v2/extensions/fwaas_v2**'
- '.github/workflows/functional-fwaas_v2.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-identity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-identity
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**identity**'
- '.github/workflows/functional-identity.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-image
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**image**'
- '.github/workflows/functional-image.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-keymanager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-keymanager
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**keymanager**'
- '.github/workflows/functional-keymanager.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-loadbalancer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-loadbalancer
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**loadbalancer**'
- '.github/workflows/functional-loadbalancer.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-messaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-messaging
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**messaging**'
- '.github/workflows/functional-messaging.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-networking.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-networking
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**networking**'
- '.github/workflows/functional-networking.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-objectstorage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-objectstorage
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**objectstorage**'
- '.github/workflows/functional-objectstorage.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-orchestration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-orchestration
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**orchestration**'
- '.github/workflows/functional-orchestration.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-placement.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-placement
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**placement**'
- '.github/workflows/functional-placement.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-sharedfilesystems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-sharedfilesystems
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**sharedfilesystems**'
- '.github/workflows/functional-sharedfilesystems.yaml'
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/functional-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: functional-workflow
on:
pull_request:
paths:
- 'openstack/auth_env.go'
- 'openstack/client.go'
- 'openstack/endpoint.go'
- 'openstack/endpoint_location.go'
- 'openstack/config/provider_client.go'
- 'openstack/utils/choose_version.go'
- 'openstack/utils/discovery.go'
- '**workflow**'
- '.github/workflows/functional-workflow.yaml'
schedule:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ format:
.PHONY: format

unit:
$(GO_TEST) ./...
$(GO_TEST) -shuffle on ./...
.PHONY: unit

coverage:
$(GO_TEST) -covermode count -coverprofile cover.out -coverpkg=./... ./...
$(GO_TEST) -shuffle on -covermode count -coverprofile cover.out -coverpkg=./... ./...
.PHONY: coverage

acceptance: acceptance-basic acceptance-baremetal acceptance-blockstorage acceptance-compute acceptance-container acceptance-containerinfra acceptance-db acceptance-dns acceptance-identity acceptance-image acceptance-keymanager acceptance-loadbalancer acceptance-messaging acceptance-networking acceptance-objectstorage acceptance-orchestration acceptance-placement acceptance-sharedfilesystems acceptance-workflow
Expand Down
12 changes: 6 additions & 6 deletions docs/contributor-tutorial/.template/testing/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestListResources(t *testing.T) {
HandleListResourcesSuccessfully(t)

count := 0
err := resources.List(client.ServiceClient(), nil).EachPage(context.TODO(), func(_ context.Context, page pagination.Page) (bool, error) {
err := resources.List(client.ServiceClient(fakeServer), nil).EachPage(context.TODO(), func(_ context.Context, page pagination.Page) (bool, error) {
count++

actual, err := resources.ExtractResources(page)
Expand All @@ -35,7 +35,7 @@ func TestListResourcesAllPages(t *testing.T) {
defer th.TeardownHTTP()
HandleListResourcesSuccessfully(t)

allPages, err := resources.List(client.ServiceClient(), nil).AllPages(context.TODO())
allPages, err := resources.List(client.ServiceClient(fakeServer), nil).AllPages(context.TODO())
th.AssertNoErr(t, err)
actual, err := resources.ExtractResources(allPages)
th.AssertNoErr(t, err)
Expand All @@ -47,7 +47,7 @@ func TestGetResource(t *testing.T) {
defer th.TeardownHTTP()
HandleGetResourceSuccessfully(t)

actual, err := resources.Get(context.TODO(), client.ServiceClient(), "9fe1d3").Extract()
actual, err := resources.Get(context.TODO(), client.ServiceClient(fakeServer), "9fe1d3").Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, SecondResource, *actual)
}
Expand All @@ -61,7 +61,7 @@ func TestCreateResource(t *testing.T) {
Name: "resource two",
}

actual, err := resources.Create(context.TODO(), client.ServiceClient(), createOpts).Extract()
actual, err := resources.Create(context.TODO(), client.ServiceClient(fakeServer), createOpts).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, SecondResource, *actual)
}
Expand All @@ -71,7 +71,7 @@ func TestDeleteResource(t *testing.T) {
defer th.TeardownHTTP()
HandleDeleteResourceSuccessfully(t)

res := resources.Delete(context.TODO(), client.ServiceClient(), "9fe1d3")
res := resources.Delete(context.TODO(), client.ServiceClient(fakeServer), "9fe1d3")
th.AssertNoErr(t, res.Err)
}

Expand All @@ -84,7 +84,7 @@ func TestUpdateResource(t *testing.T) {
Description: "Staging Resource",
}

actual, err := resources.Update(context.TODO(), client.ServiceClient(), "9fe1d3", updateOpts).Extract()
actual, err := resources.Update(context.TODO(), client.ServiceClient(fakeServer), "9fe1d3", updateOpts).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, SecondResourceUpdated, *actual)
}
5 changes: 5 additions & 0 deletions endpoint_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ type EndpointOpts struct {
// Required only for services that span multiple regions.
Region string

// Version [optional] is the major version of the service required. It it not
// a microversion. Use this to ensure the correct endpoint is selected when
// multiple API versions are available.
Version int

// Availability [optional] is the visibility of the endpoint to be returned.
// Valid types include the constants AvailabilityPublic, AvailabilityInternal,
// or AvailabilityAdmin from this package.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,33 +75,3 @@ func CreateVLANTransparentNetwork(t *testing.T, client *gophercloud.ServiceClien

return &network, nil
}

// UpdateVLANTransparentNetwork will update a network with the
// "vlan-transparent" extension. An error will be returned if the network could
// not be updated.
func UpdateVLANTransparentNetwork(t *testing.T, client *gophercloud.ServiceClient, networkID string) (*VLANTransparentNetwork, error) {
networkName := tools.RandomString("TESTACC-NEW-", 6)
networkUpdateOpts := networks.UpdateOpts{
Name: &networkName,
}

iFalse := false
updateOpts := vlantransparent.UpdateOptsExt{
UpdateOptsBuilder: &networkUpdateOpts,
VLANTransparent: &iFalse,
}

t.Logf("Attempting to update a VLAN-transparent network: %s", networkID)

var network VLANTransparentNetwork
err := networks.Update(context.TODO(), client, networkID, updateOpts).ExtractInto(&network)
if err != nil {
return nil, err
}

t.Logf("Successfully updated the network.")

th.AssertEquals(t, networkName, network.Name)

return &network, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ func TestVLANTransparentCRUD(t *testing.T) {

tools.PrintResource(t, network)

// Update the created VLAN transparent network.
newNetwork, err := UpdateVLANTransparentNetwork(t, client, network.ID)
th.AssertNoErr(t, err)

tools.PrintResource(t, newNetwork)
// The vlan_transparent field is read-only so no update test

// Check that the created VLAN transparent network exists.
vlanTransparentNetworks, err := ListVLANTransparentNetworks(t, client)
Expand Down
8 changes: 4 additions & 4 deletions openstack/baremetal/apiversions/testing/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ var IronicAllAPIVersionResults = apiversions.APIVersions{
},
}

func MockListResponse(t *testing.T) {
th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
func MockListResponse(t *testing.T, fakeServer th.FakeServer) {
fakeServer.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)

Expand All @@ -93,8 +93,8 @@ func MockListResponse(t *testing.T) {
})
}

func MockGetResponse(t *testing.T) {
th.Mux.HandleFunc("/v1/", func(w http.ResponseWriter, r *http.Request) {
func MockGetResponse(t *testing.T, fakeServer th.FakeServer) {
fakeServer.Mux.HandleFunc("/v1/", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)

Expand Down
Loading
Loading