Skip to content

Commit 99f85ab

Browse files
committed
E2E: role-import working
1 parent 1a09c94 commit 99f85ab

File tree

8 files changed

+148
-0
lines changed

8 files changed

+148
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: Role
4+
metadata:
5+
name: role-import
6+
status:
7+
conditions:
8+
- type: Available
9+
message: Waiting for OpenStack resource to be created externally
10+
status: "False"
11+
reason: Progressing
12+
- type: Progressing
13+
message: Waiting for OpenStack resource to be created externally
14+
status: "True"
15+
reason: Progressing
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: Role
4+
metadata:
5+
name: role-import
6+
spec:
7+
cloudCredentialsRef:
8+
cloudName: openstack-admin
9+
secretName: openstack-clouds
10+
managementPolicy: unmanaged
11+
import:
12+
filter:
13+
name: role-import-external
14+
# TODO(scaffolding): Add all fields supported by the filter
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestStep
4+
commands:
5+
- command: kubectl create secret generic openstack-clouds --from-file=clouds.yaml=${E2E_KUTTL_OSCLOUDS} ${E2E_KUTTL_CACERT_OPT}
6+
namespaced: true
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: Role
4+
metadata:
5+
name: role-import-external-not-this-one
6+
status:
7+
conditions:
8+
- type: Available
9+
message: OpenStack resource is available
10+
status: "True"
11+
reason: Success
12+
- type: Progressing
13+
message: OpenStack resource is up to date
14+
status: "False"
15+
reason: Success
16+
resource:
17+
name: role-import-external-not-this-one
18+
19+
# TODO(scaffolding): Add fields necessary to match filter
20+
---
21+
apiVersion: openstack.k-orc.cloud/v1alpha1
22+
kind: Role
23+
metadata:
24+
name: role-import
25+
status:
26+
conditions:
27+
- type: Available
28+
message: Waiting for OpenStack resource to be created externally
29+
status: "False"
30+
reason: Progressing
31+
- type: Progressing
32+
message: Waiting for OpenStack resource to be created externally
33+
status: "True"
34+
reason: Progressing
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
# This `role-import-external-not-this-one` resource serves two purposes:
3+
# - ensure that we can successfully create another resource which name is a substring of it (i.e. it's not being adopted)
4+
# - ensure that importing a resource which name is a substring of it will not pick this one.
5+
apiVersion: openstack.k-orc.cloud/v1alpha1
6+
kind: Role
7+
metadata:
8+
name: role-import-external-not-this-one
9+
spec:
10+
cloudCredentialsRef:
11+
# TODO(scaffolding): Use openstack-admin if the resouce needs admin credentials to be created
12+
cloudName: openstack-admin
13+
secretName: openstack-clouds
14+
managementPolicy: managed
15+
resource: {}
16+
# TODO(scaffolding): Add fields necessary to match filter
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
apiVersion: kuttl.dev/v1beta1
3+
kind: TestAssert
4+
resourceRefs:
5+
- apiVersion: openstack.k-orc.cloud/v1alpha1
6+
kind: Role
7+
name: role-import-external
8+
ref: role1
9+
- apiVersion: openstack.k-orc.cloud/v1alpha1
10+
kind: Role
11+
name: role-import-external-not-this-one
12+
ref: role2
13+
assertAll:
14+
- celExpr: "role1.status.id != role2.status.id"
15+
---
16+
apiVersion: openstack.k-orc.cloud/v1alpha1
17+
kind: Role
18+
metadata:
19+
name: role-import
20+
status:
21+
conditions:
22+
- type: Available
23+
message: OpenStack resource is available
24+
status: "True"
25+
reason: Success
26+
- type: Progressing
27+
message: OpenStack resource is up to date
28+
status: "False"
29+
reason: Success
30+
resource:
31+
name: role-import-external
32+
# TODO(scaffolding): Add all fields the resource supports
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: Role
4+
metadata:
5+
name: role-import-external
6+
spec:
7+
cloudCredentialsRef:
8+
# TODO(scaffolding): Use openstack-admin if the resouce needs admin credentials to be created
9+
cloudName: openstack-admin
10+
secretName: openstack-clouds
11+
managementPolicy: managed
12+
resource: {}
13+
# TODO(scaffolding): Add fields necessary to match filter
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Import Role
2+
3+
## Step 00
4+
5+
Import a role, matching all of the available filter's fields, and verify it is waiting for the external resource to be created.
6+
7+
## Step 01
8+
9+
Create a role which name is a superstring of the one specified in the import filter, and otherwise matching the filter, and verify that it's not being imported.
10+
11+
## Step 02
12+
13+
Create a role matching the filter and verify that the observed status on the imported role corresponds to the spec of the created role.
14+
Also verify that the created role didn't adopt the one which name is a superstring of it.
15+
16+
## Reference
17+
18+
https://k-orc.cloud/development/writing-tests/#import

0 commit comments

Comments
 (0)