Merge "Update KUD to switch to Ubuntu 18.04"
[multicloud/k8s.git] / kud / tests / integration_vFW.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=66fea6f0-b74d-11e8-95a0-525400feed26
19
20 # Setup
21 if [[ ! -f $HOME/.ssh/id_rsa.pub ]]; then
22     echo -e "\n\n\n" | ssh-keygen -t rsa -N ""
23 fi
24 populate_CSAR_vms_vFW $csar_id
25
26 pushd ${CSAR_DIR}/${csar_id}
27 for resource in $unprotected_private_net $protected_private_net $onap_private_net; do
28     kubectl apply -f $resource.yaml
29 done
30 setup $packetgen_deployment_name $firewall_deployment_name $sink_deployment_name
31
32 # Test
33 for deployment_name in $packetgen_deployment_name $firewall_deployment_name $sink_deployment_name; do
34     pod_name=$(kubectl get pods | grep  $deployment_name | awk '{print $1}')
35     vm=$(kubectl virt virsh list | grep ".*$deployment_name"  | awk '{print $2}')
36     echo "Pod name: $pod_name Virsh domain: $vm"
37     echo "ssh -i ~/.ssh/id_rsa.pub admin@$(kubectl get pods $pod_name -o jsonpath="{.status.podIP}")"
38     echo "kubectl attach -it $pod_name"
39     echo "=== Virtlet details ===="
40     echo "$(kubectl virt virsh dumpxml $vm | grep VIRTLET_)\n"
41 done
42 popd
43
44 # Teardown
45 teardown $packetgen_deployment_name $firewall_deployment_name $sink_deployment_name