-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
273 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
|
||
galera="$1" | ||
dbname="$2" | ||
username="$3" | ||
password="$4" | ||
|
||
|
||
found=0 | ||
not_found=1 | ||
|
||
if [ "$5" = "--reverse" ];then | ||
# sometimes we want to check that a user does not exist | ||
found=1 | ||
not_found=0 | ||
fi | ||
|
||
found_username=$(oc rsh -n ${NAMESPACE} -c galera ${galera} /bin/sh -c 'mysql -uroot -p${DB_ROOT_PASSWORD} -Nse "select user from mysql.user"' | grep -o -w ${username}) | ||
|
||
# username was not found, exit | ||
if [ -z "$found_username" ]; then | ||
exit $not_found | ||
fi | ||
|
||
# username was found. if we wanted it to be found, then check the login also. | ||
if [ "$found" = "0" ]; then | ||
oc rsh -n ${NAMESPACE} -c galera ${galera} /bin/sh -c "mysql -u${username} -p${password} -Nse 'select database();' ${dbname}" || exit -1 | ||
fi | ||
|
||
exit $found |
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,114 @@ | ||
# | ||
# Check for: | ||
# | ||
# - 1 MariaDB CR | ||
# - 1 Pod for MariaDB CR | ||
# | ||
|
||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: Galera | ||
metadata: | ||
name: openstack | ||
spec: | ||
replicas: 1 | ||
secret: osp-secret | ||
storageRequest: 500M | ||
status: | ||
bootstrapped: true | ||
conditions: | ||
- message: Setup complete | ||
reason: Ready | ||
status: "True" | ||
type: Ready | ||
- message: Deployment completed | ||
reason: Ready | ||
status: "True" | ||
type: DeploymentReady | ||
- message: Exposing service completed | ||
reason: Ready | ||
status: "True" | ||
type: ExposeServiceReady | ||
- message: RoleBinding created | ||
reason: Ready | ||
status: "True" | ||
type: RoleBindingReady | ||
- message: Role created | ||
reason: Ready | ||
status: "True" | ||
type: RoleReady | ||
- message: ServiceAccount created | ||
reason: Ready | ||
status: "True" | ||
type: ServiceAccountReady | ||
- message: Service config create completed | ||
reason: Ready | ||
status: "True" | ||
type: ServiceConfigReady | ||
--- | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: openstack-galera | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: galera | ||
cr: galera-openstack | ||
galera/name: openstack | ||
serviceName: openstack-galera | ||
template: | ||
metadata: | ||
labels: | ||
app: galera | ||
cr: galera-openstack | ||
galera/name: openstack | ||
spec: | ||
containers: | ||
- command: | ||
- /usr/bin/dumb-init | ||
- -- | ||
- /usr/local/bin/kolla_start | ||
name: galera | ||
ports: | ||
- containerPort: 3306 | ||
name: mysql | ||
protocol: TCP | ||
- containerPort: 4567 | ||
name: galera | ||
protocol: TCP | ||
serviceAccount: galera-openstack | ||
serviceAccountName: galera-openstack | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: openstack-galera-0 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: openstack-galera | ||
spec: | ||
ports: | ||
- name: mysql | ||
port: 3306 | ||
protocol: TCP | ||
targetPort: 3306 | ||
selector: | ||
app: galera | ||
cr: galera-openstack | ||
--- | ||
apiVersion: v1 | ||
kind: Endpoints | ||
metadata: | ||
name: openstack-galera | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: openstack-config-data |
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,9 @@ | ||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: Galera | ||
metadata: | ||
name: openstack | ||
spec: | ||
secret: osp-secret | ||
storageClass: local-storage | ||
storageRequest: 500M | ||
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,7 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: kuttldb-accounttest-db-create | ||
status: | ||
succeeded: 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,9 @@ | ||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBDatabase | ||
metadata: | ||
name: kuttldb-accounttest | ||
labels: | ||
dbName: openstack | ||
spec: | ||
secret: osp-secret | ||
name: kuttldb_accounttest |
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: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBAccount | ||
metadata: | ||
labels: | ||
mariaDBDatabaseName: kuttldb-accounttest | ||
name: kuttldb-some-db-account | ||
status: | ||
conditions: | ||
- message: 'MariaDBAccount secret is missing or incomplete: Secret openstack/some-db-secret not found' | ||
reason: SecretMissing | ||
severity: Info | ||
status: "False" | ||
type: Ready | ||
- message: 'MariaDBAccount secret is missing or incomplete: Secret openstack/some-db-secret not found' | ||
reason: SecretMissing | ||
severity: Info | ||
status: "False" | ||
type: MariaDBAccountReady | ||
- message: MariaDBDatabase ready | ||
reason: Ready | ||
status: "True" | ||
type: MariaDBDatabaseReady | ||
- message: MariaDB / Galera server ready | ||
reason: Ready | ||
status: "True" | ||
type: MariaDBServerReady |
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,9 @@ | ||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBAccount | ||
metadata: | ||
labels: | ||
mariaDBDatabaseName: kuttldb-accounttest | ||
name: kuttldb-some-db-account | ||
spec: | ||
userName: someuser | ||
secret: some-db-secret |
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,25 @@ | ||
--- | ||
apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBAccount | ||
metadata: | ||
labels: | ||
mariaDBDatabaseName: kuttldb-accounttest | ||
name: kuttldb-some-db-account | ||
status: | ||
conditions: | ||
- message: Setup complete | ||
reason: Ready | ||
status: "True" | ||
type: Ready | ||
- message: MariaDBAccount creation complete | ||
reason: Ready | ||
status: "True" | ||
type: MariaDBAccountReady | ||
- message: MariaDBDatabase ready | ||
reason: Ready | ||
status: "True" | ||
type: MariaDBDatabaseReady | ||
- message: MariaDB / Galera server ready | ||
reason: Ready | ||
status: "True" | ||
type: MariaDBServerReady |
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: v1 | ||
data: | ||
DatabasePassword: ZGJzZWNyZXQx | ||
kind: Secret | ||
metadata: | ||
name: some-db-secret | ||
type: Opaque |
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: TestAssert | ||
commands: | ||
- script: | | ||
${MARIADB_KUTTL_DIR:-tests/kuttl/tests}/../common/scripts/check_db_account.sh openstack-galera-0 kuttldb_accounttest someuser dbsecret1 |
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 delete -n $NAMESPACE mariadbaccounts/kuttldb-some-db-account |
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: TestAssert | ||
commands: | ||
- script: | | ||
${MARIADB_KUTTL_DIR:-tests/kuttl/tests}/../common/scripts/check_db_account.sh openstack-galera-0 kuttldb_accounttest someuser dbsecret1 --reverse |
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,17 @@ | ||
apiVersion: kuttl.dev/v1beta | ||
kind: TestStep | ||
delete: | ||
- apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: Galera | ||
name: openstack | ||
- apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBDatabase | ||
- apiVersion: mariadb.openstack.org/v1beta1 | ||
kind: MariaDBAccount | ||
- apiVersion: v1 | ||
kind: Secret | ||
name: some-db-secret | ||
commands: | ||
- script: | | ||
oc delete -n $NAMESPACE pvc mysql-db-openstack-galera-0 | ||
for i in `oc get pv | awk '/'$NAMESPACE'\/mysql-db-openstack-galera/ {print $1}'`; do oc patch pv $i -p '{"spec":{"claimRef": null}}'; done |