tests - support custom cleanup-kubernetes.sh script and refactor some k8s tests with helm charts
This commit is contained in:
parent
cc9d228abd
commit
4e7d795ea6
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm delete drupal
|
|
@ -0,0 +1,3 @@
|
|||
drupalUsername: "user"
|
||||
drupalPassword: "changeme42"
|
||||
drupalEmail: "contact@example.com"
|
|
@ -15,96 +15,6 @@ spec:
|
|||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: svc-drupal
|
||||
name: drupal
|
||||
port:
|
||||
number: 80
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: cfg-bunkerweb-drupal-modsec-crs
|
||||
annotations:
|
||||
bunkerweb.io/CONFIG_TYPE: "modsec-crs"
|
||||
bunkerweb.io/CONFIG_SITE: "www.example.com"
|
||||
data:
|
||||
drupal: |
|
||||
SecAction \
|
||||
"id:900130,\
|
||||
phase:1,\
|
||||
nolog,\
|
||||
pass,\
|
||||
t:none,\
|
||||
setvar:tx.crs_exclusions_drupal=1"
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: drupal
|
||||
labels:
|
||||
app: drupal
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: drupal
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: drupal
|
||||
spec:
|
||||
containers:
|
||||
- name: drupal
|
||||
image: drupal:9-apache
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: svc-drupal
|
||||
spec:
|
||||
selector:
|
||||
app: drupal
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: db
|
||||
labels:
|
||||
app: db
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: db
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: db
|
||||
spec:
|
||||
containers:
|
||||
- name: db
|
||||
image: mariadb
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
value: db-root-pwd
|
||||
- name: MYSQL_DATABASE
|
||||
value: drupaldb
|
||||
- name: MYSQL_USER
|
||||
value: user
|
||||
- name: MYSQL_PASSWORD
|
||||
value: db-user-pwd
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: svc-db
|
||||
spec:
|
||||
selector:
|
||||
app: db
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
number: 80
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm install -f drupal-chart-values.yml drupal bitnami/drupal
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm delete ghost
|
|
@ -0,0 +1,4 @@
|
|||
ghostUsername: "user"
|
||||
ghostPassword: "changeme42"
|
||||
ghostHost: "www.example.com"
|
||||
ghostEnableHttps: true
|
|
@ -4,7 +4,6 @@ metadata:
|
|||
name: ingress
|
||||
annotations:
|
||||
bunkerweb.io/AUTO_LETS_ENCRYPT: "yes"
|
||||
bunkerweb.io/USE_GZIP: "yes"
|
||||
spec:
|
||||
rules:
|
||||
- host: www.example.com
|
||||
|
@ -14,41 +13,6 @@ spec:
|
|||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: svc-ghost
|
||||
name: ghost
|
||||
port:
|
||||
number: 2368
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ghost
|
||||
labels:
|
||||
app: ghost
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ghost
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ghost
|
||||
spec:
|
||||
containers:
|
||||
- name: ghost
|
||||
image: ghost:alpine
|
||||
env:
|
||||
- name: URL
|
||||
value: "https://www.example.com"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: svc-ghost
|
||||
spec:
|
||||
selector:
|
||||
app: ghost
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 2368
|
||||
targetPort: 2368
|
||||
number: 80
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm install -f ghost-chart-values.yml ghost bitnami/ghost
|
|
@ -30,6 +30,9 @@ networks:
|
|||
external:
|
||||
name: bw-services
|
||||
|
||||
volumes:
|
||||
gogs_data:
|
||||
|
||||
configs:
|
||||
config_gogs_app:
|
||||
file: ./gogs-data/gogs/conf/app.ini
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm delete joomla
|
|
@ -0,0 +1,3 @@
|
|||
joomlaUsername: "user"
|
||||
joomlaPassword: "changeme42"
|
||||
joomlaEmail: "contact@example.com"
|
|
@ -17,88 +17,6 @@ spec:
|
|||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: svc-joomla
|
||||
name: joomla
|
||||
port:
|
||||
number: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: joomla
|
||||
labels:
|
||||
app: joomla
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: joomla
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: joomla
|
||||
spec:
|
||||
containers:
|
||||
- name: joomla
|
||||
image: joomla:4-apache
|
||||
env:
|
||||
- name: JOOMLA_DB_HOST
|
||||
value: "svc-db"
|
||||
- name: JOOMLA_DB_NAME
|
||||
value: "joomla_db"
|
||||
- name: JOOMLA_DB_USER
|
||||
value: "user"
|
||||
- name: JOOMLA_DB_PASSWORD
|
||||
value: "db-user-pwd"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: svc-joomla
|
||||
spec:
|
||||
selector:
|
||||
app: svc-joomla
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: db
|
||||
labels:
|
||||
app: db
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: db
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: db
|
||||
spec:
|
||||
containers:
|
||||
- name: db
|
||||
image: mariadb
|
||||
env:
|
||||
- name: MYSQL_ROOT_PASSWORD
|
||||
value: "db-root-password"
|
||||
- name: MYSQL_DATABASE
|
||||
value: "joomla_db"
|
||||
- name: MYSQL_USER
|
||||
value: "user"
|
||||
- name: MYSQL_PASSWORD
|
||||
value: "db-user-pwd"
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: svc-db
|
||||
spec:
|
||||
selector:
|
||||
app: db
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 3306
|
||||
targetPort: 3306
|
||||
number: 80
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm install -f joomla-chart-values.yml joomla bitnami/joomla
|
|
@ -0,0 +1,59 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
|
||||
mymagento:
|
||||
image: bitnami/magento:2
|
||||
networks:
|
||||
bw-services:
|
||||
aliases:
|
||||
- mymagento
|
||||
volumes:
|
||||
- ./magento-data:/bitnami/magento
|
||||
environment:
|
||||
- MAGENTO_USERNAME=admin # replace with admin username
|
||||
- MAGENTO_PASSWORD=changeme42 # replace with a stronger password
|
||||
- MAGENTO_EMAIL=contact@example.com # replace with admin email
|
||||
- MAGENTO_HOST=www.example.com # replace with your domain
|
||||
- MAGENTO_ENABLE_HTTPS=yes
|
||||
- MAGENTO_ENABLE_ADMIN_HTTPS=yes
|
||||
- MAGENTO_DATABASE_HOST=mydb
|
||||
- MAGENTO_DATABASE_NAME=magentodb
|
||||
- MAGENTO_DATABASE_USER=user
|
||||
- MAGENTO_DATABASE_PASSWORD=db-user-pwd # replace with a stronger password (must match MYSQL_PASSWORD)
|
||||
- ELASTICSEARCH_HOST=myelasticsearch
|
||||
labels:
|
||||
- SERVER_NAME=www.example.com
|
||||
- USE_REVERSE_PROXY=yes
|
||||
- REVERSE_PROXY_URL=/
|
||||
- REVERSE_PROXY_HOST=http://mymagento:8080
|
||||
|
||||
myelasticsearch:
|
||||
image: bitnami/elasticsearch:7
|
||||
networks:
|
||||
bw-services:
|
||||
aliases:
|
||||
- myelasticsearch
|
||||
# ⚠️ you need to create the directory and fix permissions ⚠️
|
||||
# see setup-autoconf.sh
|
||||
volumes:
|
||||
- ./elasticsearch-data:/bitnami/elasticsearch/data
|
||||
|
||||
mydb:
|
||||
image: mariadb:10.2
|
||||
networks:
|
||||
bw-services:
|
||||
aliases:
|
||||
- mydb
|
||||
volumes:
|
||||
- ./db-data:/var/lib/mysql
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=db-root-pwd # replace with a stronger password
|
||||
- MYSQL_DATABASE=magentodb
|
||||
- MYSQL_USER=user
|
||||
- MYSQL_PASSWORD=db-user-pwd # replace with a stronger password (must match MAGENTO_DATABASE_PASSWORD)
|
||||
|
||||
networks:
|
||||
bw-services:
|
||||
external:
|
||||
name: bw-services
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm delete magento
|
|
@ -46,7 +46,7 @@ services:
|
|||
myelasticsearch:
|
||||
image: bitnami/elasticsearch:7
|
||||
# ⚠️ you need to create the directory and fix permissions ⚠️
|
||||
# see setup.sh
|
||||
# see setup-docker.sh
|
||||
volumes:
|
||||
- ./elasticsearch-data:/bitnami/elasticsearch/data
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: ingress
|
||||
annotations:
|
||||
bunkerweb.io/AUTO_LETS_ENCRYPT: "yes"
|
||||
spec:
|
||||
rules:
|
||||
- host: www.example.com
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: magento
|
||||
port:
|
||||
number: 8080
|
|
@ -0,0 +1,7 @@
|
|||
magentoHost: "https://www.example.com"
|
||||
magentoUsername: "user"
|
||||
magentoPassword: "changeme42"
|
||||
magentoEmail: "contact@example.com"
|
||||
magentoFirstName: "John"
|
||||
magentoLastName: "Doe"
|
||||
magentoAdminUri: "/admin"
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm install -f magento-chart-values.yml magento bitnami/magento
|
|
@ -0,0 +1,69 @@
|
|||
version: '3'
|
||||
|
||||
services:
|
||||
|
||||
mymagento:
|
||||
image: bitnami/magento:2
|
||||
networks:
|
||||
- bw-services
|
||||
volumes:
|
||||
- magento_data:/bitnami/magento
|
||||
environment:
|
||||
- MAGENTO_USERNAME=admin # replace with admin username
|
||||
- MAGENTO_PASSWORD=changeme42 # replace with a stronger password
|
||||
- MAGENTO_EMAIL=contact@example.com # replace with admin email
|
||||
- MAGENTO_HOST=www.example.com # replace with your domain
|
||||
- MAGENTO_ENABLE_HTTPS=yes
|
||||
- MAGENTO_ENABLE_ADMIN_HTTPS=yes
|
||||
- MAGENTO_DATABASE_HOST=mydb
|
||||
- MAGENTO_DATABASE_NAME=magentodb
|
||||
- MAGENTO_DATABASE_USER=user
|
||||
- MAGENTO_DATABASE_PASSWORD=db-user-pwd # replace with a stronger password (must match MYSQL_PASSWORD)
|
||||
- ELASTICSEARCH_HOST=myelasticsearch
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- "node.role==worker"
|
||||
labels:
|
||||
- SERVER_NAME=www.example.com
|
||||
- USE_REVERSE_PROXY=yes
|
||||
- REVERSE_PROXY_URL=/
|
||||
- REVERSE_PROXY_HOST=http://mymagento:8080
|
||||
|
||||
myelasticsearch:
|
||||
image: bitnami/elasticsearch:7
|
||||
networks:
|
||||
- bw-services
|
||||
volumes:
|
||||
- elasticsearch_data:/bitnami/elasticsearch/data
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- "node.role==worker"
|
||||
|
||||
mydb:
|
||||
image: mariadb:10.2
|
||||
networks:
|
||||
- bw-services
|
||||
volumes:
|
||||
- db_data:/var/lib/mysql
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=db-root-pwd # replace with a stronger password
|
||||
- MYSQL_DATABASE=magentodb
|
||||
- MYSQL_USER=user
|
||||
- MYSQL_PASSWORD=db-user-pwd # replace with a stronger password (must match MAGENTO_DATABASE_PASSWORD)
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- "node.role==worker"
|
||||
|
||||
networks:
|
||||
bw-services:
|
||||
external:
|
||||
name: bw-services
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
elasticsearch_data:
|
||||
magento_data:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "load-balancer",
|
||||
"kinds": [
|
||||
"docker",
|
||||
"autoconf",
|
||||
"swarm",
|
||||
"kubernetes"
|
||||
],
|
||||
"timeout": 180,
|
||||
"tests": [
|
||||
{
|
||||
"type": "string",
|
||||
"url": "https://www.example.com",
|
||||
"string": "hello"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -109,7 +109,13 @@ class KubernetesTest(Test) :
|
|||
|
||||
def _cleanup_test(self) :
|
||||
try :
|
||||
proc = run("sudo kubectl delete -f kubernetes.yml", shell=True, cwd="/tmp/tests/" + self._name)
|
||||
test = "/tmp/tests/" + self._name
|
||||
cleanup = test + "/cleanup-kubernetes.sh"
|
||||
if isfile(cleanup) :
|
||||
proc = run("sudo ./cleanup-kubernetes.sh", cwd=test, shell=True)
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("cleanup-kubernetes failed"))
|
||||
proc = run("sudo kubectl delete -f kubernetes.yml", shell=True, cwd=test)
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("kubectl delete failed"))
|
||||
super()._cleanup_test()
|
||||
|
|
Loading…
Reference in New Issue