Merge pull request 'test-staging' (#8) from test-staging into master
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #8
This commit is contained in:
commit
9d05055acb
3 changed files with 50 additions and 55 deletions
62
.drone.yml
62
.drone.yml
|
@ -58,11 +58,26 @@ depends_on:
|
|||
- unit tests
|
||||
|
||||
---
|
||||
deploy_commands_alias:
|
||||
- &deploy_commands
|
||||
commands:
|
||||
- echo "== pre deploy ($${LEVEL}) status:"
|
||||
- kubectl get pods --namespace=beer
|
||||
- kubectl get deployments --namespace=beer
|
||||
- sed "s/__LEVEL__/$${LEVEL}/g" kube/beer-deployment.yaml > kube/beer-deployment-$${LEVEL}.yaml
|
||||
- sed "s/__NAMESPACE__/$${NAMESPACE}/g" kube/beer-deployment-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml
|
||||
- sed "s/__IMAGE_TAG__/$${IMAGE_TAG}/g" kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml
|
||||
- echo "applying"
|
||||
- kubectl apply -f kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml --namespace=beer
|
||||
- echo "== post deploy ($${LEVEL}) status:"
|
||||
- kubectl get deployments --namespace=beer
|
||||
- kubectl get pods --namespace=beer
|
||||
|
||||
kind: pipeline
|
||||
name: staging
|
||||
name: deploy
|
||||
|
||||
steps:
|
||||
- name: deploy
|
||||
- name: deploy staging
|
||||
image: sinlead/drone-kubectl
|
||||
settings:
|
||||
kubernetes_server:
|
||||
|
@ -75,32 +90,20 @@ steps:
|
|||
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
|
||||
NAMESPACE: beer
|
||||
LEVEL: staging
|
||||
commands:
|
||||
- echo "== pre deploy ($${LEVEL}) status:"
|
||||
- kubectl get pods --namespace=beer
|
||||
- kubectl get deployments --namespace=beer
|
||||
- sed "s/__LEVEL__/$${LEVEL}/g" kube/beer-deployment.yaml > kube/beer-deployment-$${LEVEL}.yaml
|
||||
- sed "s/__NAMESPACE__/$${NAMESPACE}/g" kube/beer-deployment-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml
|
||||
- sed "s/__IMAGE_TAG__/$${IMAGE_TAG}/g" kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml
|
||||
- echo "applying"
|
||||
- kubectl apply -f kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml --namespace=beer
|
||||
- echo "== post deploy ($${LEVEL}) status:"
|
||||
- kubectl get deployments --namespace=beer
|
||||
- kubectl get pods --namespace=beer
|
||||
<<: *deploy_commands
|
||||
when:
|
||||
branch:
|
||||
exclude:
|
||||
- master
|
||||
|
||||
depends_on:
|
||||
- build
|
||||
- name: test staging
|
||||
image: ellerbrock/alpine-bash-curl-ssl
|
||||
environment:
|
||||
BRANCH: ${DRONE_COMMIT_BRANCH}
|
||||
commands:
|
||||
- bash staging_tests.sh
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: deploy
|
||||
|
||||
steps:
|
||||
- name: deploy
|
||||
- name: deploy live
|
||||
image: sinlead/drone-kubectl
|
||||
settings:
|
||||
kubernetes_server:
|
||||
|
@ -112,19 +115,8 @@ steps:
|
|||
environment:
|
||||
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
|
||||
NAMESPACE: beer
|
||||
LEVEL: prod
|
||||
commands:
|
||||
- echo "== pre deploy ($${LEVEL}) status:"
|
||||
- kubectl get pods --namespace=beer
|
||||
- kubectl get deployments --namespace=beer
|
||||
- sed "s/__LEVEL__/$${LEVEL}/g" kube/beer-deployment.yaml > kube/beer-deployment-$${LEVEL}.yaml
|
||||
- sed "s/__NAMESPACE__/$${NAMESPACE}/g" kube/beer-deployment-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml
|
||||
- sed "s/__IMAGE_TAG__/$${IMAGE_TAG}/g" kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml
|
||||
- echo "applying"
|
||||
- kubectl apply -f kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml --namespace=beer
|
||||
- echo "== post deploy ($${LEVEL}) status:"
|
||||
- kubectl get deployments --namespace=beer
|
||||
- kubectl get pods --namespace=beer
|
||||
LEVEL: live
|
||||
<<: *deploy_commands
|
||||
when:
|
||||
branch:
|
||||
include:
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority-data: ${KUBE_CA}
|
||||
server: ${KUBE_URI}
|
||||
name: default
|
||||
contexts:
|
||||
- context:
|
||||
cluster: default
|
||||
user: default
|
||||
name: default
|
||||
current-context: default
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: default
|
||||
user:
|
||||
password: ${KUBE_PASSWORD}
|
||||
username: ${KUBE_USERNAME}
|
23
staging_tests.sh
Normal file
23
staging_tests.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
if [ ${BRANCH} == 'master' ]; then
|
||||
TEST_URL='http://beer.k3s.kleph.eu'
|
||||
else
|
||||
TEST_URL='http://staging.beer.k3s.kleph.eu'
|
||||
fi
|
||||
echo "testing URL: ${TEST_URL}"
|
||||
CURL_OPTS='-s'
|
||||
# default
|
||||
curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 0);'
|
||||
[ $? -ne 0 ] && exit 1
|
||||
|
||||
# set 1 parameter
|
||||
hours=18
|
||||
curl ${CURL_OPTS} ${TEST_URL}/${hours} | grep -q "setHours( ${hours}, 0);"
|
||||
[ $? -ne 0 ] && exit 1
|
||||
|
||||
# set 2 parameters
|
||||
minutes=30
|
||||
curl ${CURL_OPTS} ${TEST_URL}/${hours}/${minutes} | grep -q "setHours( ${hours}, ${minutes});"
|
||||
[ $? -ne 0 ] && exit 1
|
||||
|
||||
echo "OK"
|
||||
exit 0
|
Loading…
Reference in a new issue