Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | SHELL := /bin/bash |
| 16 | BUILD ?= /tmp |
| 17 | M ?= $(BUILD)/milestones |
| 18 | MYDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) |
| 19 | |
| 20 | HELM_VERSION ?= "2.10.0" |
| 21 | HELM_SHA256SUM ?= "0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe" |
| 22 | HELM_PLATFORM ?= "linux-amd64" |
| 23 | |
| 24 | KAFKA_CHART_VERSION ?= 0.8.8 |
| 25 | |
| 26 | /all: $(M)/voltha_ponsim_running |
| 27 | |
| 28 | $(M)/setup: |
| 29 | echo "MYDIR = ${MYDIR}" |
| 30 | mkdir -p $(M) |
| 31 | sudo apt update |
| 32 | sudo apt install -y httpie jq software-properties-common |
| 33 | sudo swapoff -a |
| 34 | touch $@ |
| 35 | |
| 36 | /usr/bin/docker: | $(M)/setup |
| 37 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88 |
| 38 | sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(shell lsb_release -cs) stable" |
| 39 | sudo apt update |
| 40 | sudo apt install -y "docker-ce=17.06*" |
| 41 | |
| 42 | /usr/bin/kubeadm: | $(M)/setup /usr/bin/docker |
| 43 | curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - |
| 44 | echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /tmp/kubernetes.list |
| 45 | sudo cp /tmp/kubernetes.list /etc/apt/sources.list.d/kubernetes.list |
| 46 | sudo apt update |
| 47 | sudo apt install -y "kubeadm=1.11.3-*" "kubelet=1.11.3-*" "kubectl=1.11.3-*" |
| 48 | |
| 49 | /usr/local/bin/helm: |
| 50 | curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz" |
| 51 | echo "${HELM_SHA256SUM} /tmp/helm.tgz" | sha256sum -c - |
| 52 | cd /tmp; tar -xzvf helm.tgz; sudo mv ${HELM_PLATFORM}/helm /usr/local/bin/helm |
| 53 | sudo chmod a+x /usr/local/bin/helm |
| 54 | rm -rf /tmp/helm.tgz /tmp/${HELM_PLATFORM} |
| 55 | |
| 56 | $(M)/kubeadm: | $(M)/setup /usr/bin/kubeadm |
| 57 | sudo kubeadm init --pod-network-cidr=192.168.0.0/16 |
| 58 | mkdir -p $(HOME)/.kube |
| 59 | sudo cp -f /etc/kubernetes/admin.conf $(HOME)/.kube/config |
| 60 | sudo chown $(id -u):$(id -g) $(HOME)/.kube/config |
| 61 | kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml |
| 62 | kubectl taint nodes --all node-role.kubernetes.io/master- |
| 63 | touch $@ |
| 64 | |
| 65 | $(M)/helm-init: | $(M)/kubeadm /usr/local/bin/helm |
| 66 | kubectl create serviceaccount --namespace kube-system tiller |
| 67 | kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller |
| 68 | helm init --service-account tiller |
| 69 | until helm ls >& /dev/null; \ |
| 70 | do \ |
| 71 | echo "Waiting for Helm to be ready"; \ |
| 72 | sleep 5; \ |
| 73 | done |
| 74 | helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/ |
| 75 | touch $@ |
| 76 | |
| 77 | $(HOME)/cord/helm-charts: | $(M)/setup |
| 78 | mkdir -p $(HOME)/cord |
| 79 | cd $(HOME)/cord; git clone https://gerrit.opencord.org/helm-charts |
| 80 | |
| 81 | $(M)/kafka: | $(HOME)/cord/helm-charts $(M)/helm-init |
| 82 | cd $(HOME)/cord/helm-charts && \ |
| 83 | helm upgrade --install cord-kafka --version $(KAFKA_CHART_VERSION) -f examples/kafka-single.yaml incubator/kafka |
| 84 | touch $@ |
| 85 | |
| 86 | $(M)/kafka-running: | $(M)/kafka |
| 87 | kubectl wait pod/cord-kafka-0 --for condition=Ready --timeout=180s |
| 88 | touch $@ |
| 89 | |
| 90 | $(M)/onos: | $(M)/kafka-running |
Gilles Depatie | 53d7b77 | 2018-11-09 14:33:35 -0500 | [diff] [blame] | 91 | cd $(HOME)/cord/helm-charts; helm upgrade --install onos onos -f configs/onos.yaml -f configs/seba-ponsim.yaml --set images.onos.repository=voltha-onos,images.onos.tag=latest,images.onos.pullPolicy=Never |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 92 | touch $@ |
| 93 | |
| 94 | $(M)/voltha: | $(M)/kafka-running $(M)/onos |
| 95 | cd $(HOME)/cord/helm-charts; helm dep up voltha |
Gilles Depatie | 53d7b77 | 2018-11-09 14:33:35 -0500 | [diff] [blame] | 96 | cd $(HOME)/cord/helm-charts; helm upgrade --install voltha voltha -f configs/seba-ponsim.yaml --set images.vcore.repository=voltha-voltha,images.vcore.tag=latest,images.vcore.pullPolicy=Never,images.envoy_for_etcd.repository=voltha-envoy,images.envoy_for_etcd.tag=latest,images.envoy_for_etcd.pullPolicy=Never,images.netconf.repository=voltha-netconf,images.netconf.tag=latest,images.netconf.pullPolicy=Never,images.ofagent.repository=voltha-ofagent,images.ofagent.tag=latest,images.ofagent.pullPolicy=Never,images.vcli.repository=voltha-cli,images.vcli.tag=latest,images.vcli.pullPolicy=Never,etcd-operator.customResources.createEtcdClusterCRD=false |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 97 | touch $@ |
| 98 | |
| 99 | $(M)/etcd-operator-ready: | $(M)/voltha |
| 100 | until kubectl api-versions | grep etcd.database.coreos.com/v1beta2; \ |
| 101 | do \ |
| 102 | echo "Waiting for etcd.database.coreos.com/v1beta2 to be available"; \ |
| 103 | sleep 5; \ |
| 104 | done |
| 105 | until kubectl api-resources | grep EtcdCluster; \ |
| 106 | do \ |
| 107 | echo "Waiting for EtcdCluster API resource to be available"; \ |
| 108 | sleep 5; \ |
| 109 | done |
| 110 | touch $@ |
| 111 | |
| 112 | $(M)/etcd-cluster: | $(M)/etcd-operator-ready |
Gilles Depatie | 53d7b77 | 2018-11-09 14:33:35 -0500 | [diff] [blame] | 113 | cd $(HOME)/cord/helm-charts; helm upgrade --install voltha voltha -f configs/seba-ponsim.yaml --set images.vcore.repository=voltha-voltha,images.vcore.tag=latest,images.vcore.pullPolicy=Never,images.envoy_for_etcd.repository=voltha-envoy,images.envoy_for_etcd.tag=latest,images.envoy_for_etcd.pullPolicy=Never,images.netconf.repository=voltha-netconf,images.netconf.tag=latest,images.netconf.pullPolicy=Never,images.ofagent.repository=voltha-ofagent,images.ofagent.tag=latest,images.ofagent.pullPolicy=Never,images.vcli.repository=voltha-cli,images.vcli.tag=latest,images.vcli.pullPolicy=Never,etcd-operator.customResources.createEtcdClusterCRD=true |
Kailash | e0dbb45 | 2018-11-13 10:56:30 -0800 | [diff] [blame] | 114 | 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" |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 115 | touch $@ |
| 116 | |
| 117 | $(M)/voltha-running: | $(M)/etcd-cluster |
| 118 | $(HOME)/cord/helm-charts/scripts/wait_for_pods.sh voltha |
| 119 | touch $@ |
| 120 | |
| 121 | $(M)/ponsim: | $(M)/voltha-running |
| 122 | cd $(HOME)/cord/helm-charts; helm upgrade --install ponnet ponnet |
| 123 | $(HOME)/cord/helm-charts/scripts/wait_for_pods.sh kube-system |
Gilles Depatie | 53d7b77 | 2018-11-09 14:33:35 -0500 | [diff] [blame] | 124 | cd $(HOME)/cord/helm-charts; helm upgrade --install ponsimv2 ponsimv2 -f configs/seba-ponsim.yaml --set images.olt.repository=voltha-ponsim,images.olt.tag=latest,images.olt.pullPolicy=Never,images.onu.repository=voltha-ponsim,images.onu.tag=latest,images.onu.pullPolicy=Never,images.rg.repository=voltha-tester,images.rg.tag=latest,images.rg.pullPolicy=Never |
Gilles Depatie | 84cb1e7 | 2018-10-26 12:41:33 -0400 | [diff] [blame] | 125 | touch $@ |
| 126 | |
| 127 | $(M)/pon0_fwd: | $(M)/ponsim |
| 128 | echo 8 > /tmp/pon0_group_fwd_mask |
| 129 | until sudo cp /tmp/pon0_group_fwd_mask /sys/class/net/pon0/bridge/group_fwd_mask; \ |
| 130 | do \ |
| 131 | echo "waiting for pon0..."; \ |
| 132 | sleep 5; \ |
| 133 | done |
| 134 | rm /tmp/pon0_group_fwd_mask |
| 135 | touch $@ |
| 136 | |
| 137 | $(M)/voltha_ponsim_running: | $(M)/pon0_fwd |
| 138 | $(HOME)/cord/helm-charts/scripts/wait_for_pods.sh |
| 139 | touch $@ |
| 140 | echo "Voltha Test Framework Ready!" |
| 141 | |
| 142 | $(M)/authenticate: $(M)/voltha_ponsim_running |
| 143 | timeout 60s 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" |
| 144 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- wpa_supplicant -i eth0 -Dwired -c /etc/wpa_supplicant/wpa_supplicant.conf -B |
| 145 | timeout 60s 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 APPROVED; do echo 'waiting for att-workflow-driver to be in APPROVED state'; sleep 5; done" |
| 146 | touch $@ |
| 147 | |
| 148 | $(M)/dhclient: $(M)/authenticate |
| 149 | sudo iptables -P FORWARD ACCEPT |
| 150 | timeout 60s bash -c "until http -a admin@opencord.org:letmein GET http://127.0.0.1:30001/xosapi/v1/fabric-crossconnect/fabriccrossconnectserviceinstances |jq '.items[0].backend_status'|grep OK; do echo 'waiting for fabric-crossconnect to be synchronized';sleep 5; done" |
| 151 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- dhclient |
| 152 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- dhclient -r |
| 153 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- dhclient |
| 154 | touch $@ |
| 155 | |
| 156 | $(M)/pingtest: $(M)/dhclient |
| 157 | kubectl -n voltha exec $(shell kubectl -n voltha get pod|grep "^rg-"|cut -d' ' -f1) -- ping -c 3 172.18.0.10 |
| 158 | touch $@ |
| 159 | |
| 160 | run-tests: $(M)/pingtest |
| 161 | |
| 162 | remove-chart-milestones: |
| 163 | cd $(M); sudo rm -f setup kafka kafka-running onos voltha etcd-operator-ready etcd-cluster \ |
| 164 | pon0_fwd voltha-running ponsim voltha_ponsim_running |
| 165 | remove-kube-milestones: |
| 166 | cd $(M); sudo rm -f kubeadm helm-init |
| 167 | |
| 168 | remove-test-milestones: |
| 169 | cd $(M); sudo rm -f authenticate dhclient pingtest |
| 170 | |
| 171 | teardown-charts: remove-chart-milestones |
| 172 | helm delete --purge $(shell helm ls -q) |
| 173 | |
| 174 | reset-kubeadm: remove-chart-milestones remove-kube-milestones |
| 175 | sudo kubeadm reset -f |
| 176 | sudo iptables -F && sudo iptables -t nat -F && sudo iptables -t mangle -F && sudo iptables -X |
| 177 | |