blob: 0d25e75232c146fb277a864295ddb52f54a26bd4 [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"
147 cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod
148 $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh
149 touch $@
150
151$(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca
152 until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \
153 do \
154 sleep 5; \
155 done
156 http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535
Andy Bavier07779ea2018-10-03 15:13:22 -0700157 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 AWAITING; do echo 'waiting for att-workflow-driver to be in AWAITING state'; sleep 5; done"
Andy Bavier35053b62018-09-20 13:45:45 -0700158 touch $@
159 echo "SEBA-in-a-Box installation finished!"
160
Andy Bavier01449932018-10-01 16:19:40 -0700161run-tests: $(M)/qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700162
Andy Bavier01449932018-10-01 16:19:40 -0700163$(M)/qatests-prereqs:
164 sudo apt install -y python-pip virtualenv
Andy Bavier35053b62018-09-20 13:45:45 -0700165 touch $@
166
Andy Bavier01449932018-10-01 16:19:40 -0700167$(WORKSPACE)/cord/test/cord-tester: | $(M)/setup
168 mkdir -p $(WORKSPACE)/cord/test
169 cd $(WORKSPACE)/cord/test && git clone https://gerrit.opencord.org/cord-tester
Andy Bavier35053b62018-09-20 13:45:45 -0700170
Andy Bavier01449932018-10-01 16:19:40 -0700171$(M)/qatests: $(M)/siab $(M)/qatests-prereqs $(WORKSPACE)/cord/test/cord-tester
172 cd $(WORKSPACE)/cord/test/cord-tester/src/test/cord-api/ && \
Andy Bavier6ce277e2018-10-02 10:29:21 -0700173 WORKSPACE=$(VIRTUALENV) bash ./setup_venv.sh && \
174 source $(VIRTUALENV)/venv-cord-tester/bin/activate && \
Andy Bavier01449932018-10-01 16:19:40 -0700175 cd Tests/WorkflowValidations/ && \
176 pybot -e notready SIAB.robot
Andy Bavier35053b62018-09-20 13:45:45 -0700177 touch $@
178
179remove-chart-milestones:
180 cd $(M); rm -f kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \
181 voltha-running ponsim mininet nem nem-running ponsim-tosca siab
182
183remove-kube-milestones:
184 cd $(M); rm -f kubeadm helm-init
185
186remove-test-milestones:
Andy Bavier01449932018-10-01 16:19:40 -0700187 cd $(M); rm -f qatests
Andy Bavier35053b62018-09-20 13:45:45 -0700188
189teardown-charts: remove-chart-milestones
190 helm delete --purge $(shell helm ls -q)
191
192reset-kubeadm: remove-chart-milestones remove-kube-milestones
Andy Bavierc3a02692018-09-26 15:55:23 -0700193 sudo kubeadm reset -f
Andy Bavier35053b62018-09-20 13:45:45 -0700194 sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X
195