-
Notifications
You must be signed in to change notification settings - Fork 8
/
ci_test.sh
executable file
·106 lines (82 loc) · 2.41 KB
/
ci_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
# Prep the results.markdown file
echo "Results for "$JOB_NAME > results.markdown
echo "" >> results.markdown
echo 'Module | Instance | Kubernetes' >> results.markdown
echo '-----|-------|------' >> results.markdown
# Clone and prep Stockpile
git clone https://github.com/cloud-bulldozer/stockpile.git
cp stockpile/ci/all.yml stockpile/group_vars/all.yml
cp stockpile/ci/kubernetes.yml stockpile/group_vars/kubernetes.yml
sed -i 's/\/tmp\/stockpile.json/\/tmp\/stockpile_scribe.json/' stockpile/group_vars/all.yml
sed -i 's/\/tmp\/container/\/tmp\/scribe_container/' stockpile/group_vars/kubernetes.yml
cd stockpile
echo "Running Stockpile"
ansible-playbook -i ci/hosts stockpile.yml -e kube_config=/root/.kube/config
cd ..
module_list=`ls transcribe/scribe_modules/*.py | grep -v __ | grep -v base_scribe_module | sed 's/.py//' | awk -F "/" '{print $3}'`
echo "Scribe module list: "$module_list
# Create python3 virt env for the test
python3 -m venv ci_test
source ci_test/bin/activate
# Install scribe into the venv
pip3 install -e .
rc=0
# Test against the local (instance) data
python3 -m scribe -t stockpile -ip /tmp/stockpile_scribe.json > scribe_out
scribe_rc=$?
if [[ $scribe_rc -eq 1 ]]
then
echo "Scribe failed to run checking instance output. Exiting"
exit 1
fi
# Test against against the backpack created data
for cont_file in `ls /tmp/scribe_container/backpack*`
do
echo $cont_file
python3 -m scribe -t stockpile -ip $cont_file > scribe_cont_out
scribe_cont_rc=$?
if [[ $scribe_cont_rc -eq 1 ]]
then
echo "Scribe failed to run checking container output. Exiting"
exit 1
fi
done
echo "Full scribe instance output:"
cat scribe_out
echo ""
echo ""
echo ""
echo "Full scribe container output:"
cat scribe_cont_out
echo ""
echo ""
echo "Scribe Module Results:"
for module in $module_list
do
grep $module" is not part" scribe_out
my_inst_rc=$?
grep $module" is not part" scribe_cont_out
my_cont_rc=$?
if [ $my_inst_rc -eq 1 ]
then
echo -n $module": Passed Instance"
echo -n $module"|Pass" >> results.markdown
else
echo -n $module": Failed Instance"
echo -n $module"|Fail" >> results.markdown
rc=1
fi
if [ $my_cont_rc -eq 1 ]
then
echo " | Passed Kubernetes"
echo "|Pass" >> results.markdown
else
echo " | Failed Kubernetes"
echo "|Fail" >> results.markdown
rc=1
fi
done
deactivate
rm -rf stockpile ci_test /tmp/scribe_container
exit $rc