diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e6ded3d4..398147c7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -126,11 +126,8 @@ jobs: - name: Integration tests run: | export KUBECONFIG=$HOME/.kube/config_packet - if [[ "${{ matrix.CNI }}" == "calico-vpp" ]]; then - go test -count 1 -timeout 1h50m -race -v ./tests_${{ matrix.CNI }} -parallel 4 || true - else - go test -count 1 -timeout 1h50m -race -v ./tests_${{ matrix.CNI }} -parallel 4 - fi + go test -count 1 -timeout 50m -race -v ./tests_${{ matrix.CNI }} -run TestRunOVS + false env: ARTIFACTS_DIR: logs working-directory: ${{ github.repository }} diff --git a/scripts/ovs/enable-ovs.sh b/scripts/ovs/enable-ovs.sh new file mode 100755 index 00000000..e2fc5546 --- /dev/null +++ b/scripts/ovs/enable-ovs.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +modprobe openvswitch diff --git a/scripts/ovs/setup-ovs.sh b/scripts/ovs/setup-ovs.sh new file mode 100755 index 00000000..66fc0970 --- /dev/null +++ b/scripts/ovs/setup-ovs.sh @@ -0,0 +1,28 @@ +#!/bin/bash -x +# shellcheck disable=SC2086 + +master_ip="$1" + +worker_ip="$2" + +SSH_OPTS="$3" + +OVS_DIR=$(dirname "$0") + +# wait_pids pid_1 ... pid_n +source scripts/include/wait-pids.sh + +# Create ovs scripts directory on nodes +ssh ${SSH_OPTS} root@${master_ip} mkdir ovs +ssh ${SSH_OPTS} root@${worker_ip} mkdir ovs + +# Enable ovs and wait for scripts to execute +scp ${SSH_OPTS} ${OVS_DIR}/enable-ovs.sh root@${master_ip}:ovs/enable-ovs.sh || exit 1 +scp ${SSH_OPTS} ${OVS_DIR}/enable-ovs.sh root@${worker_ip}:ovs/enable-ovs.sh || exit 2 + +pids="" +ssh ${SSH_OPTS} root@${master_ip} ./ovs/enable-ovs.sh & +pids+=" $!" +ssh ${SSH_OPTS} root@${worker_ip} ./ovs/enable-ovs.sh & +pids+=" $!" +wait_pids "${pids}" "ovs setup failed" || exit 3 diff --git a/scripts/setup-cluster.sh b/scripts/setup-cluster.sh index 64992b73..88b780a8 100755 --- a/scripts/setup-cluster.sh +++ b/scripts/setup-cluster.sh @@ -98,16 +98,24 @@ done ## Setup SR-IOV /bin/bash scripts/sriov/setup-SRIOV.sh "${master_node}" "${master_ip}" "${worker_node}" "${worker_ip}" "${sriov_vlan}" "${enable8021q}" "${SSH_OPTS}" || exit 12 +## Setup ovs +/bin/bash scripts/ovs/setup-ovs.sh "${master_ip}" "${worker_ip}" "${SSH_OPTS}" || exit 13 + +## Setup ovs +if [[ "$CNI" == "calico-vpp" ]]; then # calico + /bin/bash scripts/smartnic/setup-SmartNIC.sh "${master_ip}" "${worker_ip}" "${SSH_OPTS}" "${CALICO_INTERFACE}" || exit 14 +fi + ## Remove master label from the control-plane node to be able to use it as worker node # For some versions of kubernetes you need to use node-role.kubernetes.io/master- -kubectl --kubeconfig=$KUBECONFIG_PACK taint nodes --selector='node-role.kubernetes.io/control-plane' node-role.kubernetes.io/control-plane:NoSchedule- || exit 13 +kubectl --kubeconfig=$KUBECONFIG_PACK taint nodes --selector='node-role.kubernetes.io/control-plane' node-role.kubernetes.io/control-plane:NoSchedule- || exit 15 ## CNI installation if [[ "$CNI" == "default" ]]; then # use calico CNI in case of default - kubectl --kubeconfig=$KUBECONFIG_PACK apply -k scripts/defaultCNI || exit 14 + kubectl --kubeconfig=$KUBECONFIG_PACK apply -k scripts/defaultCNI || exit 16 elif [[ "$CNI" == "calico-vpp" ]]; then # calico-VPP CNI export KUBECONFIG=$KUBECONFIG_PACK - /bin/bash scripts/calico/deploy-calico.sh || exit 15 + /bin/bash scripts/calico/deploy-calico.sh || exit 17 fi ## SPIRE server requires StorageClass diff --git a/scripts/smartnic/enable-SmartNIC.sh b/scripts/smartnic/enable-SmartNIC.sh new file mode 100755 index 00000000..7fb1a172 --- /dev/null +++ b/scripts/smartnic/enable-SmartNIC.sh @@ -0,0 +1,8 @@ +#!/bin/bash -x +# shellcheck disable=SC2086,SC2064 + +set -e + +ls /sys/class/net +ip -details link show +lspci | egrep -i 'network|ethernet' \ No newline at end of file diff --git a/scripts/smartnic/setup-SmartNIC.sh b/scripts/smartnic/setup-SmartNIC.sh new file mode 100755 index 00000000..3dcb7e27 --- /dev/null +++ b/scripts/smartnic/setup-SmartNIC.sh @@ -0,0 +1,48 @@ +#!/bin/bash -x +# shellcheck disable=SC2086 + +set -e + +master_ip="$1" +worker_ip="$2" +SSH_OPTS="$3" +snic="$4" + +function wait_pids() { + pids="$1" + message="$2" + for pid in ${pids}; do + echo "waiting for PID ${pid}" + wait ${pid} + code=$? + if test $code -ne 0; then + echo "${message}: process exited with code $code, aborting..." + return 1 + fi + done + return 0 +} + +SMARTNIC_DIR=$(dirname "$0") + +# Create SmartNIC scripts directory on nodes +ssh ${SSH_OPTS} root@${master_ip} mkdir smartnic +ssh ${SSH_OPTS} root@${worker_ip} mkdir smartnic + + +# Configure SmartNIC on the nodes +scp ${SSH_OPTS} ${SMARTNIC_DIR}/enable-SmartNIC.sh root@${master_ip}:smartnic/enable-SmartNIC.sh || exit 1 +scp ${SSH_OPTS} ${SMARTNIC_DIR}/enable-SmartNIC.sh root@${worker_ip}:smartnic/enable-SmartNIC.sh || exit 2 + +pids="" +ssh ${SSH_OPTS} root@${master_ip} ./smartnic/enable-SmartNIC.sh $snic & +pids+=" $!" +ssh ${SSH_OPTS} root@${worker_ip} ./smartnic/enable-SmartNIC.sh $snic & +pids+=" $!" +wait_pids "${pids}" "SmartNIC setup failed" || exit 3 + +sleep 5 + +# Copy SRIOV config as SmartNIC config +ssh ${SSH_OPTS} root@${master_ip} cp /var/lib/networkservicemesh/sriov.config /var/lib/networkservicemesh/smartnic.config +ssh ${SSH_OPTS} root@${worker_ip} cp /var/lib/networkservicemesh/sriov.config /var/lib/networkservicemesh/smartnic.config \ No newline at end of file diff --git a/tests_calico-vpp/main_test.go b/tests_calico-vpp/main_test.go index 93371ac7..6e1f9eed 100644 --- a/tests_calico-vpp/main_test.go +++ b/tests_calico-vpp/main_test.go @@ -2,6 +2,8 @@ // // Copyright (c) 2023 Cisco and/or its affiliates. // +// Copyright (c) 2024 Nordix and/or its affiliates. +// // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,6 +31,7 @@ import ( "github.com/networkservicemesh/integration-tests/suites/memory" "github.com/networkservicemesh/integration-tests/suites/multiforwarder" "github.com/networkservicemesh/integration-tests/suites/observability" + "github.com/networkservicemesh/integration-tests/suites/ovs" "github.com/networkservicemesh/integration-tests/suites/sriov" ) @@ -67,3 +70,17 @@ func (s *featuresSuite) BeforeTest(suiteName, testName string) { func TestRunFeatureSuiteCalico(t *testing.T) { parallel.Run(t, new(featuresSuite), "TestVl3_basic", "TestVl3_dns", "TestScale_from_zero", "TestVl3_scale_from_zero", "TestSelect_forwarder") } + +type ovsSuite struct { + ovs.Suite +} + +func (s *ovsSuite) BeforeTest(suiteName, testName string) { + if testName == "TestKernel2KernelVLAN" { + s.T().Skip() + } +} + +func TestRunOVS(t *testing.T) { + suite.Run(t, new(ovsSuite)) +} diff --git a/tests_default/main_test.go b/tests_default/main_test.go index 7adce8c7..328332c5 100644 --- a/tests_default/main_test.go +++ b/tests_default/main_test.go @@ -2,6 +2,8 @@ // // Copyright (c) 2023 Cisco and/or its affiliates. // +// Copyright (c) 2024 Nordix and/or its affiliates. +// // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,6 +31,7 @@ import ( "github.com/networkservicemesh/integration-tests/suites/memory" "github.com/networkservicemesh/integration-tests/suites/multiforwarder_vlantag" "github.com/networkservicemesh/integration-tests/suites/observability" + "github.com/networkservicemesh/integration-tests/suites/ovs" "github.com/networkservicemesh/integration-tests/suites/sriov_vlantag" ) @@ -55,3 +58,19 @@ func TestRunObservabilitySuite(t *testing.T) { func TestFeatureSuite(t *testing.T) { parallel.Run(t, new(features.Suite), "TestVl3_basic", "TestVl3_dns", "TestScale_from_zero", "TestVl3_scale_from_zero", "TestSelect_forwarder") } + +type ovsSuite struct { + ovs.Suite +} + +func (s *ovsSuite) BeforeTest(suiteName, testName string) { + switch testName { + case + "TestSmartVF2SmartVF", + "TestKernel2KernelVLAN": + s.T().Skip() + } +} +func TestRunOVS(t *testing.T) { + suite.Run(t, new(ovsSuite)) +}