Skip to content

Commit c9d9d66

Browse files
committed
hostaggregate: Add import test
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 64cc392 commit c9d9d66

8 files changed

Lines changed: 145 additions & 0 deletions

File tree

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: HostAggregate
4+
metadata:
5+
name: hostaggregate-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: HostAggregate
4+
metadata:
5+
name: hostaggregate-import
6+
spec:
7+
cloudCredentialsRef:
8+
cloudName: openstack-admin
9+
secretName: openstack-clouds
10+
managementPolicy: unmanaged
11+
import:
12+
filter:
13+
name: hostaggregate-import-external
14+
availabilityZone: test-az
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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: HostAggregate
4+
metadata:
5+
name: hostaggregate-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: hostaggregate-import-external-not-this-one
18+
availabilityZone: test-az
19+
---
20+
apiVersion: openstack.k-orc.cloud/v1alpha1
21+
kind: HostAggregate
22+
metadata:
23+
name: hostaggregate-import
24+
status:
25+
conditions:
26+
- type: Available
27+
message: Waiting for OpenStack resource to be created externally
28+
status: "False"
29+
reason: Progressing
30+
- type: Progressing
31+
message: Waiting for OpenStack resource to be created externally
32+
status: "True"
33+
reason: Progressing
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
# This `hostaggregate-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: HostAggregate
7+
metadata:
8+
name: hostaggregate-import-external-not-this-one
9+
spec:
10+
cloudCredentialsRef:
11+
cloudName: openstack-admin
12+
secretName: openstack-clouds
13+
managementPolicy: managed
14+
resource:
15+
availabilityZone: test-az
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: HostAggregate
7+
name: hostaggregate-import-external
8+
ref: hostaggregate1
9+
- apiVersion: openstack.k-orc.cloud/v1alpha1
10+
kind: HostAggregate
11+
name: hostaggregate-import-external-not-this-one
12+
ref: hostaggregate2
13+
assertAll:
14+
- celExpr: "hostaggregate1.status.id != hostaggregate2.status.id"
15+
---
16+
apiVersion: openstack.k-orc.cloud/v1alpha1
17+
kind: HostAggregate
18+
metadata:
19+
name: hostaggregate-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: hostaggregate-import-external
32+
availabilityZone: test-az
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: openstack.k-orc.cloud/v1alpha1
3+
kind: HostAggregate
4+
metadata:
5+
name: hostaggregate-import-external
6+
spec:
7+
cloudCredentialsRef:
8+
cloudName: openstack-admin
9+
secretName: openstack-clouds
10+
managementPolicy: managed
11+
resource:
12+
availabilityZone: test-az
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Import HostAggregate
2+
3+
## Step 00
4+
5+
Import a host aggregate, 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 host aggregate 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 host aggregate matching the filter and verify that the observed status on the imported host aggregate corresponds to the spec of the created host aggregate.
14+
Also verify that the created host aggregate 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)