blob: 834c27152be7f4a60d86dda07a7d419cec9a0e1d [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
Andy Bavier1d5b9922019-01-02 15:30:55 -070019KAFKA_POD := "pod/cord-kafka-0"
Zack Williams3bcdc262018-09-27 11:00:38 -070020
Zack Williamsd0c12f02018-11-21 11:54:36 -070021# Targets
22ponsim: $(M)/siab
23
24bbsim: $(M)/bbsim-tosca
25
26both: BBSIM_DHCP_TOSCA =
27both: $(M)/siab $(M)/bbsim-tosca
Andy Bavier35053b62018-09-20 13:45:45 -070028
Andy Baviere5a16f62018-10-11 14:07:15 -070029# https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_6.html#SEC69
30latest: SEBAVALUES := configs/seba-ponsim-latest.yaml
31latest: all
32
33stable: SEBAVALUES := configs/seba-ponsim.yaml
34stable: all
35
Andy Bavier1d5b9922019-01-02 15:30:55 -070036siab-1.0: SEBAVALUES := configs/siab-v1.0.0.yaml
37siab-1.0: KAFKA_POD := "pod/cord-platform-kafka-0"
38# Parallel make won't work here; need to install seba-1.0.0 before siab
39siab-1.0: $(M)/seba-1.0.0 $(M)/siab
40
Andy Bavier35053b62018-09-20 13:45:45 -070041$(M)/setup:
42 mkdir -p $(M)
43 sudo apt update
44 sudo apt install -y httpie jq software-properties-common
45 sudo swapoff -a
Andy Bavier07779ea2018-10-03 15:13:22 -070046 sudo iptables -P FORWARD ACCEPT
Andy Bavier35053b62018-09-20 13:45:45 -070047 touch $@
48
49/usr/bin/docker: | $(M)/setup
50 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
51 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable"
52 sudo apt update
53 sudo apt install -y "docker-ce=17.03*"
54
55/usr/bin/kubeadm: | $(M)/setup /usr/bin/docker
56 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
57 echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list
58 sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list
59 sudo apt update
60 sudo apt install -y "kubeadm=1.11.3-*" "kubelet=1.11.3-*" "kubectl=1.11.3-*"
61
62/usr/local/bin/helm:
63 curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz"
64 echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c -
65 cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
66 sudo chmod a+x /usr/local/bin/helm
67 rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM}
68
69$(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm
70 sudo kubeadm init --pod-network-cidr=192.168.0.0/16
Andy Baviera7c6a4e2018-09-28 13:29:43 -070071 mkdir -p $(HOME)/.kube
72 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
73 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
Andy Bavier35053b62018-09-20 13:45:45 -070074 kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
75 kubectl taint nodes --all node-role.kubernetes.io/master-
76 touch $@
77
78$(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm
79 kubectl create serviceaccount --namespace kube-system tiller
80 kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
81 helm init --service-account tiller
82 until helm ls >& /dev/null; \
83 do \
84 echo "Waiting for Helm to be ready"; \
85 sleep 5; \
86 done
Zack Williams3bcdc262018-09-27 11:00:38 -070087 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
Andy Bavier1d5b9922019-01-02 15:30:55 -070088 helm repo add cord https://charts.opencord.org
Andy Bavier35053b62018-09-20 13:45:45 -070089 touch $@
90
91$(WORKSPACE)/cord/helm-charts: | $(M)/setup
92 mkdir -p $(WORKSPACE)/cord
93 cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts
94
95$(M)/kafka: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init
Zack Williams3bcdc262018-09-27 11:00:38 -070096 cd $(WORKSPACE)/cord/helm-charts && \
97 helm upgrade --install cord-kafka --version $(KAFKA_CHART_VERSION) -f examples/kafka-single.yaml incubator/kafka
Andy Bavier35053b62018-09-20 13:45:45 -070098 touch $@
99
100$(M)/kafka-running: | $(M)/kafka
Andy Bavier1d5b9922019-01-02 15:30:55 -0700101 kubectl wait $(KAFKA_POD) --for condition=Ready --timeout=180s
Andy Bavier35053b62018-09-20 13:45:45 -0700102 touch $@
103
Zack Williams3bcdc262018-09-27 11:00:38 -0700104$(M)/nem-monitoring: | $(M)/kafka-running
105 cd $(WORKSPACE)/cord/helm-charts && \
106 helm dep up nem-monitoring && \
107 helm upgrade --install nem-monitoring nem-monitoring
108 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
109 touch $@
110
111$(M)/logging: | $(M)/kafka-running
112 cd $(WORKSPACE)/cord/helm-charts && \
113 helm dep up logging && \
114 helm upgrade --install logging -f examples/logging-single.yaml logging
115 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
116 touch $@
117
Andy Bavier35053b62018-09-20 13:45:45 -0700118# Dependency on NEM is there to force ordering for parallel install
119# The idea is to install VOLTHA / ONOS / Mininet while NEM is initializing
Zack Williams3bcdc262018-09-27 11:00:38 -0700120$(M)/onos: | $(M)/kafka-running $(M)/nem $(INFRA_PREREQS)
Andy Bavierb5651c72018-12-13 07:44:46 -0700121 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install onos onos -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700122 touch $@
123
Andy Bavier1e3e9522018-11-06 11:12:00 -0700124$(M)/voltha: | $(M)/kafka-running $(INFRA_PREREQS) $(M)/etcd-operator-ready
Andy Bavier35053b62018-09-20 13:45:45 -0700125 cd $(WORKSPACE)/cord/helm-charts; helm dep up voltha
Andy Bavier1e3e9522018-11-06 11:12:00 -0700126 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install voltha voltha -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700127 touch $@
128
Andy Bavier1e3e9522018-11-06 11:12:00 -0700129$(M)/etcd-operator-ready: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init
130 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install etcd-operator stable/etcd-operator -f $(SEBAVALUES)
131 until kubectl get crd | grep etcdclusters; \
Andy Bavier35053b62018-09-20 13:45:45 -0700132 do \
Andy Bavier1e3e9522018-11-06 11:12:00 -0700133 echo "Waiting for etcdclusters CRD to be available"; \
Andy Bavier35053b62018-09-20 13:45:45 -0700134 sleep 5; \
135 done
136 touch $@
137
Andy Bavier1e3e9522018-11-06 11:12:00 -0700138$(M)/voltha-running: | $(M)/voltha
Kailashbff9eb72018-11-16 13:03:59 -0800139 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 -0700140 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh voltha
141 touch $@
142
143$(M)/ponsim: | $(M)/voltha
144 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponnet ponnet
145 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh kube-system
146 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f $(SEBAVALUES)
147 touch $@
148
149$(M)/pon0_fwd: | $(M)/ponsim
150 echo 8 > /tmp/pon0_group_fwd_mask
151 until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \
152 do \
153 echo "waiting for pon0..."; \
154 sleep 5; \
155 done
156 rm /tmp/pon0_group_fwd_mask
157 touch $@
158
159$(M)/mininet: | $(M)/onos $(M)/ponsim $(M)/pon0_fwd
160 sudo modprobe openvswitch
Andy Bavier1d5b9922019-01-02 15:30:55 -0700161 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install mininet mininet -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700162 touch $@
163
Zack Williamsd0c12f02018-11-21 11:54:36 -0700164$(M)/nem: | $(M)/kafka-running $(INFRA_PREREQS)
Andy Bavier35053b62018-09-20 13:45:45 -0700165 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-core
Andy Baviere5a16f62018-10-11 14:07:15 -0700166 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install xos-core xos-core -f $(SEBAVALUES)
Matteo Scandolof3ceb4c2018-12-12 15:48:38 -0800167 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/seba-services
168 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install seba-services xos-profiles/seba-services -f $(SEBAVALUES)
169 cd $(WORKSPACE)/cord/helm-charts; helm dep update workflows/att-workflow
170 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install att-workflow workflows/att-workflow -f $(SEBAVALUES)
Andy Bavierde4537d2018-11-29 11:48:25 -0700171 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/base-kubernetes
172 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install base-kubernetes xos-profiles/base-kubernetes -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700173 touch $@
174
Zack Williamsd0c12f02018-11-21 11:54:36 -0700175$(M)/nem-running: | $(M)/nem
Andy Bavier35053b62018-09-20 13:45:45 -0700176 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
177 touch $@
178
Zack Williamsd0c12f02018-11-21 11:54:36 -0700179$(M)/ponsim-tosca: | $(M)/nem-running
Andy Bavier35053b62018-09-20 13:45:45 -0700180 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"
181 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 -0700182 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 -0700183 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod -f $(SEBAVALUES)
Andy Bavier35053b62018-09-20 13:45:45 -0700184 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
185 touch $@
186
187$(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca
188 until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \
189 do \
190 sleep 5; \
191 done
192 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 -0700193 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"
194 echo "[passed] VOLTHA is HEALTHY"
195 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"
196 echo "[passed] OLT and ONU are enabled in VOLTHA"
197 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"
198 echo "[passed] VOLTHA logical device and agg switch are available in ONOS"
199 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"
200 echo "[passed] ATT Workflow Driver ServiceInstance is in AWAITING state"
Andy Bavier35053b62018-09-20 13:45:45 -0700201 touch $@
202 echo "SEBA-in-a-Box installation finished!"
203
Andy Bavier1d5b9922019-01-02 15:30:55 -0700204$(M)/seba-1.0.0: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init
205 helm install -n cord-platform cord/cord-platform --version=6.1.0 -f $(WORKSPACE)/cord/helm-charts/$(SEBAVALUES)
206 until kubectl get crd | grep etcdclusters; \
207 do \
208 echo "Waiting for etcdclusters CRD to be available"; \
209 sleep 5; \
210 done
211 touch $(M)/kafka
212 touch $(M)/onos
213 touch $(M)/etcd-operator-ready
214 helm install -n seba cord/seba --version=1.0.0 -f $(WORKSPACE)/cord/helm-charts/$(SEBAVALUES)
215 helm install -n att-workflow cord/att-workflow --version=1.0.2 -f $(WORKSPACE)/cord/helm-charts/$(SEBAVALUES)
216 touch $(M)/voltha
217 touch $(M)/nem
218 touch $@
219
Zack Williamsd0c12f02018-11-21 11:54:36 -0700220# BBSim support
221BBSIM_OLT_TOSCA ?= examples/bbsim-16.yaml
222BBSIM_DHCP_TOSCA ?= examples/bbsim-dhcp.yaml
223
224$(M)/bbsim: | $(M)/onos $(M)/voltha-running $(M)/nem-running
225 cd $(WORKSPACE)/cord/helm-charts && \
226 helm upgrade --install bbsim bbsim -f $(SEBAVALUES) && \
227 scripts/wait_for_pods.sh voltha && \
228 touch $@
229
230$(M)/bbsim-tosca: | $(M)/bbsim
231 cd $(WORKSPACE)/cord/helm-charts && \
232 echo "Loading BBSim TOSCA: $(BBSIM_DHCP_TOSCA) $(BBSIM_OLT_TOSCA)" && \
233 for tosca in $(BBSIM_DHCP_TOSCA) $(BBSIM_OLT_TOSCA) ; do \
234 curl -H "xos-username: admin@opencord.org" -H "xos-password: letmein" -X POST --data-binary @$$tosca http://127.0.0.1:30007/run ; \
235 done && \
236 touch $@
237
238run-tests: | $(M)/qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700239
Andy Bavier01449932018-10-01 16:19:40 -0700240$(M)/qatests-prereqs:
241 sudo apt install -y python-pip virtualenv
Andy Bavier35053b62018-09-20 13:45:45 -0700242 touch $@
243
Andy Bavier01449932018-10-01 16:19:40 -0700244$(WORKSPACE)/cord/test/cord-tester: | $(M)/setup
245 mkdir -p $(WORKSPACE)/cord/test
246 cd $(WORKSPACE)/cord/test && git clone https://gerrit.opencord.org/cord-tester
Andy Bavier35053b62018-09-20 13:45:45 -0700247
Zack Williamsd0c12f02018-11-21 11:54:36 -0700248PYBOT_ARGS ?=
249$(M)/qatests: | $(M)/siab $(M)/qatests-prereqs $(WORKSPACE)/cord/test/cord-tester
Andy Bavier01449932018-10-01 16:19:40 -0700250 cd $(WORKSPACE)/cord/test/cord-tester/src/test/cord-api/ && \
Andy Bavier6ce277e2018-10-02 10:29:21 -0700251 WORKSPACE=$(VIRTUALENV) bash ./setup_venv.sh && \
252 source $(VIRTUALENV)/venv-cord-tester/bin/activate && \
Andy Bavier01449932018-10-01 16:19:40 -0700253 cd Tests/WorkflowValidations/ && \
Kailash48e7a3f2018-12-06 12:31:32 -0800254 robot $(PYBOT_ARGS) --removekeywords wuks -e notready -i $(TESTTAGS) SIAB.robot
Andy Bavier35053b62018-09-20 13:45:45 -0700255 touch $@
256
257remove-chart-milestones:
258 cd $(M); rm -f kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \
Zack Williamsd0c12f02018-11-21 11:54:36 -0700259 voltha-running ponsim mininet nem nem-running ponsim-tosca siab bbsim bbsim-tosca \
Andy Bavier1d5b9922019-01-02 15:30:55 -0700260 logging nem-monitoring seba-1.0.0
Andy Bavier35053b62018-09-20 13:45:45 -0700261
262remove-kube-milestones:
263 cd $(M); rm -f kubeadm helm-init
264
265remove-test-milestones:
Kailashf8ff8122018-12-03 10:44:06 -0800266 cd $(M); rm -f qatests qatests-prereqs
Andy Bavier35053b62018-09-20 13:45:45 -0700267
268teardown-charts: remove-chart-milestones
Matteo Scandolo0efb3252018-12-10 15:58:45 -0800269 helm delete --purge $(shell helm ls -q | grep -v docker-registry)
Andy Bavier35053b62018-09-20 13:45:45 -0700270
Kailashf8ff8122018-12-03 10:44:06 -0800271reset-kubeadm: remove-chart-milestones remove-kube-milestones remove-test-milestones
Andy Bavierc3a02692018-09-26 15:55:23 -0700272 sudo kubeadm reset -f
Andy Bavier35053b62018-09-20 13:45:45 -0700273 sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
274