diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6fb48cb..dc38130 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,13 +26,35 @@ jobs: checkgomod: uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main + make-matrix: + name: make matrix + runs-on: ubuntu-latest + # Map a step output to a job output + outputs: + matrix: ${{ steps.make-matrix.outputs.matrix }} + steps: + - id: make-matrix + run: | + if ${{ startsWith(github.ref_name, 'release/') }}; then + echo "matrix={\"config\":[ \ + {\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"default\"}, \ + {\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"calico-vpp\"}, \ + {\"node_type\":\"c3.large.arm64\",\"CNI\":\"default\"} \ + ]}" >> $GITHUB_OUTPUT + else + echo "matrix={\"config\":[ \ + {\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"default\"}, \ + {\"node_type\":\"n3.xlarge.x86\",\"CNI\":\"calico-vpp\"} \ + ]}" >> $GITHUB_OUTPUT + fi + packet: - name: packet (CNI ${{ matrix.CNI }}) + name: ${{ matrix.config.node_type }} (CNI ${{ matrix.config.CNI }}) runs-on: ubuntu-latest + needs: make-matrix strategy: fail-fast: false - matrix: - CNI: ["default", "calico-vpp"] + matrix: ${{ fromJSON(needs.make-matrix.outputs.matrix) }} steps: - name: Set up /bin permissions run: | @@ -47,20 +69,31 @@ jobs: - name: Set envs run: | - id=${{ matrix.CNI }}-${{ github.run_number }} - if [[ "${{ matrix.CNI }}" == "calico-vpp" ]]; then - id=calico-${{ github.run_number }} + # Set SRIOV_ENABLED + echo SRIOV_ENABLED=true >> $GITHUB_ENV + if [[ "${{ matrix.config.node_type }}" != "n3.xlarge.x86" ]]; then + echo SRIOV_ENABLED=false >> $GITHUB_ENV + fi + + # Set CLUSTER_NAME and SSH_KEY + node_type=${{ matrix.config.node_type }} + id=${node_type:0:2}-${{ github.run_number }} + if [[ "${{ matrix.config.CNI }}" == "calico-vpp" ]]; then + id=c-${id} fi echo CLUSTER_NAME=nsm-ci-${id} >> $GITHUB_ENV echo SSH_KEY=nsm-ssh-${id} >> $GITHUB_ENV + # Checking server availability by metro and node_type - name: Find metro run: | metros_to_check=da,ny - if [[ "${{ matrix.CNI }}" == "calico-vpp" ]]; then + if [[ "${{ matrix.config.CNI }}" == "calico-vpp" ]]; then metros_to_check=at,ch + elif [[ "${{ matrix.config.node_type }}" == "c3.large.arm64" ]]; then + metros_to_check=da,dc fi - METRO=$(metal capacity check -m ${metros_to_check} -P n3.xlarge.x86 -q 2 -o json | jq -r '[.[] | select( .available == true ) | .metro][0]') + METRO=$(metal capacity check -m ${metros_to_check} -P "${{ matrix.config.node_type }}" -q 2 -o json | jq -r '[.[] | select( .available == true ) | .metro][0]') if [ ${METRO} == "null" ]; then exit 1; fi @@ -111,7 +144,7 @@ jobs: - name: Setup cluster uses: nick-fields/retry@v2.8.3 with: - timeout_minutes: 50 + timeout_minutes: 60 max_attempts: 3 command: | cd ${{ github.repository }} @@ -127,17 +160,19 @@ jobs: PROJECT_ID: 383890d0-f5d1-4de1-881a-4d1ede549d18 NODE_OS: ubuntu_20_04 KUBERNETES_VERSION: "v1.27.1" - CNI: ${{ matrix.CNI }} - CONTROLPLANE_NODE_TYPE: "n3.xlarge.x86" - WORKER_NODE_TYPE: "n3.xlarge.x86" + CNI: ${{ matrix.config.CNI }} + CONTROLPLANE_NODE_TYPE: ${{ matrix.config.node_type }} + WORKER_NODE_TYPE: ${{ matrix.config.node_type }} - 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 + if [[ "${{ matrix.config.CNI }}" == "calico-vpp" ]]; then + go test -count 1 -timeout 1h50m -race -v ./test/${{ matrix.config.CNI }} -parallel 4 || true + elif [ "${SRIOV_ENABLED}" == true ]; then + go test -count 1 -timeout 1h50m -race -v ./test/${{ matrix.config.CNI }} -parallel 4 else - go test -count 1 -timeout 1h50m -race -v ./tests_${{ matrix.CNI }} -parallel 4 + go test -count 1 -timeout 1h50m -race -v ./test/${{ matrix.config.CNI }}/main_test.go -parallel 4 fi env: ARTIFACTS_DIR: logs @@ -147,8 +182,8 @@ jobs: uses: actions/upload-artifact@v2 if: ${{ always() }} with: - name: ${{ matrix.CNI }}-logs - path: ${{ github.repository }}/tests_${{ matrix.CNI }}/logs + name: ${{ matrix.config.node_type }}-${{ matrix.config.CNI }}-logs + path: ${{ github.repository }}/test/${{ matrix.config.CNI }}/logs - name: Cleanup if: ${{ always() }} diff --git a/scripts/setup-cluster.sh b/scripts/setup-cluster.sh index a523b83..37b2b44 100755 --- a/scripts/setup-cluster.sh +++ b/scripts/setup-cluster.sh @@ -57,7 +57,7 @@ done # Wait for packet servers to be ready sleep 30s -kubectl wait --timeout=30m --for=condition=Ready=true packetmachine -l cluster.x-k8s.io/cluster-name=${CLUSTER_NAME} +kubectl wait --timeout=50m --for=condition=Ready=true packetmachine -l cluster.x-k8s.io/cluster-name=${CLUSTER_NAME} result=$? if [ $result -ne 0 ]; then clusterctl describe cluster ${CLUSTER_NAME} --echo @@ -96,7 +96,9 @@ for i in {1..30}; do 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 +if [[ "$SRIOV_ENABLED" == true ]]; then + /bin/bash scripts/sriov/setup-SRIOV.sh "${master_node}" "${master_ip}" "${worker_node}" "${worker_ip}" "${sriov_vlan}" "${enable8021q}" "${SSH_OPTS}" || exit 12 +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- diff --git a/tests_calico-vpp/main_test.go b/test/calico-vpp/main_test.go similarity index 96% rename from tests_calico-vpp/main_test.go rename to test/calico-vpp/main_test.go index 93371ac..4606493 100644 --- a/tests_calico-vpp/main_test.go +++ b/test/calico-vpp/main_test.go @@ -1,6 +1,6 @@ // Copyright (c) 2020-2022 Doc.ai and/or its affiliates. // -// Copyright (c) 2023 Cisco and/or its affiliates. +// Copyright (c) 2023-2024 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,7 +16,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main_test +package calico_vpp_test import ( "testing" diff --git a/test/default/feature_test.go b/test/default/feature_test.go new file mode 100644 index 0000000..1b3bda9 --- /dev/null +++ b/test/default/feature_test.go @@ -0,0 +1,28 @@ +// Copyright (c) 2024 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// 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. + +package default_test + +import ( + "testing" + + "github.com/networkservicemesh/integration-tests/extensions/parallel" + "github.com/networkservicemesh/integration-tests/suites/features" +) + +func TestFeatureSuite(t *testing.T) { + parallel.Run(t, new(features.Suite), "TestVl3_ipv6", "TestVl3_dns", "TestVl3_lb", "TestVl3_scale_from_zero", "TestScale_from_zero", "TestSelect_forwarder") +} diff --git a/test/default/heal_test.go b/test/default/heal_test.go new file mode 100644 index 0000000..dde40bf --- /dev/null +++ b/test/default/heal_test.go @@ -0,0 +1,29 @@ +// Copyright (c) 2024 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// 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. + +package default_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/networkservicemesh/integration-tests/suites/heal" +) + +func TestHeal(t *testing.T) { + suite.Run(t, new(heal.Suite)) +} diff --git a/test/default/main_test.go b/test/default/main_test.go new file mode 100644 index 0000000..c9d22d5 --- /dev/null +++ b/test/default/main_test.go @@ -0,0 +1,40 @@ +// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. +// +// Copyright (c) 2023-2024 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// 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. + +package default_test + +import ( + "testing" + + "github.com/networkservicemesh/integration-tests/extensions/parallel" + "github.com/networkservicemesh/integration-tests/suites/basic" + "github.com/networkservicemesh/integration-tests/suites/ipsec_mechanism" + "github.com/networkservicemesh/integration-tests/suites/memory" +) + +func TestBasic(t *testing.T) { + parallel.Run(t, new(basic.Suite)) +} + +func TestMemory(t *testing.T) { + parallel.Run(t, new(memory.Suite)) +} + +func TestIPSec(t *testing.T) { + parallel.Run(t, new(ipsec_mechanism.Suite)) +} diff --git a/test/default/observ_test.go b/test/default/observ_test.go new file mode 100644 index 0000000..3f00784 --- /dev/null +++ b/test/default/observ_test.go @@ -0,0 +1,29 @@ +// Copyright (c) 2024 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// 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. + +package default_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/networkservicemesh/integration-tests/suites/observability" +) + +func TestRunObservabilitySuite(t *testing.T) { + suite.Run(t, new(observability.Suite)) +} diff --git a/tests_default/main_test.go b/test/default/sriov_test.go similarity index 53% rename from tests_default/main_test.go rename to test/default/sriov_test.go index 7adce8c..387902c 100644 --- a/tests_default/main_test.go +++ b/test/default/sriov_test.go @@ -1,6 +1,4 @@ -// Copyright (c) 2020-2022 Doc.ai and/or its affiliates. -// -// Copyright (c) 2023 Cisco and/or its affiliates. +// Copyright (c) 2024 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -16,26 +14,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main_test +package default_test import ( "testing" "github.com/stretchr/testify/suite" - "github.com/networkservicemesh/integration-tests/extensions/parallel" - "github.com/networkservicemesh/integration-tests/suites/features" - "github.com/networkservicemesh/integration-tests/suites/heal" - "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/sriov_vlantag" ) -func TestMemory(t *testing.T) { - parallel.Run(t, new(memory.Suite)) -} - func TestSRIOV_VlanTag(t *testing.T) { suite.Run(t, new(sriov_vlantag.Suite)) } @@ -43,15 +32,3 @@ func TestSRIOV_VlanTag(t *testing.T) { func TestMultiForwarder_VlanTag(t *testing.T) { suite.Run(t, new(multiforwarder_vlantag.Suite)) } - -func TestHeal(t *testing.T) { - suite.Run(t, new(heal.Suite)) -} - -func TestRunObservabilitySuite(t *testing.T) { - suite.Run(t, new(observability.Suite)) -} - -func TestFeatureSuite(t *testing.T) { - parallel.Run(t, new(features.Suite), "TestVl3_basic", "TestVl3_dns", "TestScale_from_zero", "TestVl3_scale_from_zero", "TestSelect_forwarder") -}