// 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
    def VolthaEtcdPort = '2379'
    if (params.withKind != null){
        withKind = params.withKind
    }
    if (params.VolthaEtcdPort != null){
        VolthaEtcdPort = params.VolthaEtcdPort
    }
    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 if ( params.workFlow == "TT" )
                {
                    deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}-TT.yaml"
                }
                else
                {
                    deployment_config = readYaml file: "${configBaseDir}/${configDeploymentDir}/${configFileName}.yaml"
                }
            }
            stage('Clean up') {
                timeout(15) {
                    sh returnStdout: true, script: """
                    echo "cleaning up"
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    HELM_MAJOR=\$(helm version --client --short | sed -E -e 's/^.*v([0-9]+)\\.[0-9]+\\.[0-9]+.*\$/\\1/')
                    for hchart in \$(helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle');
                    do
                        echo "Purging chart: \${hchart}"
                        if [ \$HELM_MAJOR -le 2 ]; then
                            helm delete --purge "\${hchart}"
                        else
                            helm uninstall "\${hchart}"
                        fi
                    done
                    if [ \$HELM_MAJOR -gt 2 ]; then
                        for hchart in \$(helm list -q -n voltha | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle');
                        do
                            echo "Purging chart: \${hchart}"
                            if [ \$HELM_MAJOR -le 2 ]; then
                                helm delete --purge "\${hchart}"
                            else
                                helm uninstall -n voltha "\${hchart}"
                            fi
                        done
                    fi
                    """
                    timeout(5) {
                        waitUntil {
                            helm_deleted = sh returnStdout: true, script: """

                            export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                            HELM_MAJOR=\$(helm version --client --short | sed -E -e 's/^.*v([0-9]+)\\.[0-9]+\\.[0-9]+.*\$/\\1/')

                            if [ \$HELM_MAJOR -le 2 ]; then
                                helm list -q | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle' | wc -l
                            else
                                helm list -q --all-namespaces | grep -E -v 'docker-registry|mavenrepo|ponnet|local-path-storage|cattle' | wc -l
                            fi
                            """
                            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|local-path-storage|cattle' | 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/
                    export EXTRA_HELM_FLAGS=""
                    if [ "${branch}" != "master" ]; then
                        cd $WORKSPACE/kind-voltha
                        # The releases/ file also specifies EXTRA_HELM_FLAGS
                        source releases/${branch}
                    fi
                    # Make sure that the EXTRA_HELM_FLAGS from the releases/ file appear at the end to override earlier values
                    export EXTRA_HELM_FLAGS="-f $WORKSPACE/${configBaseDir}/${configKubernetesDir}/voltha/${configFileName}.yml \$EXTRA_HELM_FLAGS"

                    # 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
                    export JENKINS_NODE_COOKIE=dontKillMe
                    export NUM_OF_OPENONU=${NumOfOpenOnu}
                    export NUM_OF_ONOS=${NumOfOnos}
                    export NUM_OF_ATOMIX=${NumOfAtomix}
                    # VOL-2194 ONOS SSH and REST ports hardcoded to 30115/30120 in tests
                    export ONOS_SSH_PORT=30115
                    export ONOS_API_PORT=30120
                    export VOLTHA_LOG_LEVEL=DEBUG
                    export WITH_SIM_ADAPTERS=n
                    export DEPLOY_K8S=no
                    export INSTALL_KUBECTL=no
                    export INSTALL_HELM=no
                    export WITH_RADIUS=yes 
                    export FANCY=0
                    # VOL-3162 Forwaring port 2379 does not work on ONF demo pod
                    export VOLTHA_ETCD_PORT=${VolthaEtcdPort}

                    if [[ "${workFlow}" == "DT" ]]; then
                       WITH_EAPOL=no WITH_DHCP=no WITH_IGMP=no WITH_RADIUS=no ./voltha up
                    elif [[  "${workFlow}" == "TT" ]]; then
                       WITH_EAPOL=no WITH_DHCP=no WITH_INCREMENTAL_EVTO_UPDATE=yes WITH_IGMP=yes WITH_RADIUS=no ./voltha up
                    else
                       ./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 | grep etcd | awk 'NR==1{print \$1}')
                            if [[ "${workFlow}" == "TT" ]]; then
                               kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-HSIA.json \$etcd_container:/tmp/hsia.json
                               put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/hsia.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
                               kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-VoIP.json \$etcd_container:/tmp/voip.json
                               put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/voip.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/65')
                               kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-TT-MCAST.json \$etcd_container:/tmp/mcast.json
                               put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/mcast.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/66')
                            else
                               kubectl cp $WORKSPACE/voltha-system-tests/tests/data/TechProfile-${profile}.json \$etcd_container:/tmp/flexpod.json
                               put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/flexpod.json | ETCDCTL_API=3 etcdctl put service/voltha/technology_profiles/${tech_prof_directory}/64')
                            fi
           
                            """
                            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 | grep etcd | awk 'NR==1{print \$1}')
                            get_result=\$(kubectl exec -it \$etcd_container -- /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: """
                    export KUBECONFIG=$WORKSPACE/${configBaseDir}/${configKubernetesDir}/${configFileName}.conf
                    etcd_container=\$(kubectl get pods | grep etcd | awk 'NR==1{print \$1}')
                    kubectl cp $WORKSPACE/voltha-system-tests/tests/data/MIB_Alpha.json \$etcd_container:/tmp/MIB_Alpha.json
                    put_result=\$(kubectl exec -it \$etcd_container -- /bin/sh -c 'cat /tmp/MIB_Alpha.json | ETCDCTL_API=3 etcdctl put service/voltha/omci_mibs/templates/BRCM/BVM4K00BRA0915-0083/5023_020O02414')
                    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
                    elif [[ "${workFlow}" == "TT" ]]; 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-TT.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} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; 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) {
                        def netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch.json"
                        if (params.inBandManagement){
                             netcfg = "$WORKSPACE/${configBaseDir}/${configToscaDir}/voltha/${configFileName}-onos-netcfg-switch-inband.json"
                        }
                        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 @${netcfg}
                        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: """
                            sleep 30
                            version=\$(sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -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
                            """
                        }
                    }
                }
            }
            if ( params.inBandManagement ) {
                stage('Reboot OLT') {
                    for(int i=0; i < deployment_config.olts.size(); i++) {
                        timeout(10) {
                            sh returnStdout: true, script: """
                            ssh-keyscan -H ${deployment_config.olts[i].sship} >> ~/.ssh/known_hosts
                            sshpass -p ${deployment_config.olts[i].pass} ssh -l ${deployment_config.olts[i].user} ${deployment_config.olts[i].sship} 'rm -f /var/log/openolt.log; rm -f /var/log/dev_mgmt_daemon.log; rm -f /var/log/startup.log; reboot' || true
                            sleep 360
                            """
                        }
                        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].sship} '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].sship} 'ps -ef | grep openolt | wc -l'"
                                return openoltprocess.toInteger() > 0
                            }
                        }
                    }
                }
            }

            currentBuild.result = 'SUCCESS'
        } catch (err) {
            currentBuild.result = 'FAILURE'
            step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
            throw err
        }
        echo "RESULT: ${currentBuild.result}"
    }
}
