Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Smartnic config files for ovs forwarder #396

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 3 additions & 0 deletions scripts/ovs/enable-ovs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

modprobe openvswitch
28 changes: 28 additions & 0 deletions scripts/ovs/setup-ovs.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 11 additions & 3 deletions scripts/setup-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions scripts/smartnic/enable-SmartNIC.sh
Original file line number Diff line number Diff line change
@@ -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'
48 changes: 48 additions & 0 deletions scripts/smartnic/setup-SmartNIC.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions tests_calico-vpp/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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"
)

Expand Down Expand Up @@ -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))
}
19 changes: 19 additions & 0 deletions tests_default/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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"
)

Expand All @@ -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))
}
Loading