forked from k-orc/openstack-resource-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a regular expression in server ListOSResourcesForAdoption
In adoption use a regular expression to get a specific server instead of using the name as it is which can lead to getting servers that contain the server name in their names Example: We look for 'foo' where there is a server 'foobar' Also added a test for server adoption - Create one server named 'create-adoption'. - Create another server with the substring of the first - 'adoption' - Test that the resource name of the second server is 'adoption'. Done the same for import - same fix and added a test Fixes k-orc#250
- Loading branch information
1 parent
88322db
commit 08ef35a
Showing
21 changed files
with
388 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
8 changes: 8 additions & 0 deletions
8
internal/controllers/server/tests/create-adoption/00-assert.yaml
This file contains 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,8 @@ | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: create-adoption | ||
status: | ||
resource: | ||
name: create-adoption |
7 changes: 7 additions & 0 deletions
7
internal/controllers/server/tests/create-adoption/00-flavor.yaml
This file contains 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,7 @@ | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT} | ||
namespaced: true | ||
- script: cat ../templates/create-flavor.tmpl |envsubst | kubectl -n ${NAMESPACE} apply -f - |
71 changes: 71 additions & 0 deletions
71
internal/controllers/server/tests/create-adoption/00-server.yaml
This file contains 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,71 @@ | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Image | ||
metadata: | ||
name: create-adoption | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack-admin | ||
secretName: openstack-clouds | ||
managementPolicy: managed | ||
resource: | ||
content: | ||
diskFormat: qcow2 | ||
download: | ||
url: https://download.cirros-cloud.net/0.6.3/cirros-0.6.3-x86_64-disk.img | ||
visibility: public | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Network | ||
metadata: | ||
name: create-adoption | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: managed | ||
resource: | ||
name: create-adoption | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Subnet | ||
metadata: | ||
name: create-adoption | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: managed | ||
networkRef: create-adoption | ||
resource: | ||
ipVersion: 4 | ||
cidr: 192.168.200.0/24 | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Port | ||
metadata: | ||
name: create-adoption | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: managed | ||
networkRef: create-adoption | ||
resource: | ||
addresses: | ||
- subnetRef: create-adoption | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: create-adoption | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: managed | ||
resource: | ||
imageRef: create-adoption | ||
flavorRef: server-flavor | ||
ports: | ||
- portRef: create-adoption |
28 changes: 28 additions & 0 deletions
28
internal/controllers/server/tests/create-adoption/01-adoption-server.yaml
This file contains 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,28 @@ | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Port | ||
metadata: | ||
name: adoption | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: managed | ||
networkRef: create-adoption | ||
resource: | ||
addresses: | ||
- subnetRef: create-adoption | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: adoption | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: managed | ||
resource: | ||
imageRef: create-adoption | ||
flavorRef: server-flavor | ||
ports: | ||
- portRef: adoption |
8 changes: 8 additions & 0 deletions
8
internal/controllers/server/tests/create-adoption/01-assert.yaml
This file contains 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,8 @@ | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: adoption | ||
status: | ||
resource: | ||
name: adoption |
20 changes: 20 additions & 0 deletions
20
internal/controllers/server/tests/create-adoption/02-assert.yaml
This file contains 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,20 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
commands: | ||
- script: "! kubectl get server create-adoption --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
- script: "! kubectl get port create-adoption --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
- script: "! kubectl get server adoption --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
- script: "! kubectl get port adoption --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
- script: "! kubectl get subnet create-adoption --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
- script: "! kubectl get network create-adoption --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
- script: "! kubectl get flavor server-flavor --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
- script: "! kubectl get image create-adoption --namespace $NAMESPACE" | ||
skipLogOutput: true | ||
|
27 changes: 27 additions & 0 deletions
27
internal/controllers/server/tests/create-adoption/02-cleanup.yaml
This file contains 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,27 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
delete: | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
name: create-adoption | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Port | ||
name: create-adoption | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
name: adoption | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Port | ||
name: adoption | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Subnet | ||
name: create-adoption | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Network | ||
name: create-adoption | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Flavor | ||
name: server-flavor | ||
- apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Image | ||
name: create-adoption |
13 changes: 13 additions & 0 deletions
13
internal/controllers/server/tests/create-adoption/README.md
This file contains 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,13 @@ | ||
# Create two servers to test adoption | ||
|
||
## Step 00 | ||
|
||
Import a flavor, create an image,network,subnet and a port and then create a server with name 'create-adoption'. | ||
|
||
## Step 01 | ||
Create another server with the name 'adoption'. The second server should have a resource name of 'adoption' | ||
|
||
## Step 02 | ||
|
||
Validate we're able to delete resources. | ||
Cleaning up resources also avoids a race where kuttl could delete the secret before the other resources. |
This file contains 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,30 @@ | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: import | ||
status: | ||
conditions: | ||
- type: Available | ||
message: Waiting for OpenStack resource to be created externally | ||
status: "False" | ||
reason: Progressing | ||
- type: Progressing | ||
message: Waiting for OpenStack resource to be created externally | ||
status: "True" | ||
reason: Progressing | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: import-error | ||
status: | ||
conditions: | ||
- type: Available | ||
message: Waiting for OpenStack resource to be created externally | ||
status: "False" | ||
reason: Progressing | ||
- type: Progressing | ||
message: Waiting for OpenStack resource to be created externally | ||
status: "True" | ||
reason: Progressing |
This file contains 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,7 @@ | ||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT} | ||
namespaced: true | ||
- script: cat ../templates/create-flavor.tmpl |envsubst | kubectl -n ${NAMESPACE} apply -f - |
13 changes: 13 additions & 0 deletions
13
internal/controllers/server/tests/import/00-import-server-error.yaml
This file contains 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,13 @@ | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: import-error | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: unmanaged | ||
import: | ||
filter: | ||
name: external |
13 changes: 13 additions & 0 deletions
13
internal/controllers/server/tests/import/00-import-server.yaml
This file contains 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,13 @@ | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: import | ||
spec: | ||
cloudCredentialsRef: | ||
cloudName: openstack | ||
secretName: openstack-clouds | ||
managementPolicy: unmanaged | ||
import: | ||
filter: | ||
name: import-external |
This file contains 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,32 @@ | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: import | ||
status: | ||
conditions: | ||
- type: Available | ||
message: OpenStack resource is available | ||
status: "True" | ||
reason: Success | ||
- type: Progressing | ||
message: OpenStack resource is up to date | ||
status: "False" | ||
reason: Success | ||
resource: | ||
name: import-external | ||
--- | ||
apiVersion: openstack.k-orc.cloud/v1alpha1 | ||
kind: Server | ||
metadata: | ||
name: import-error | ||
status: | ||
conditions: | ||
- type: Available | ||
message: Waiting for OpenStack resource to be created externally | ||
status: "False" | ||
reason: Progressing | ||
- type: Progressing | ||
message: Waiting for OpenStack resource to be created externally | ||
status: "True" | ||
reason: Progressing |
Oops, something went wrong.