-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kuttl tests to cover single glanceAPI instance
With the new structure we can either split the glanceAPI (preserving the old behavior) or deploy a "single" instance that will serve both internal and external workloads. This patch introduces kuttl tests to cover the glance_single scenario. Signed-off-by: Francesco Pantano <[email protected]>
- Loading branch information
Showing
15 changed files
with
326 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# | ||
# Check for: | ||
# - Glance CR | ||
# - GlanceAPI glance-single CR | ||
# - GlanceAPI glance-single-api Deployment | ||
# - glance-single-api Pod | ||
# - glance-internal service | ||
# - glance-public service | ||
# - glance internal and public endpoints | ||
|
||
apiVersion: glance.openstack.org/v1beta1 | ||
kind: Glance | ||
metadata: | ||
name: glance | ||
spec: | ||
serviceUser: glance | ||
containerImage: quay.io/podified-antelope-centos9/openstack-glance-api:current-podified | ||
customServiceConfig: | | ||
[DEFAULT] | ||
debug = true | ||
databaseInstance: openstack | ||
databaseUser: glance | ||
glanceAPI: | ||
containerImage: quay.io/podified-antelope-centos9/openstack-glance-api:current-podified | ||
debug: | ||
service: false | ||
replicas: 1 | ||
type: "single" | ||
secret: osp-secret | ||
storageRequest: 10G | ||
status: | ||
databaseHostname: openstack | ||
glanceAPIExternalReadyCount: 1 | ||
--- | ||
apiVersion: glance.openstack.org/v1beta1 | ||
kind: GlanceAPI | ||
metadata: | ||
name: glance-single | ||
spec: | ||
apiType: single | ||
containerImage: quay.io/podified-antelope-centos9/openstack-glance-api:current-podified | ||
databaseUser: glance | ||
databaseHostname: openstack | ||
debug: | ||
service: false | ||
passwordSelectors: | ||
database: GlanceDatabasePassword | ||
service: GlancePassword | ||
replicas: 1 | ||
status: | ||
readyCount: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: glance-single-api | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
service: glance-single | ||
template: | ||
metadata: | ||
labels: | ||
service: glance-single | ||
spec: | ||
containers: | ||
- args: | ||
- -c | ||
- tail -n+1 -F /var/log/glance/glance-single.log | ||
command: | ||
- /bin/bash | ||
image: quay.io/podified-antelope-centos9/openstack-glance-api:current-podified | ||
name: glance-log | ||
- args: | ||
- -c | ||
- /usr/sbin/httpd -DFOREGROUND | ||
command: | ||
- /bin/bash | ||
image: quay.io/podified-antelope-centos9/openstack-glance-api:current-podified | ||
name: glance-httpd | ||
- args: | ||
- -c | ||
- /usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start | ||
command: | ||
- /bin/bash | ||
image: quay.io/podified-antelope-centos9/openstack-glance-api:current-podified | ||
name: glance-api | ||
serviceAccount: glance-glance | ||
serviceAccountName: glance-glance | ||
status: | ||
availableReplicas: 1 | ||
replicas: 1 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
service: glance-single | ||
status: | ||
phase: Running | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: glance-internal | ||
labels: | ||
endpoint: internal | ||
service: glance-single | ||
spec: | ||
ports: | ||
- name: glance-internal | ||
port: 9292 | ||
protocol: TCP | ||
targetPort: 9292 | ||
selector: | ||
service: glance-single | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: glance-public | ||
labels: | ||
endpoint: public | ||
service: glance-single | ||
spec: | ||
ports: | ||
- name: glance-public | ||
port: 9292 | ||
protocol: TCP | ||
targetPort: 9292 | ||
selector: | ||
service: glance-single | ||
--- | ||
# the actual addresses of the apiEndpoints are platform specific, so we can't rely on | ||
# kuttl asserts to check them. This short script gathers the addresses and checks that | ||
# the three endpoints are defined and their addresses follow the default pattern | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
namespaced: true | ||
commands: | ||
- script: | | ||
template='{{.status.apiEndpoint.internal}}{{":"}}{{.status.apiEndpoint.public}}{{"\n"}}' | ||
regex="http:\/\/glance-internal.$NAMESPACE.*:http:\/\/glance-public.$NAMESPACE.*" | ||
apiEndpoints=$(oc get -n $NAMESPACE Glance glance -o go-template="$template") | ||
matches=$(echo "$apiEndpoints" | sed -e "s?$regex??") | ||
if [ -z "$matches" ]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |
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,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
cp ../../../../config/samples/glance_v1beta1_glance_single.yaml deploy | ||
oc kustomize deploy | oc apply -n $NAMESPACE -f - |
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 @@ | ||
# | ||
# Check for: | ||
# - Glance CR with 2 replicas for each GlanceAPI | ||
# - GlanceAPI glance-external-api Deployment with 2 replicas | ||
# - GlanceAPI glance-internal-api Deployment with 2 replicas | ||
|
||
|
||
apiVersion: glance.openstack.org/v1beta1 | ||
kind: Glance | ||
metadata: | ||
name: glance | ||
spec: | ||
glanceAPI: | ||
replicas: 2 | ||
status: | ||
glanceAPIExternalReadyCount: 2 | ||
#glanceAPIInternalReadyCount: 2 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: glance-single-api | ||
spec: | ||
replicas: 2 | ||
status: | ||
availableReplicas: 2 | ||
replicas: 2 |
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,5 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc patch Glance -n $NAMESPACE glance --type='json' -p='[{"op": "replace", "path": "/spec/glanceAPI/replicas", "value":2}]' |
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,26 @@ | ||
# | ||
# Check for: | ||
# - Glance CR with 1 replicas for each GlanceAPI | ||
# - GlanceAPI glance-single-api Deployment with 1 replicas | ||
|
||
|
||
apiVersion: glance.openstack.org/v1beta1 | ||
kind: Glance | ||
metadata: | ||
name: glance | ||
spec: | ||
glanceAPI: | ||
replicas: 1 | ||
status: | ||
glanceAPIExternalReadyCount: 1 | ||
#glanceAPIInternalReadyCount: 1 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: glance-single-api | ||
spec: | ||
replicas: 1 | ||
status: | ||
availableReplicas: 1 | ||
replicas: 1 |
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,5 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc patch Glance -n $NAMESPACE glance --type='json' -p='[{"op": "replace", "path": "/spec/glanceAPI/replicas", "value":1}]' |
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,21 @@ | ||
# | ||
# Check for: | ||
# - Glance CR with 0 replicas for each GlanceAPI | ||
# - GlanceAPI glance-external-api Deployment with 0 replicas | ||
# - GlanceAPI glance-internal-api Deployment with 0 replicas | ||
|
||
|
||
apiVersion: glance.openstack.org/v1beta1 | ||
kind: Glance | ||
metadata: | ||
name: glance | ||
spec: | ||
glanceAPI: | ||
replicas: 0 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: glance-single-api | ||
spec: | ||
replicas: 0 |
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,5 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
service: glance-single |
5 changes: 5 additions & 0 deletions
5
test/kuttl/tests/glance_single/04-scale-down-zero-glanceapis.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,5 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc patch Glance -n $NAMESPACE glance --type='json' -p='[{"op": "replace", "path": "/spec/glanceAPI/replicas", "value":0}]' |
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,6 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
oc kustomize deploy | oc delete -n $NAMESPACE -f - | ||
rm deploy/glance_v1beta1_glance_single.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,39 @@ | ||
# | ||
# Check for: | ||
# - No Glance CR | ||
# - No GlanceAPI glance-single CR | ||
# - No GlanceAPI glance-single-api Deployment | ||
# - No glance-single-api Pod | ||
# - No glance-public service | ||
# - No glance internal and public endpoints | ||
|
||
apiVersion: glance.openstack.org/v1beta1 | ||
kind: Glance | ||
metadata: | ||
name: glance | ||
--- | ||
apiVersion: glance.openstack.org/v1beta1 | ||
kind: GlanceAPI | ||
metadata: | ||
name: glance-single | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: glance-single-api | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
service: glance-single | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: glance-internal | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: glance-public |
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,11 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- ./glance_v1beta1_glance_single.yaml | ||
patches: | ||
- patch: |- | ||
- op: replace | ||
path: /spec/storageClass | ||
value: local-storage | ||
target: | ||
kind: Glance |