blob: 19baa14171b26ee9bf72ee908e89e1140169c52b [file] [log] [blame]
// Copyright 2017-present Open Networking Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
node ("${TestNodeName}") {
def withKind = false
if (params.withKind != null){
withKind = params.withKind
}
timeout (100) {
try {
stage ("Parse deployment configuration file") {
sh returnStdout: true, script: "rm -rf ${configBaseDir} voltha-system-tests kind-voltha"
sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/${configBaseDir}"
sh returnStdout: true, script: "git clone -b ${branch} ${cordRepoUrl}/voltha-system-tests"
sh returnStdout: true, script: "git clone -b master ${cordRepoUrl}/kind-voltha"
if ( params.workFlow == "DT" ) {
deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-DT.yaml"
}
else
{
deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
}
}
stage('Clean up') {
timeout(15) {
sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet');
do
echo "Purging chart: \${hchart}"
helm delete --purge "\${hchart}"
done
"""
timeout(5) {
waitUntil {
helm_deleted = sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
helm ls -q | grep -E -v 'docker-registry|mavenrepo|ponnet' | wc -l
"""
return helm_deleted.toInteger() == 0
}
}
timeout(5) {
waitUntil {
kubectl_deleted = sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf &&
kubectl get pods --all-namespaces --no-headers | grep -E -v 'kube-system|docker-registry|mavenrepo|ponnet' | wc -l
"""
return kubectl_deleted.toInteger() == 0
}
}
timeout(1) {
sh returnStdout: false, script: """
#Remove all while true; do kubectl port-forward ...done; rules
for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | grep "while true"| awk '{print \$1}'`;
do
cat /proc/\$port_fwd_id/cmdline
kill -9 \$port_fwd_id
done
#Remove all kubectl port-forward rules
for port_fwd_id in `ps -ax | grep "port-forward" | grep -E "onos|voltha" | awk '{print \$1}'`;
do
cat /proc/\$port_fwd_id/cmdline
kill -9 \$port_fwd_id
done
"""
}
}
}
stage('Install Voltha') {
timeout(20) {
sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
cd kind-voltha/
if [ "${branch}" != "master" ]; then
cd $WORKSPACE/kind-voltha
source releases/${branch}
else
export EXTRA_HELM_FLAGS='-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml'
fi
# VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
# JENKINS_NODE_COOKIE=dontKillMe ask Jenkins doesn't kill the proces after this job. we want the `while true; do kubectl port-forward` keep alive
if [[ "${workFlow}" == "DT" ]]; then
JENKINS_NODE_COOKIE=dontKillMe NUM_OF_OPENONU=${NumOfOpenOnu} NUM_OF_ONOS=${NumOfOnos} NUM_OF_ATOMIX=${NumOfAtomix} ONOS_SSH_PORT=30115 ONOS_API_PORT=30120 VOLTHA_LOG_LEVEL=DEBUG WITH_SIM_ADAPTERS=n WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no WITH_EAPOL=no WITH_DHCP=no WITH_IGMP=no WITH_RADIUS=no FANCY=0 ./voltha up
else
JENKINS_NODE_COOKIE=dontKillMe NUM_OF_OPENONU=${NumOfOpenOnu} NUM_OF_ONOS=${NumOfOnos} NUM_OF_ATOMIX=${NumOfAtomix} ONOS_SSH_PORT=30115 ONOS_API_PORT=30120 VOLTHA_LOG_LEVEL=DEBUG WITH_SIM_ADAPTERS=n WITH_RADIUS=y WITH_TP=yes DEPLOY_K8S=no INSTALL_KUBECTL=no INSTALL_HELM=no FANCY=0 ./voltha up
fi
kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.image}{'\\n'}" | sort | uniq
kubectl get pods --all-namespaces -o jsonpath="{range .items[*].status.containerStatuses[*]}{.image}{'\\t'}{.imageID}{'\\n'}" | sort | uniq
kubectl get nodes -o wide
kubectl get pods -n voltha -o wide
"""
}
}
if ( withKind && deployment_config.fabric_switches.size() > 0 ) {
stage('OpenFlow port forward for aggregation switch') {
timeout(1) {
sh returnStdout: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
#This uses the default route out, porperly configured is the management
mgmt_address=`ip route get 1 | awk '{print \$NF;exit}'`
JENKINS_NODE_COOKIE=dontkill kubectl port-forward -n default service/onos-onos-classic-hs --address=\$mgmt_address 6653:6653 >> /dev/null 2>&1 &
"""
}
}
}
if ( params.configurePod && params.profile != "Default" ) {
stage('Push Tech-Profile') {
for(int i=0; i < deployment_config.olts.size(); i++) {
def tech_prof_directory = "XGS-PON"
if (deployment_config.olts[i].oltDebVersion.contains("asgvolt64")){
tech_prof_directory = "GPON"
}
timeout(1) {
out_push_tp = sh returnStatus: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json voltha/\$etcd_container:/tmp/flexpod.json
put_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
"""
return out_push_tp == 0
}
timeout(1) {
out_get_tp = sh returnStatus: true, script: """
export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
etcd_container=\$(kubectl get pods -n voltha | grep voltha-etcd-cluster | awk 'NR==1{print \$1}')
get_result=\$(kubectl exec -it \$etcd_container -n voltha -- /bin/sh -c 'ETCDCTL_API=3 etcdctl get --prefix service/voltha/technology_profiles/${tech_prof_directory}/64')
"""
return out_get_tp == 0
}
}
}
}
stage('Push Sadis-config') {
timeout(1) {
sadis_out = sh returnStatus: true, script: """
if [[ "${workFlow}" == "DT" ]]; then
curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis-DT.json
else
curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/voltha-system-tests/tests/data/${configFileName}-sadis.json
fi
"""
return sadis_out == 0
}
}
if ( params.reinstallOlt ) {
stage('Reinstall OLT software') {
for(int i=0; i < deployment_config.olts.size(); i++) {
sh returnStdout: true, script: """
if [ "${branch}" != "master" ]; then
sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${deployment_config.olts[i].oltDebVersion23}"
else
sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} "dpkg --install ${deployment_config.olts[i].oltDebVersion}"
fi
sleep 10
"""
timeout(5) {
waitUntil {
olt_sw_present = sh returnStdout: true, script: """
if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16-2.4"* ]] || [[ "${deployment_config.olts[i].oltDebVersion23}" == *"asfvolt16-2.4"* ]]; then
sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asfvolt16 | wc -l'
else
sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'dpkg --list | grep asgvolt64 | wc -l'
fi
if (${deployment_config.olts[i].fortygig}); then
if [[ "${deployment_config.olts[i].oltDebVersion}" == *"asfvolt16-2.4"* ]] || [[ "${deployment_config.olts[i].oltDebVersion23}" == *"asfvolt16-2.4"* ]]; then
sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000 if=XLAUI" >> /broadcom/qax.soc'
else
sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'echo "port ce128 sp=40000" >> /broadcom/qax.soc'
fi
fi
"""
return olt_sw_present.toInteger() > 0
}
}
}
}
stage('Restart OLT processes') {
for(int i=0; i < deployment_config.olts.size(); i++) {
timeout(5) {
sh returnStdout: true, script: """
ssh-keyscan -H ${deployment_config.olts[i].ip} >> ~/.ssh/known_hosts
sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'reboot' || true
sleep 120
"""
}
timeout(15) {
waitUntil {
devprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep dev_mgmt_daemon | wc -l'"
return devprocess.toInteger() > 0
}
}
timeout(15) {
waitUntil {
openoltprocess = sh returnStdout: true, script: "sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].ip} 'ps -ef | grep openolt | wc -l'"
return openoltprocess.toInteger() > 0
}
}
}
}
}
if ( deployment_config.fabric_switches.size() > 0 ) {
stage('Switch Configurations in ONOS') {
timeout(1) {
netcfg_out = sh returnStatus: true, script: """
curl -sSL --user karaf:karaf -X POST -H Content-Type:application/json http://${deployment_config.nodes[0].ip}:30120/onos/v1/network/configuration --data @$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json
curl -sSL --user karaf:karaf -X POST http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting/active
"""
return netcfg_out == 0
}
timeout(1) {
waitUntil {
sr_active_out = sh returnStatus: true, script: """
ssh-keygen -R [${deployment_config.nodes[0].ip}]:30115
ssh-keyscan -p 30115 -H ${deployment_config.nodes[0].ip} >> ~/.ssh/known_hosts
sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.dhcpl2relay"
sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.aaa"
sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "log:set TRACE org.opencord.olt"
curl -sSL --user karaf:karaf -X GET http://${deployment_config.nodes[0].ip}:30120/onos/v1/applications/org.onosproject.segmentrouting | jq '.state' | grep ACTIVE
sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.flow.impl.FlowRuleManager purgeOnDisconnection false"
sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "cfg set org.onosproject.net.meter.impl.MeterManager purgeOnDisconnection false"
"""
return sr_active_out == 0
}
}
timeout(5) {
for(int i=0; i < deployment_config.hosts.src.size(); i++) {
def aggPort = -1
for(int j=0; j < deployment_config.olts.size(); j++) {
if(deployment_config.olts[j].serial == deployment_config.hosts.src[j].olt){
aggPort = deployment_config.olts[j].aggPort
}
}
if(aggPort == -1){
throw new Exception("Upstream port for the olt is not configured, field aggPort is empty")
}
xconnect_out = sh returnStatus: true, script: """
version=\$(sshpass -p karaf ssh -p 30115 karaf@${deployment_config.nodes[0].ip} "summary" | grep version)
sleep 10
if [[ \$version == *"version=2.2"* ]]; then
curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "endpoints": [${deployment_config.fabric_switches[0].bngPort},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
else
curl -X POST --user karaf:karaf --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"deviceId": "${deployment_config.fabric_switches[0].device_id}", "vlanId": "${deployment_config.hosts.src[i].s_tag}", "ports": [${deployment_config.fabric_switches[0].bngPort},${aggPort}]}' 'http://${deployment_config.nodes[0].ip}:30120/onos/segmentrouting/xconnect'
fi
"""
}
}
}
}
currentBuild.result = 'SUCCESS'
} catch (err) {
currentBuild.result = 'FAILURE'
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
throw err
}
echo "RESULT: ${currentBuild.result}"
}
}