Skip to content

Commit

Permalink
Merge branch 'devel' into refactor-github-actions-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Shakhbazian authored and Artem Shakhbazian committed Jun 27, 2024
2 parents 53885e5 + c0ad755 commit b927895
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 20 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/automerge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,3 @@ jobs:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
MERGE_LABELS: "gate"
MERGE_METHOD: "squash"
- name: feedback
if: ${{ steps.automerge.outputs.mergeResult == 'merged' }}
run: |
echo "Pull request ${{ steps.automerge.outputs.pullRequestNumber }} automatically merged by GitHub Actions!"
14 changes: 13 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
acc_tests:
name: acceptance tests
runs-on: ubuntu-latest
environment: tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
Expand All @@ -58,5 +59,16 @@ jobs:
OS_DOMAIN_NAME: ${{ secrets.USER_DOMAIN_NAME }}
OS_PASSWORD: ${{ secrets.PASSWORD }}
OS_USERNAME: ${{ secrets.USERNAME }}
OS_PROJECT_NAME: ${{ secrets.FUNCTEST_PROJECT_NAME }}
OS_PROJECT_NAME: ${{ vars.FUNCTEST_PROJECT_NAME }}
OS_REGION: "eu-de"

eco_check:
name: eco/check
if: always()
needs: [lint, vet, unit_tests, acc_tests]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
9 changes: 7 additions & 2 deletions acceptance/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,22 @@ func NewBlockStorageV3Client() (*golangsdk.ServiceClient, error) {
}

// NewComputeV2Client returns a *ServiceClient for making calls
// to the OpenStack Compute v2 API. An error will be returned
// to the OpenStack Compute v2.1 API. An error will be returned
// if authentication or client creation was not possible.
func NewComputeV2Client() (*golangsdk.ServiceClient, error) {
cc, err := CloudAndClient()
if err != nil {
return nil, err
}

return openstack.NewComputeV2(cc.ProviderClient, golangsdk.EndpointOpts{
client, err := openstack.NewComputeV2(cc.ProviderClient, golangsdk.EndpointOpts{
Region: cc.RegionName,
})
if err != nil {
return nil, err
}
client.Microversion = "2.55"
return client, err
}

// NewComputeV1Client returns a *ServiceClient for making calls
Expand Down
11 changes: 6 additions & 5 deletions acceptance/openstack/compute/v2/servers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
func TestServerList(t *testing.T) {
client, err := clients.NewComputeV2Client()
th.AssertNoErr(t, err)

listOpts := servers.ListOpts{}
allServerPages, err := servers.List(client, listOpts).AllPages()
th.AssertNoErr(t, err)
Expand Down Expand Up @@ -57,7 +56,7 @@ func TestServerLifecycle(t *testing.T) {

flavorID, err := flavors.IDFromName(client, "s2.large.2")
th.AssertNoErr(t, err)

ecsDescription := "my description"
createOpts := servers.CreateOpts{
Name: ecsName,
ImageRef: image[0].Id,
Expand All @@ -71,6 +70,7 @@ func TestServerLifecycle(t *testing.T) {
UUID: networkID,
},
},
Description: ecsDescription,
}

ecs, err := servers.Create(client, createOpts).Extract()
Expand All @@ -83,6 +83,7 @@ func TestServerLifecycle(t *testing.T) {
ecs, err = servers.Get(client, ecs.ID).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, ecsName, ecs.Name)
th.AssertEquals(t, ecsDescription, ecs.Description)

nicInfo, err := servers.GetNICs(client, ecs.ID).Extract()
th.AssertNoErr(t, err)
Expand Down Expand Up @@ -114,16 +115,16 @@ func TestServerLifecycle(t *testing.T) {

ecsName = tools.RandomString("update-ecs-", 3)
updateOpts := servers.UpdateOpts{
Name: ecsName,
Name: ecsName,
Description: ecsDescription + " update",
}

_, err = servers.Update(client, ecs.ID, updateOpts).Extract()
th.AssertNoErr(t, err)

t.Logf("ECSv2 successfully updated: %s", ecs.ID)
th.AssertNoErr(t, err)

newECS, err := servers.Get(client, ecs.ID).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, ecsName, newECS.Name)
th.AssertEquals(t, ecsDescription+" update", newECS.Description)
}
4 changes: 4 additions & 0 deletions openstack/compute/v2/servers/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ type CreateOpts struct {
// ServiceClient will allow calls to be made to retrieve an image or
// flavor ID by name.
ServiceClient *golangsdk.ServiceClient `json:"-"`

Description string `json:"description,omitempty"`
}

// ToServerCreateMap assembles a request body based on the contents of a
Expand Down Expand Up @@ -338,6 +340,8 @@ type UpdateOpts struct {

// AccessIPv6 provides a new IPv6 address for the instance.
AccessIPv6 string `json:"accessIPv6,omitempty"`

Description string `json:"description,omitempty"`
}

// ToServerUpdateMap formats an UpdateOpts structure into a request body.
Expand Down
12 changes: 10 additions & 2 deletions openstack/compute/v2/servers/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ type GetPasswordResult struct {
// If privateKey != nil the password is decrypted with the private key.
// If privateKey == nil the encrypted password is returned and can be decrypted
// with:
// echo '<pwd>' | base64 -D | openssl rsautl -decrypt -inkey <private_key>
//
// echo '<pwd>' | base64 -D | openssl rsautl -decrypt -inkey <private_key>
func (r GetPasswordResult) ExtractPassword(privateKey *rsa.PrivateKey) (string, error) {
var s struct {
Password string `json:"password"`
Expand Down Expand Up @@ -222,7 +223,14 @@ type Server struct {
Fault Fault `json:"fault"`

// VolumeAttached includes the volumes that attached to the server.
VolumesAttached []map[string]string `json:"os-extended-volumes:volumes_attached"`
VolumesAttached []VolumesDetails `json:"os-extended-volumes:volumes_attached"`

Description string `json:"description"`
}

type VolumesDetails struct {
DeleteOnTermination bool `json:"delete_on_termination"`
ID string `json:"id"`
}

type Fault struct {
Expand Down
20 changes: 14 additions & 6 deletions openstack/compute/v2/servers/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const ServerListBody = `
"OS-DCF:diskConfig": "MANUAL",
"os-extended-volumes:volumes_attached": [
{
"delete_on_termination": true,
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e"
}
],
Expand Down Expand Up @@ -154,6 +155,7 @@ const ServerListBody = `
"OS-DCF:diskConfig": "MANUAL",
"os-extended-volumes:volumes_attached": [
{
"delete_on_termination": true,
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e"
}
],
Expand Down Expand Up @@ -220,6 +222,7 @@ const ServerListBody = `
"OS-DCF:diskConfig": "MANUAL",
"os-extended-volumes:volumes_attached": [
{
"delete_on_termination": true,
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e"
}
],
Expand Down Expand Up @@ -301,6 +304,7 @@ const SingleServerBody = `
"OS-DCF:diskConfig": "MANUAL",
"os-extended-volumes:volumes_attached": [
{
"delete_on_termination": true,
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e"
}
],
Expand Down Expand Up @@ -382,6 +386,7 @@ const FaultyServerBody = `
"OS-DCF:diskConfig": "MANUAL",
"os-extended-volumes:volumes_attached": [
{
"delete_on_termination": true,
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e"
}
],
Expand Down Expand Up @@ -468,9 +473,10 @@ var (
"name": "default",
},
},
VolumesAttached: []map[string]string{
VolumesAttached: []servers.VolumesDetails{
{
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e",
DeleteOnTermination: true,
ID: "cfb68a5e-203f-446d-9fd7-74b7e1f9722e",
},
},
}
Expand Down Expand Up @@ -531,9 +537,10 @@ var (
"name": "default",
},
},
VolumesAttached: []map[string]string{
VolumesAttached: []servers.VolumesDetails{
{
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e",
DeleteOnTermination: true,
ID: "cfb68a5e-203f-446d-9fd7-74b7e1f9722e",
},
},
}
Expand Down Expand Up @@ -588,9 +595,10 @@ var (
"name": "default",
},
},
VolumesAttached: []map[string]string{
VolumesAttached: []servers.VolumesDetails{
{
"id": "cfb68a5e-203f-446d-9fd7-74b7e1f9722e",
DeleteOnTermination: true,
ID: "cfb68a5e-203f-446d-9fd7-74b7e1f9722e",
},
},
}
Expand Down

0 comments on commit b927895

Please sign in to comment.