Skip to content

Commit

Permalink
feature. add service validation workflow to e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkfree committed Jun 17, 2022
1 parent c887dd7 commit 4b1f084
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 3 deletions.
35 changes: 32 additions & 3 deletions tests/tks-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ spec:
value: "{{steps.call-create-usercluster.outputs.parameters.cluster-id}}"
- name: service_name
value: "LMA"
# TODO: LMA validation
- - name: call-validate-lma-1st
templateRef:
name: tks-validate-service
template: validate-lma
arguments:
parameters:
- name: cluster_id
value: "{{steps.call-create-usercluster.outputs.parameters.cluster-id}}"
- - name: call-create-service-for-SERVICEMESH-1st
template: create-service
arguments:
Expand All @@ -56,7 +63,14 @@ spec:
value: "{{steps.call-create-usercluster.outputs.parameters.cluster-id}}"
- name: service_name
value: "SERVICE_MESH"
# TODO: SERVICE_MESH validation
- - name: call-validate-servicemesh-1st
templateRef:
name: tks-validate-service
template: validate-servicemesh
arguments:
parameters:
- name: cluster_id
value: "{{steps.call-create-usercluster.outputs.parameters.cluster-id}}"
- - name: call-delete-service-for-SERVICEMESH-1st
template: delete-service
arguments:
Expand Down Expand Up @@ -91,7 +105,14 @@ spec:
value: "{{steps.call-create-usercluster.outputs.parameters.cluster-id}}"
- name: service_name
value: "LMA"
# TODO: LMA validation
- - name: call-validate-lma-2nd
templateRef:
name: tks-validate-service
template: validate-lma
arguments:
parameters:
- name: cluster_id
value: "{{steps.call-create-usercluster.outputs.parameters.cluster-id}}"
- - name: call-create-service-for-SERVICEMESH-2nd
template: create-service
arguments:
Expand All @@ -115,6 +136,14 @@ spec:
value: "SERVICE_MESH"
- name: svc_id
value: "{{steps.call-create-service-for-SERVICEMESH-2nd.outputs.parameters.svc_id}}"
- - name: call-validate-servicemesh-2nd
templateRef:
name: tks-validate-service
template: validate-servicemesh
arguments:
parameters:
- name: cluster_id
value: "{{steps.call-create-usercluster.outputs.parameters.cluster-id}}"
- - name: call-delete-service-for-LMA-2nd
template: delete-service
arguments:
Expand Down
113 changes: 113 additions & 0 deletions tests/validate-service-wftpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: tks-validate-service
namespace: argo
spec:
entrypoint: main
arguments:
parameters:
- name: cluster_id
value: "93460371-6dbe-4a10-a574-97e35c049e10"
templates:
- name: main
steps:
- - name: validate-lma
template: validate-lma
arguments:
parameters:
- name: cluster_id
value: "{{workflow.parameters.cluster_id}}"
- - name: validate-servicemesh
template: validate-servicemesh
arguments:
parameters:
- name: cluster_id
value: "{{workflow.parameters.cluster_id}}"
- name: validate-lma
inputs:
parameters:
- name: cluster_id
container:
name: checker-lma
image: 'sktcloud/sonobuoy-worker'
command:
- /bin/bash
- -c
- |
KUBECONFIG_=$(kubectl get secret -n {{inputs.parameters.cluster_id}} {{inputs.parameters.cluster_id}}-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
cat <<< "$KUBECONFIG_" > /etc/kubeconfig_temp
export KUBECONFIG='/etc/kubeconfig_temp'
# check status of pods
kubectl get ns | grep lma | grep -v NAME
if [[ $? != 0 ]]; then
echo "ERROR - no namespace 'lma'"
exit 1
fi
kubectl get po -n lma | grep -Ev "Running|Completed|NAME"
if [[ $? != 1 ]]; then
echo "ERROR - invalid pod status"
exit 1
fi
# check endpoints
function check_status(){
status=$(kubectl run --quiet -i --tty --rm -n default --image=curlimages/curl --restart=Never curltest-$RANDOM -- -o /dev/null --write-out %{http_code} --silent --max-time 5 $1)
if [[ $status -ne 200 ]]; then
echo "ERROR - STATUS:$status, URL:$1"
exit 1
else
echo "GOOD - STATUS:$status, URL:$1"
fi
}
check_status http://admin:[email protected]/api/search
check_status http://lma-prometheus.lma.svc:9090/api/v1/labels
check_status http://lma-alertmanager.lma.svc:9093/api/v2/status
echo "LMA verification completed."
- name: validate-servicemesh
inputs:
parameters:
- name: cluster_id
container:
name: checker-servicemesh
image: 'sktcloud/sonobuoy-worker'
command:
- /bin/bash
- -c
- |
KUBECONFIG_=$(kubectl get secret -n {{inputs.parameters.cluster_id}} {{inputs.parameters.cluster_id}}-kubeconfig -o jsonpath="{.data.value}" | base64 -d)
cat <<< "$KUBECONFIG_" > /etc/kubeconfig_temp
export KUBECONFIG='/etc/kubeconfig_temp'
# check status of pods
kubectl get ns | grep istio-system | grep -v NAME
if [[ $? != 0 ]]; then
echo "ERROR - no namespace 'istio-system'"
exit 1
fi
kubectl get po -n istio-system | grep -Ev "Running|Completed|NAME"
if [[ $? != 1 ]]; then
echo "ERROR - invalid pod status"
exit 1
fi
# check endpoints
function check_status(){
status=$(kubectl run --quiet -i --tty --rm -n default --image=curlimages/curl --restart=Never curltest-$RANDOM -- -o /dev/null --write-out %{http_code} --silent --max-time 5 $1)
if [[ $status -ne 200 ]]; then
echo "ERROR - STATUS:$status, URL:$1"
exit 1
else
echo "GOOD - STATUS:$status, URL:$1"
fi
}
check_status http://kiali.istio-system.svc:20001/kiali/console/overview
echo "servicemesh verification completed."
File renamed without changes.

0 comments on commit 4b1f084

Please sign in to comment.