blob: 1134fc077734c4419b775b7eae8a16393b274df9 [file] [log] [blame]
Andy Bavier35053b62018-09-20 13:45:45 -07001SHELL := /bin/bash
2BUILD ?= /tmp
3M ?= $(BUILD)/milestones
4MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
5WORKSPACE ?= $(HOME)
Andy Bavier6ce277e2018-10-02 10:29:21 -07006VIRTUALENV ?= $(WORKSPACE)/cord/test
Andy Bavier35053b62018-09-20 13:45:45 -07007SEBAVALUES ?= configs/seba-ponsim.yaml
Kailash Khalasi98dabd02018-10-19 13:00:12 -07008TESTTAGS ?= stable
Andy Bavier35053b62018-09-20 13:45:45 -07009
Zack Williams3bcdc262018-09-27 11:00:38 -070010# used to start logging/monitoring and other infrastructure charts
11INFRA_CHARTS ?=
12INFRA_PREREQS = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart))
13
Andy Bavier35053b62018-09-20 13:45:45 -070014HELM_VERSION ?= "2.10.0"
15HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe"
16HELM_PLATFORM ?= "linux-amd64"
17
Zack Williams3bcdc262018-09-27 11:00:38 -070018KAFKA_CHART_VERSION ?= 0.8.8
19
Zack Williamsd0c12f02018-11-21 11:54:36 -070020# Targets
21ponsim: $(M)/siab
22
23bbsim: $(M)/bbsim-tosca
24
25both: BBSIM_DHCP_TOSCA =
26both: $(M)/siab $(M)/bbsim-tosca
Andy Bavier35053b62018-09-20 13:45:45 -070027
Andy Baviere5a16f62018-10-11 14:07:15 -070028# https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_6.html#SEC69
29latest: SEBAVALUES := configs/seba-ponsim-latest.yaml
30latest: all
31
32stable: SEBAVALUES := configs/seba-ponsim.yaml
33stable: all
34
Andy Bavier35053b62018-09-20 13:45:45 -070035$(M)/setup:
36 mkdir -p $(M)
37 sudo apt update
38 sudo apt install -y httpie jq software-properties-common
39 sudo swapoff -a
Andy Bavier07779ea2018-10-03 15:13:22 -070040 sudo iptables -P FORWARD ACCEPT
Andy Bavier35053b62018-09-20 13:45:45 -070041 touch $@
42
43/usr/bin/docker: | $(M)/setup
44 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
45 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable"
46 sudo apt update
47 sudo apt install -y "docker-ce=17.03*"
48
49/usr/bin/kubeadm: | $(M)/setup /usr/bin/docker
50 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
51 echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list
52 sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list
53 sudo apt update
54 sudo apt install -y "kubeadm=1.11.3-*" "kubelet=1.11.3-*" "kubectl=1.11.3-*"
55
56/usr/local/bin/helm:
57 curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz"
58 echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c -
59 cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
60 sudo chmod a+x /usr/local/bin/helm
61 rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM}
62
63$(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm
64 sudo kubeadm init --pod-network-cidr=192.168.0.0/16
Andy Baviera7c6a4e2018-09-28 13:29:43 -070065 mkdir -p $(HOME)/.kube
66 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
67 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
Andy Bavier35053b62018-09-20 13:45:45 -070068 kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
69 kubectl taint nodes --all node-role.kubernetes.io/master-
70 touch $@
71
72$(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm
73 kubectl create serviceaccount --namespace kube-system tiller
74 kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
75 helm init --service-account tiller
76 until helm ls >& /dev/null; \
77 do \
78 echo "Waiting for Helm to be ready"; \
79 sleep 5; \
80 done
Zack Williams3bcdc262018-09-27 11:00:38 -070081 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
Andy Bavier35053b62018-09-20 13:45:45 -070082 touch $@
83
84$(WORKSPACE)/cord/helm-charts: | $(M)/setup
85 mkdir -p $(WORKSPACE)/cord
86 cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts
87
88$(M)/kafka: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init
Zack Williams3bcdc262018-09-27 11:00:38 -070089 cd $(WORKSPACE)/cord/helm-charts && \
90 helm upgrade --install cord-kafka --version $(KAFKA_CHART_VERSION) -f examples/kafka-single.yaml incubator/kafka
Andy Bavier35053b62018-09-20 13:45:45 -070091 touch $@
92
93$(M)/kafka-running: | $(M)/kafka
94 kubectl wait pod/cord-kafka-0 --for condition=Ready --timeout=180s
95 touch $@
96
Zack Williams3bcdc262018-09-27 11:00:38 -070097$(M)/nem-monitoring: | $(M)/kafka-running
98 cd $(WORKSPACE)/cord/helm-charts && \
99 helm dep up nem-monitoring && \
100 helm upgrade --install nem-monitoring nem-monitoring
101 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
102 touch $@
103
104$(M)/logging: | $(M)/kafka-running
105 cd $(WORKSPACE)/cord/helm-charts && \
106 helm dep up logging && \
107 helm upgrade --install logging -f examples/logging-single.yaml logging
108 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
109 touch $@
110
Andy Bavier35053b62018-09-20 13:45:45 -0700111# Dependency on NEM is there to force ordering for parallel install
112# The idea is to install VOLTHA / ONOS / Mininet while NEM is initializing
Zack Williams3bcdc262018-09-27 11:00:38 -0700113$(M)/onos: | $(M)/kafka-running $(M)/nem $(INFRA_PREREQS)
Andy Bavierb5651c72018-12-13 07:44:46 -0700114 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install onos onos -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700115 touch $@
116
Andy Bavier1e3e9522018-11-06 11:12:00 -0700117$(M)/voltha: | $(M)/kafka-running $(INFRA_PREREQS) $(M)/etcd-operator-ready
Andy Bavier35053b62018-09-20 13:45:45 -0700118 cd $(WORKSPACE)/cord/helm-charts; helm dep up voltha
Andy Bavier1e3e9522018-11-06 11:12:00 -0700119 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install voltha voltha -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700120 touch $@
121
Andy Bavier1e3e9522018-11-06 11:12:00 -0700122$(M)/etcd-operator-ready: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init
123 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install etcd-operator stable/etcd-operator -f $(SEBAVALUES)
124 until kubectl get crd | grep etcdclusters; \
Andy Bavier35053b62018-09-20 13:45:45 -0700125 do \
Andy Bavier1e3e9522018-11-06 11:12:00 -0700126 echo "Waiting for etcdclusters CRD to be available"; \
Andy Bavier35053b62018-09-20 13:45:45 -0700127 sleep 5; \
128 done
129 touch $@
130
Andy Bavier1e3e9522018-11-06 11:12:00 -0700131$(M)/voltha-running: | $(M)/voltha
Kailashbff9eb72018-11-16 13:03:59 -0800132 timeout 300s bash -c "until kubectl get pod|grep etcd-cluster|grep 1/1; do echo 'Waiting for etcd-cluster to be ready'; sleep 10; done"
Andy Bavier35053b62018-09-20 13:45:45 -0700133 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh voltha
134 touch $@
135
136$(M)/ponsim: | $(M)/voltha
137 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponnet ponnet
138 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh kube-system
139 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f $(SEBAVALUES)
140 touch $@
141
142$(M)/pon0_fwd: | $(M)/ponsim
143 echo 8 > /tmp/pon0_group_fwd_mask
144 until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \
145 do \
146 echo "waiting for pon0..."; \
147 sleep 5; \
148 done
149 rm /tmp/pon0_group_fwd_mask
150 touch $@
151
152$(M)/mininet: | $(M)/onos $(M)/ponsim $(M)/pon0_fwd
153 sudo modprobe openvswitch
154 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install mininet mininet
155 touch $@
156
Zack Williamsd0c12f02018-11-21 11:54:36 -0700157$(M)/nem: | $(M)/kafka-running $(INFRA_PREREQS)
Andy Bavier35053b62018-09-20 13:45:45 -0700158 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-core
Andy Baviere5a16f62018-10-11 14:07:15 -0700159 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install xos-core xos-core -f $(SEBAVALUES)
Matteo Scandolof3ceb4c2018-12-12 15:48:38 -0800160 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/seba-services
161 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install seba-services xos-profiles/seba-services -f $(SEBAVALUES)
162 cd $(WORKSPACE)/cord/helm-charts; helm dep update workflows/att-workflow
163 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install att-workflow workflows/att-workflow -f $(SEBAVALUES)
Andy Bavierde4537d2018-11-29 11:48:25 -0700164 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/base-kubernetes
165 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install base-kubernetes xos-profiles/base-kubernetes -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700166 touch $@
167
Zack Williamsd0c12f02018-11-21 11:54:36 -0700168$(M)/nem-running: | $(M)/nem
Andy Bavier35053b62018-09-20 13:45:45 -0700169 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
170 touch $@
171
Zack Williamsd0c12f02018-11-21 11:54:36 -0700172$(M)/ponsim-tosca: | $(M)/nem-running
Andy Bavier35053b62018-09-20 13:45:45 -0700173 timeout 60s bash -c "until ! http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/core/serviceinstanceattributes|jq '.items[].backend_status'|grep -v OK; do echo 'waiting for ONOS config to sync'; sleep 5; done"
174 timeout 60s bash -c "until ! http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/onos/onosapps|jq '.items[].backend_status'|grep -v OK; do echo 'waiting for ONOS apps to sync'; sleep 5; done"
Andy Bavier905ec802018-10-04 11:08:37 -0700175 timeout 60s bash -c "until http -a karaf:karaf GET http://127.0.0.1:30120/onos/v1/applications/org.opencord.kafka|jq '.state'|grep -q ACTIVE; do echo 'Waiting for Kafka app to become ACTIVE'; sleep 5; done"
Andy Baviere5a16f62018-10-11 14:07:15 -0700176 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700177 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
178 touch $@
179
180$(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca
181 until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \
182 do \
183 sleep 5; \
184 done
185 http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535
Andy Bavier905ec802018-10-04 11:08:37 -0700186 timeout 1m bash -c "until http GET http://127.0.0.1:30125/health|jq '.state'|grep -q HEALTHY; do echo 'Waiting for VOLTHA to be HEALTHY'; sleep 10; done"
187 echo "[passed] VOLTHA is HEALTHY"
188 timeout 2m bash -c "until http GET http://127.0.0.1:30125/api/v1/devices|jq '.items[].admin_state'|grep ENABLED|wc -l|grep -q 2; do echo 'Waiting for OLT and ONU to be enabled in VOLTHA'; sleep 10; done"
189 echo "[passed] OLT and ONU are enabled in VOLTHA"
190 timeout 2m bash -c "until http -a karaf:karaf GET http://127.0.0.1:30120/onos/v1/devices|jq '.devices[].available'|grep true|wc -l|grep -q 2; do echo 'Waiting for VOLTHA logical device and agg switch to be available in ONOS'; sleep 10; done"
191 echo "[passed] VOLTHA logical device and agg switch are available in ONOS"
192 timeout 2m bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/att-workflow-driver/attworkflowdriverserviceinstances |jq '.items[0].authentication_state'|grep -q AWAITING; do echo 'waiting for ATT Workflow Driver ServiceInstance to be in AWAITING state'; sleep 10; done"
193 echo "[passed] ATT Workflow Driver ServiceInstance is in AWAITING state"
Andy Bavier35053b62018-09-20 13:45:45 -0700194 touch $@
195 echo "SEBA-in-a-Box installation finished!"
196
Zack Williamsd0c12f02018-11-21 11:54:36 -0700197# BBSim support
198BBSIM_OLT_TOSCA ?= examples/bbsim-16.yaml
199BBSIM_DHCP_TOSCA ?= examples/bbsim-dhcp.yaml
200
201$(M)/bbsim: | $(M)/onos $(M)/voltha-running $(M)/nem-running
202 cd $(WORKSPACE)/cord/helm-charts && \
203 helm upgrade --install bbsim bbsim -f $(SEBAVALUES) && \
204 scripts/wait_for_pods.sh voltha && \
205 touch $@
206
207$(M)/bbsim-tosca: | $(M)/bbsim
208 cd $(WORKSPACE)/cord/helm-charts && \
209 echo "Loading BBSim TOSCA: $(BBSIM_DHCP_TOSCA) $(BBSIM_OLT_TOSCA)" && \
210 for tosca in $(BBSIM_DHCP_TOSCA) $(BBSIM_OLT_TOSCA) ; do \
211 curl -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @$$tosca http://127.0.0.1:30007/run ; \
212 done && \
213 touch $@
214
215run-tests: | $(M)/qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700216
Andy Bavier01449932018-10-01 16:19:40 -0700217$(M)/qatests-prereqs:
218 sudo apt install -y python-pip virtualenv
Andy Bavier35053b62018-09-20 13:45:45 -0700219 touch $@
220
Andy Bavier01449932018-10-01 16:19:40 -0700221$(WORKSPACE)/cord/test/cord-tester: | $(M)/setup
222 mkdir -p $(WORKSPACE)/cord/test
223 cd $(WORKSPACE)/cord/test && git clone https://gerrit.opencord.org/cord-tester
Andy Bavier35053b62018-09-20 13:45:45 -0700224
Zack Williamsd0c12f02018-11-21 11:54:36 -0700225PYBOT_ARGS ?=
226$(M)/qatests: | $(M)/siab $(M)/qatests-prereqs $(WORKSPACE)/cord/test/cord-tester
Andy Bavier01449932018-10-01 16:19:40 -0700227 cd $(WORKSPACE)/cord/test/cord-tester/src/test/cord-api/ && \
Andy Bavier6ce277e2018-10-02 10:29:21 -0700228 WORKSPACE=$(VIRTUALENV) bash ./setup_venv.sh && \
229 source $(VIRTUALENV)/venv-cord-tester/bin/activate && \
Andy Bavier01449932018-10-01 16:19:40 -0700230 cd Tests/WorkflowValidations/ && \
Kailash48e7a3f2018-12-06 12:31:32 -0800231 robot $(PYBOT_ARGS) --removekeywords wuks -e notready -i $(TESTTAGS) SIAB.robot
Andy Bavier35053b62018-09-20 13:45:45 -0700232 touch $@
233
234remove-chart-milestones:
235 cd $(M); rm -f kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \
Zack Williamsd0c12f02018-11-21 11:54:36 -0700236 voltha-running ponsim mininet nem nem-running ponsim-tosca siab bbsim bbsim-tosca \
237 logging nem-monitoring
Andy Bavier35053b62018-09-20 13:45:45 -0700238
239remove-kube-milestones:
240 cd $(M); rm -f kubeadm helm-init
241
242remove-test-milestones:
Kailashf8ff8122018-12-03 10:44:06 -0800243 cd $(M); rm -f qatests qatests-prereqs
Andy Bavier35053b62018-09-20 13:45:45 -0700244
245teardown-charts: remove-chart-milestones
Matteo Scandolo0efb3252018-12-10 15:58:45 -0800246 helm delete --purge $(shell helm ls -q | grep -v docker-registry)
Andy Bavier35053b62018-09-20 13:45:45 -0700247
Kailashf8ff8122018-12-03 10:44:06 -0800248reset-kubeadm: remove-chart-milestones remove-kube-milestones remove-test-milestones
Andy Bavierc3a02692018-09-26 15:55:23 -0700249 sudo kubeadm reset -f
Andy Bavier35053b62018-09-20 13:45:45 -0700250 sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
251