blob: ec0afb6773fcafe51946c36530b3306ad86ae03a [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
8
Zack Williams3bcdc262018-09-27 11:00:38 -07009# used to start logging/monitoring and other infrastructure charts
10INFRA_CHARTS ?=
11INFRA_PREREQS = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart))
12
Andy Bavier35053b62018-09-20 13:45:45 -070013HELM_VERSION ?= "2.10.0"
14HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe"
15HELM_PLATFORM ?= "linux-amd64"
16
Zack Williams3bcdc262018-09-27 11:00:38 -070017KAFKA_CHART_VERSION ?= 0.8.8
18
Andy Bavier35053b62018-09-20 13:45:45 -070019all: $(M)/siab
20
21$(M)/setup:
22 mkdir -p $(M)
23 sudo apt update
24 sudo apt install -y httpie jq software-properties-common
25 sudo swapoff -a
Andy Bavier07779ea2018-10-03 15:13:22 -070026 sudo iptables -P FORWARD ACCEPT
Andy Bavier35053b62018-09-20 13:45:45 -070027 touch $@
28
29/usr/bin/docker: | $(M)/setup
30 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
31 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable"
32 sudo apt update
33 sudo apt install -y "docker-ce=17.03*"
34
35/usr/bin/kubeadm: | $(M)/setup /usr/bin/docker
36 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
37 echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list
38 sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list
39 sudo apt update
40 sudo apt install -y "kubeadm=1.11.3-*" "kubelet=1.11.3-*" "kubectl=1.11.3-*"
41
42/usr/local/bin/helm:
43 curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz"
44 echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c -
45 cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
46 sudo chmod a+x /usr/local/bin/helm
47 rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM}
48
49$(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm
50 sudo kubeadm init --pod-network-cidr=192.168.0.0/16
Andy Baviera7c6a4e2018-09-28 13:29:43 -070051 mkdir -p $(HOME)/.kube
52 sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config
53 sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config
Andy Bavier35053b62018-09-20 13:45:45 -070054 kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
55 kubectl taint nodes --all node-role.kubernetes.io/master-
56 touch $@
57
58$(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm
59 kubectl create serviceaccount --namespace kube-system tiller
60 kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
61 helm init --service-account tiller
62 until helm ls >& /dev/null; \
63 do \
64 echo "Waiting for Helm to be ready"; \
65 sleep 5; \
66 done
Zack Williams3bcdc262018-09-27 11:00:38 -070067 helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
Andy Bavier35053b62018-09-20 13:45:45 -070068 touch $@
69
70$(WORKSPACE)/cord/helm-charts: | $(M)/setup
71 mkdir -p $(WORKSPACE)/cord
72 cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts
73
74$(M)/kafka: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init
Zack Williams3bcdc262018-09-27 11:00:38 -070075 cd $(WORKSPACE)/cord/helm-charts && \
76 helm upgrade --install cord-kafka --version $(KAFKA_CHART_VERSION) -f examples/kafka-single.yaml incubator/kafka
Andy Bavier35053b62018-09-20 13:45:45 -070077 touch $@
78
79$(M)/kafka-running: | $(M)/kafka
80 kubectl wait pod/cord-kafka-0 --for condition=Ready --timeout=180s
81 touch $@
82
Zack Williams3bcdc262018-09-27 11:00:38 -070083$(M)/nem-monitoring: | $(M)/kafka-running
84 cd $(WORKSPACE)/cord/helm-charts && \
85 helm dep up nem-monitoring && \
86 helm upgrade --install nem-monitoring nem-monitoring
87 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
88 touch $@
89
90$(M)/logging: | $(M)/kafka-running
91 cd $(WORKSPACE)/cord/helm-charts && \
92 helm dep up logging && \
93 helm upgrade --install logging -f examples/logging-single.yaml logging
94 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
95 touch $@
96
Andy Bavier35053b62018-09-20 13:45:45 -070097# Dependency on NEM is there to force ordering for parallel install
98# The idea is to install VOLTHA / ONOS / Mininet while NEM is initializing
Zack Williams3bcdc262018-09-27 11:00:38 -070099$(M)/onos: | $(M)/kafka-running $(M)/nem $(INFRA_PREREQS)
Andy Bavier35053b62018-09-20 13:45:45 -0700100 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install onos onos -f configs/onos.yaml -f $(SEBAVALUES)
101 touch $@
102
Zack Williams3bcdc262018-09-27 11:00:38 -0700103$(M)/voltha: | $(M)/kafka-running $(INFRA_PREREQS)
Andy Bavier35053b62018-09-20 13:45:45 -0700104 cd $(WORKSPACE)/cord/helm-charts; helm dep up voltha
105 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install voltha -f $(SEBAVALUES) \
106 --set etcd-operator.customResources.createEtcdClusterCRD=false \
107 voltha
108 touch $@
109
110$(M)/etcd-operator-ready: | $(M)/voltha
111 until kubectl api-versions | grep etcd.database.coreos.com/v1beta2; \
112 do \
113 echo "Waiting for etcd.database.coreos.com/v1beta2 to be available"; \
114 sleep 5; \
115 done
116 until kubectl api-resources | grep EtcdCluster; \
117 do \
118 echo "Waiting for EtcdCluster API resource to be available"; \
119 sleep 5; \
120 done
121 touch $@
122
123$(M)/etcd-cluster: | $(M)/etcd-operator-ready
124 cd $(WORKSPACE)/cord/helm-charts; helm upgrade voltha -f $(SEBAVALUES) \
125 --set etcd-operator.customResources.createEtcdClusterCRD=true \
126 voltha
127 touch $@
128
129$(M)/voltha-running: | $(M)/etcd-cluster
130 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh voltha
131 touch $@
132
133$(M)/ponsim: | $(M)/voltha
134 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponnet ponnet
135 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh kube-system
136 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f $(SEBAVALUES)
137 touch $@
138
139$(M)/pon0_fwd: | $(M)/ponsim
140 echo 8 > /tmp/pon0_group_fwd_mask
141 until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \
142 do \
143 echo "waiting for pon0..."; \
144 sleep 5; \
145 done
146 rm /tmp/pon0_group_fwd_mask
147 touch $@
148
149$(M)/mininet: | $(M)/onos $(M)/ponsim $(M)/pon0_fwd
150 sudo modprobe openvswitch
151 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install mininet mininet
152 touch $@
153
Zack Williams3bcdc262018-09-27 11:00:38 -0700154$(M)/nem: $(M)/kafka-running $(INFRA_PREREQS)
Andy Bavier35053b62018-09-20 13:45:45 -0700155 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-core
156 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install xos-core xos-core
157 cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/att-workflow
158 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install att-workflow xos-profiles/att-workflow -f $(SEBAVALUES)
159 touch $@
160
161$(M)/nem-running: $(M)/nem
162 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
163 touch $@
164
165$(M)/ponsim-tosca: $(M)/nem-running
166 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"
167 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 -0700168 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 Bavier35053b62018-09-20 13:45:45 -0700169 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod
170 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
171 touch $@
172
173$(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca
174 until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \
175 do \
176 sleep 5; \
177 done
178 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 -0700179 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"
180 echo "[passed] VOLTHA is HEALTHY"
181 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"
182 echo "[passed] OLT and ONU are enabled in VOLTHA"
183 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"
184 echo "[passed] VOLTHA logical device and agg switch are available in ONOS"
185 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"
186 echo "[passed] ATT Workflow Driver ServiceInstance is in AWAITING state"
Andy Bavier35053b62018-09-20 13:45:45 -0700187 touch $@
188 echo "SEBA-in-a-Box installation finished!"
189
Andy Bavier01449932018-10-01 16:19:40 -0700190run-tests: $(M)/qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700191
Andy Bavier01449932018-10-01 16:19:40 -0700192$(M)/qatests-prereqs:
193 sudo apt install -y python-pip virtualenv
Andy Bavier35053b62018-09-20 13:45:45 -0700194 touch $@
195
Andy Bavier01449932018-10-01 16:19:40 -0700196$(WORKSPACE)/cord/test/cord-tester: | $(M)/setup
197 mkdir -p $(WORKSPACE)/cord/test
198 cd $(WORKSPACE)/cord/test && git clone https://gerrit.opencord.org/cord-tester
Andy Bavier35053b62018-09-20 13:45:45 -0700199
Andy Bavier01449932018-10-01 16:19:40 -0700200$(M)/qatests: $(M)/siab $(M)/qatests-prereqs $(WORKSPACE)/cord/test/cord-tester
201 cd $(WORKSPACE)/cord/test/cord-tester/src/test/cord-api/ && \
Andy Bavier6ce277e2018-10-02 10:29:21 -0700202 WORKSPACE=$(VIRTUALENV) bash ./setup_venv.sh && \
203 source $(VIRTUALENV)/venv-cord-tester/bin/activate && \
Andy Bavier01449932018-10-01 16:19:40 -0700204 cd Tests/WorkflowValidations/ && \
205 pybot -e notready SIAB.robot
Andy Bavier35053b62018-09-20 13:45:45 -0700206 touch $@
207
208remove-chart-milestones:
209 cd $(M); rm -f kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \
210 voltha-running ponsim mininet nem nem-running ponsim-tosca siab
211
212remove-kube-milestones:
213 cd $(M); rm -f kubeadm helm-init
214
215remove-test-milestones:
Andy Bavier01449932018-10-01 16:19:40 -0700216 cd $(M); rm -f qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700217
218teardown-charts: remove-chart-milestones
219 helm delete --purge $(shell helm ls -q)
220
221reset-kubeadm: remove-chart-milestones remove-kube-milestones
Andy Bavierc3a02692018-09-26 15:55:23 -0700222 sudo kubeadm reset -f
Andy Bavier35053b62018-09-20 13:45:45 -0700223 sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
224