Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 1 | SHELL := /bin/bash |
| 2 | BUILD ?= /tmp |
| 3 | M ?= $(BUILD)/milestones |
| 4 | MAKEDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) |
| 5 | WORKSPACE ?= $(HOME) |
Andy Bavier | 6ce277e | 2018-10-02 10:29:21 -0700 | [diff] [blame] | 6 | VIRTUALENV ?= $(WORKSPACE)/cord/test |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 7 | SEBAVALUES ?= configs/seba-ponsim.yaml |
Kailash Khalasi | 98dabd0 | 2018-10-19 13:00:12 -0700 | [diff] [blame^] | 8 | TESTTAGS ?= stable |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 9 | |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 10 | # used to start logging/monitoring and other infrastructure charts |
| 11 | INFRA_CHARTS ?= |
| 12 | INFRA_PREREQS = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart)) |
| 13 | |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 14 | HELM_VERSION ?= "2.10.0" |
| 15 | HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe" |
| 16 | HELM_PLATFORM ?= "linux-amd64" |
| 17 | |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 18 | KAFKA_CHART_VERSION ?= 0.8.8 |
| 19 | |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 20 | all: $(M)/siab |
| 21 | |
Andy Bavier | e5a16f6 | 2018-10-11 14:07:15 -0700 | [diff] [blame] | 22 | # https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_6.html#SEC69 |
| 23 | latest: SEBAVALUES := configs/seba-ponsim-latest.yaml |
| 24 | latest: all |
| 25 | |
| 26 | stable: SEBAVALUES := configs/seba-ponsim.yaml |
| 27 | stable: all |
| 28 | |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 29 | $(M)/setup: |
| 30 | mkdir -p $(M) |
| 31 | sudo apt update |
| 32 | sudo apt install -y httpie jq software-properties-common |
| 33 | sudo swapoff -a |
Andy Bavier | 07779ea | 2018-10-03 15:13:22 -0700 | [diff] [blame] | 34 | sudo iptables -P FORWARD ACCEPT |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 35 | touch $@ |
| 36 | |
| 37 | /usr/bin/docker: | $(M)/setup |
| 38 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88 |
| 39 | sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable" |
| 40 | sudo apt update |
| 41 | sudo apt install -y "docker-ce=17.03*" |
| 42 | |
| 43 | /usr/bin/kubeadm: | $(M)/setup /usr/bin/docker |
| 44 | curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - |
| 45 | echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list |
| 46 | sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list |
| 47 | sudo apt update |
| 48 | sudo apt install -y "kubeadm=1.11.3-*" "kubelet=1.11.3-*" "kubectl=1.11.3-*" |
| 49 | |
| 50 | /usr/local/bin/helm: |
| 51 | curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz" |
| 52 | echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c - |
| 53 | cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm |
| 54 | sudo chmod a+x /usr/local/bin/helm |
| 55 | rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM} |
| 56 | |
| 57 | $(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm |
| 58 | sudo kubeadm init --pod-network-cidr=192.168.0.0/16 |
Andy Bavier | a7c6a4e | 2018-09-28 13:29:43 -0700 | [diff] [blame] | 59 | mkdir -p $(HOME)/.kube |
| 60 | sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config |
| 61 | sudo chown $(shell id -u):$(shell id -g) $(HOME)/.kube/config |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 62 | kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml |
| 63 | kubectl taint nodes --all node-role.kubernetes.io/master- |
| 64 | touch $@ |
| 65 | |
| 66 | $(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm |
| 67 | kubectl create serviceaccount --namespace kube-system tiller |
| 68 | kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| 69 | helm init --service-account tiller |
| 70 | until helm ls >& /dev/null; \ |
| 71 | do \ |
| 72 | echo "Waiting for Helm to be ready"; \ |
| 73 | sleep 5; \ |
| 74 | done |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 75 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 76 | touch $@ |
| 77 | |
| 78 | $(WORKSPACE)/cord/helm-charts: | $(M)/setup |
| 79 | mkdir -p $(WORKSPACE)/cord |
| 80 | cd $(WORKSPACE)/cord; git clone https://gerrit.opencord.org/helm-charts |
| 81 | |
| 82 | $(M)/kafka: | $(WORKSPACE)/cord/helm-charts $(M)/helm-init |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 83 | cd $(WORKSPACE)/cord/helm-charts && \ |
| 84 | helm upgrade --install cord-kafka --version $(KAFKA_CHART_VERSION) -f examples/kafka-single.yaml incubator/kafka |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 85 | touch $@ |
| 86 | |
| 87 | $(M)/kafka-running: | $(M)/kafka |
| 88 | kubectl wait pod/cord-kafka-0 --for condition=Ready --timeout=180s |
| 89 | touch $@ |
| 90 | |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 91 | $(M)/nem-monitoring: | $(M)/kafka-running |
| 92 | cd $(WORKSPACE)/cord/helm-charts && \ |
| 93 | helm dep up nem-monitoring && \ |
| 94 | helm upgrade --install nem-monitoring nem-monitoring |
| 95 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh |
| 96 | touch $@ |
| 97 | |
| 98 | $(M)/logging: | $(M)/kafka-running |
| 99 | cd $(WORKSPACE)/cord/helm-charts && \ |
| 100 | helm dep up logging && \ |
| 101 | helm upgrade --install logging -f examples/logging-single.yaml logging |
| 102 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh |
| 103 | touch $@ |
| 104 | |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 105 | # Dependency on NEM is there to force ordering for parallel install |
| 106 | # The idea is to install VOLTHA / ONOS / Mininet while NEM is initializing |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 107 | $(M)/onos: | $(M)/kafka-running $(M)/nem $(INFRA_PREREQS) |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 108 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install onos onos -f configs/onos.yaml -f $(SEBAVALUES) |
| 109 | touch $@ |
| 110 | |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 111 | $(M)/voltha: | $(M)/kafka-running $(INFRA_PREREQS) |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 112 | cd $(WORKSPACE)/cord/helm-charts; helm dep up voltha |
| 113 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install voltha -f $(SEBAVALUES) \ |
| 114 | --set etcd-operator.customResources.createEtcdClusterCRD=false \ |
| 115 | voltha |
| 116 | touch $@ |
| 117 | |
| 118 | $(M)/etcd-operator-ready: | $(M)/voltha |
| 119 | until kubectl api-versions | grep etcd.database.coreos.com/v1beta2; \ |
| 120 | do \ |
| 121 | echo "Waiting for etcd.database.coreos.com/v1beta2 to be available"; \ |
| 122 | sleep 5; \ |
| 123 | done |
| 124 | until kubectl api-resources | grep EtcdCluster; \ |
| 125 | do \ |
| 126 | echo "Waiting for EtcdCluster API resource to be available"; \ |
| 127 | sleep 5; \ |
| 128 | done |
| 129 | touch $@ |
| 130 | |
| 131 | $(M)/etcd-cluster: | $(M)/etcd-operator-ready |
| 132 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade voltha -f $(SEBAVALUES) \ |
| 133 | --set etcd-operator.customResources.createEtcdClusterCRD=true \ |
| 134 | voltha |
Andy Bavier | e5a16f6 | 2018-10-11 14:07:15 -0700 | [diff] [blame] | 135 | timeout 180s bash -c "until kubectl wait pod/etcd-cluster-0000 --for condition=ready; do echo 'Waiting for etcd-cluster-0000 to be ready'; done" |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 136 | touch $@ |
| 137 | |
| 138 | $(M)/voltha-running: | $(M)/etcd-cluster |
| 139 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh voltha |
| 140 | touch $@ |
| 141 | |
| 142 | $(M)/ponsim: | $(M)/voltha |
| 143 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponnet ponnet |
| 144 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh kube-system |
| 145 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f $(SEBAVALUES) |
| 146 | touch $@ |
| 147 | |
| 148 | $(M)/pon0_fwd: | $(M)/ponsim |
| 149 | echo 8 > /tmp/pon0_group_fwd_mask |
| 150 | until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \ |
| 151 | do \ |
| 152 | echo "waiting for pon0..."; \ |
| 153 | sleep 5; \ |
| 154 | done |
| 155 | rm /tmp/pon0_group_fwd_mask |
| 156 | touch $@ |
| 157 | |
| 158 | $(M)/mininet: | $(M)/onos $(M)/ponsim $(M)/pon0_fwd |
| 159 | sudo modprobe openvswitch |
| 160 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install mininet mininet |
| 161 | touch $@ |
| 162 | |
Zack Williams | 3bcdc26 | 2018-09-27 11:00:38 -0700 | [diff] [blame] | 163 | $(M)/nem: $(M)/kafka-running $(INFRA_PREREQS) |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 164 | cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-core |
Andy Bavier | e5a16f6 | 2018-10-11 14:07:15 -0700 | [diff] [blame] | 165 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install xos-core xos-core -f $(SEBAVALUES) |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 166 | cd $(WORKSPACE)/cord/helm-charts; helm dep update xos-profiles/att-workflow |
| 167 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install att-workflow xos-profiles/att-workflow -f $(SEBAVALUES) |
| 168 | touch $@ |
| 169 | |
| 170 | $(M)/nem-running: $(M)/nem |
| 171 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh |
| 172 | touch $@ |
| 173 | |
| 174 | $(M)/ponsim-tosca: $(M)/nem-running |
| 175 | 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" |
| 176 | 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 Bavier | 905ec80 | 2018-10-04 11:08:37 -0700 | [diff] [blame] | 177 | 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 Bavier | e5a16f6 | 2018-10-11 14:07:15 -0700 | [diff] [blame] | 178 | cd $(WORKSPACE)/cord/helm-charts; helm upgrade --install ponsim-pod xos-profiles/ponsim-pod -f $(SEBAVALUES) |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 179 | $(WORKSPACE)/cord/helm-charts/scripts/wait_for_pods.sh |
| 180 | touch $@ |
| 181 | |
| 182 | $(M)/siab: | $(M)/voltha-running $(M)/mininet $(M)/ponsim-tosca |
| 183 | until http -a karaf:karaf --ignore-stdin --check-status GET http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt; \ |
| 184 | do \ |
| 185 | sleep 5; \ |
| 186 | done |
| 187 | http -a karaf:karaf --ignore-stdin POST http://127.0.0.1:30120/onos/v1/configuration/org.opencord.olt.impl.Olt defaultVlan=65535 |
Andy Bavier | 905ec80 | 2018-10-04 11:08:37 -0700 | [diff] [blame] | 188 | 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" |
| 189 | echo "[passed] VOLTHA is HEALTHY" |
| 190 | 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" |
| 191 | echo "[passed] OLT and ONU are enabled in VOLTHA" |
| 192 | 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" |
| 193 | echo "[passed] VOLTHA logical device and agg switch are available in ONOS" |
| 194 | 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" |
| 195 | echo "[passed] ATT Workflow Driver ServiceInstance is in AWAITING state" |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 196 | touch $@ |
| 197 | echo "SEBA-in-a-Box installation finished!" |
| 198 | |
Andy Bavier | 0144993 | 2018-10-01 16:19:40 -0700 | [diff] [blame] | 199 | run-tests: $(M)/qatests |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 200 | |
Andy Bavier | 0144993 | 2018-10-01 16:19:40 -0700 | [diff] [blame] | 201 | $(M)/qatests-prereqs: |
| 202 | sudo apt install -y python-pip virtualenv |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 203 | touch $@ |
| 204 | |
Andy Bavier | 0144993 | 2018-10-01 16:19:40 -0700 | [diff] [blame] | 205 | $(WORKSPACE)/cord/test/cord-tester: | $(M)/setup |
| 206 | mkdir -p $(WORKSPACE)/cord/test |
| 207 | cd $(WORKSPACE)/cord/test && git clone https://gerrit.opencord.org/cord-tester |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 208 | |
Andy Bavier | 0144993 | 2018-10-01 16:19:40 -0700 | [diff] [blame] | 209 | $(M)/qatests: $(M)/siab $(M)/qatests-prereqs $(WORKSPACE)/cord/test/cord-tester |
| 210 | cd $(WORKSPACE)/cord/test/cord-tester/src/test/cord-api/ && \ |
Andy Bavier | 6ce277e | 2018-10-02 10:29:21 -0700 | [diff] [blame] | 211 | WORKSPACE=$(VIRTUALENV) bash ./setup_venv.sh && \ |
| 212 | source $(VIRTUALENV)/venv-cord-tester/bin/activate && \ |
Andy Bavier | 0144993 | 2018-10-01 16:19:40 -0700 | [diff] [blame] | 213 | cd Tests/WorkflowValidations/ && \ |
Kailash Khalasi | 98dabd0 | 2018-10-19 13:00:12 -0700 | [diff] [blame^] | 214 | pybot -e notready -i $(TESTTAGS) SIAB.robot |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 215 | touch $@ |
| 216 | |
| 217 | remove-chart-milestones: |
| 218 | cd $(M); rm -f kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \ |
| 219 | voltha-running ponsim mininet nem nem-running ponsim-tosca siab |
| 220 | |
| 221 | remove-kube-milestones: |
| 222 | cd $(M); rm -f kubeadm helm-init |
| 223 | |
| 224 | remove-test-milestones: |
Andy Bavier | 0144993 | 2018-10-01 16:19:40 -0700 | [diff] [blame] | 225 | cd $(M); rm -f qatests |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 226 | |
| 227 | teardown-charts: remove-chart-milestones |
| 228 | helm delete --purge $(shell helm ls -q) |
| 229 | |
| 230 | reset-kubeadm: remove-chart-milestones remove-kube-milestones |
Andy Bavier | c3a0269 | 2018-09-26 15:55:23 -0700 | [diff] [blame] | 231 | sudo kubeadm reset -f |
Andy Bavier | 35053b6 | 2018-09-20 13:45:45 -0700 | [diff] [blame] | 232 | sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X |
| 233 | |