forked from kubevirt/common-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
157 lines (122 loc) · 4.93 KB
/
makefile
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
SHELL=/bin/bash
# i.e. fedora28.yaml
ALL_META_TEMPLATES=$(wildcard templates/*.yaml)
ALL_TEMPLATES=$(wildcard dist/templates/*.yaml)
ALL_PRESETS=$(wildcard presets/*.yaml)
METASOURCES=$(ALL_META_TEMPLATES) $(ALL_PRESETS)
# i.e. fedora28
ALL_GUESTS=$(ALL_TEMPLATES:dist/templates/%.yaml=%)
# Make sure the version is defined
export VERSION=$(shell ./version.sh)
export REVISION=$(shell ./revision.sh)
TEST_SYNTAX=$(ALL_GUESTS)
TEST_UNIT=$(ALL_GUESTS)
ifeq ($(TEST_FUNCTIONAL),ALL)
TEST_FUNCTIONAL=fedora-desktop-small ubuntu-desktop-small rhel7-server-small centos7-server-small
endif
test: syntax-tests unit-tests functional-tests
syntax-tests: generate $(TEST_SYNTAX:%=%-syntax-check)
unit-tests: generate is-deployed
unit-tests: $(TEST_UNIT:%=%-apply-and-remove)
unit-tests: $(TEST_UNIT:%=%-generated-name-apply-and-remove)
functional-tests: generate is-deployed
functional-tests: $(TEST_FUNCTIONAL:%=%-start-wait-for-systemd-and-stop)
dist/templates/%.yaml: generate
dist/common-templates.yaml: generate
( \
echo -n "# Version " ; \
git describe --always --tags HEAD ; \
for F in $(ALL_PRESETS) dist/templates/*.yaml; \
do \
echo "---" ; \
echo "# Source: $$F" ; \
cat $$F ; \
done ; \
) >$@
release: dist/common-templates.yaml
cp dist/common-templates.yaml dist/common-templates-$(VERSION).yaml
TRAVIS_FOLD_START=echo -e "travis_fold:start:details\033[33;1mDetails\033[0m"
TRAVIS_FOLD_END=echo -e "\ntravis_fold:end:details\r"
gather-env-of-%:
kubectl describe vm $*
kubectl describe vmi $*
kubectl describe pods
kubectl -n kubevirt logs -l kubevirt.io=virt-handler --tail=20
is-deployed:
kubectl api-versions | grep kubevirt.io
generate: generate-templates.yaml $(METASOURCES)
# Just build the XML files, no need to export to tarball
make -C osinfo-db/ OSINFO_DB_EXPORT=echo
ansible-playbook generate-templates.yaml
bash automation/x-limit-ram-size.sh
%-syntax-check: dist/templates/%.yaml
oc process --local -f "dist/templates/$*.yaml" NAME=$@ PVCNAME=$*-pvc
%-apply-and-remove: dist/templates/%.yaml
oc process --local -f "dist/templates/$*.yaml" NAME=$@ PVCNAME=$*-pvc | \
kubectl apply -f -
oc process --local -f "dist/templates/$*.yaml" NAME=$@ PVCNAME=$*-pvc | \
kubectl delete -f -
%-generated-name-apply-and-remove:
oc process --local -f "dist/templates/$*.yaml" PVCNAME=$*-pvc > $@.yaml
kubectl apply -f $@.yaml
kubectl delete -f $@.yaml
rm -v $@.yaml
%-start-wait-for-systemd-and-stop: %.pvc
oc process --local -f "dist/templates/$*.yaml" NAME=$* PVCNAME=$* | \
kubectl apply -f -
virtctl start $*
$(TRAVIS_FOLD_START)
while ! kubectl get vmi $* -o yaml | grep "phase: Running" ; do make gather-env-of-$* ; sleep 15; done
make gather-env-of-$*
$(TRAVIS_FOLD_END)
# Wait for a pretty universal magic word
virtctl console --timeout=5 $* | tee /dev/stderr | egrep -m 1 "Welcome|systemd"
oc process --local -f "dist/templates/$*.yaml" NAME=$* PVCNAME=$* | \
kubectl delete -f -
# Wait for successful vmi deletion
while kubectl get vmi $* 2> >(grep "not found") ; do sleep 15; done
pvs: $(TESTABLE_GUESTS:%=%.pv)
raws: $(TESTABLE_GUESTS:%=%.raw)
%.pvc: %.pv
kubectl get pvc $*
# fedora-desktop-small.pv will use fedora.raw
.SECONDEXPANSION:
%.pv: $$(firstword $$(subst -, ,$$@)).raw
$(TRAVIS_FOLD_START)
SIZEMB=$$(( $$(qemu-img info $< --output json | jq '.["virtual-size"]') / 1024 / 1024 + 128 )) && \
mkdir -p "$$PWD/pvs/$*" && \
cp $< $$PWD/pvs/$*/disk.img && \
sudo chown 107:107 $$PWD/pvs/$*/disk.img && \
sudo chmod -R a+X $$PWD/pvs && \
bash create-minikube-pvc.sh "$*" "$${SIZEMB}M" "$$PWD/pvs/$*/" | tee | kubectl apply -f -
find $$PWD/pvs
kubectl get -o yaml pv $*
$(TRAVIS_FOLD_END)
%.raw: %.qcow2
qemu-img convert -p -O raw $< $@
fedora.qcow2:
curl -L -o $@ https://download.fedoraproject.org/pub/fedora/linux/releases/28/Cloud/x86_64/images/Fedora-Cloud-Base-28-1.1.x86_64.qcow2
ubuntu.qcow2:
curl -L -o $@ http://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
opensuse.qcow2:
curl -L -o $@ https://download.opensuse.org/repositories/Cloud:/Images:/Leap_15.0/images/openSUSE-Leap-15.0-OpenStack.x86_64-0.0.4-Buildlp150.12.12.qcow2
centos7.qcow2:
curl -L http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2.xz | xz -d > $@
# For now we test the RHEL75 template with the CentOS image
rhel7.raw: centos7.raw
ln $< $@
centos6.qcow2:
curl -L http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud.qcow2.xz | xz -d > $@
# For now we test the RHEL6 template with the CentOS image
rhel6.raw: centos6.raw
ln $< $@
# For now we test the RHEL8 template with the CentOS image
rhel8.raw: centos8.raw
ln $< $@
centos8.qcow2:
# For now we test the CentOS 8 image using Fedora as that is the branch source
# TODO fix this once CentOS 8 is released
curl -L -o $@ https://download.fedoraproject.org/pub/fedora/linux/releases/28/Cloud/x86_64/images/Fedora-Cloud-Base-28-1.1.x86_64.qcow2
clean:
rm -v *.raw *.qcow2
.PHONY: all test generate release