Merge "Update ResourceBundleState CRD and monitor-deploy"
[multicloud/k8s.git] / kud / tests / virtlet.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 set -o errexit
12 set -o nounset
13 set -o pipefail
14
15 source _common.sh
16 source _functions.sh
17
18 csar_id=6b54a728-b76a-11e8-a1ba-52540053ccc8
19
20 # Setup
21 populate_CSAR_virtlet $csar_id
22
23 pushd ${CSAR_DIR}/${csar_id}
24
25 setup $virtlet_deployment_name
26
27 # Test
28 deployment_pod=$(kubectl get pods | grep $virtlet_deployment_name | awk '{print $1}')
29 vm_name=$(kubectl virt virsh list | grep "virtlet-.*-$virtlet_deployment_name" | awk '{print $2}')
30 vm_status=$(kubectl virt virsh list | grep "virtlet-.*-$virtlet_deployment_name" | awk '{print $3}')
31 if [[ "$vm_status" != "running" ]]; then
32     echo "There is no Virtual Machine running by $deployment_pod pod"
33     exit 1
34 fi
35 echo "Pod name: $deployment_pod Virsh domain: $vm_name"
36 echo "ssh testuser@$(kubectl get pods $deployment_pod -o jsonpath="{.status.podIP}")"
37 echo "kubectl attach -it $deployment_pod"
38 echo "=== Virtlet details ===="
39 echo "$(kubectl virt virsh dumpxml $vm_name | grep VIRTLET_)\n"
40 popd
41
42 # Teardown
43 teardown $virtlet_deployment_name