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