From fa677a39771ad4630b6a1907ae7d58e81f5dc840 Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Mon, 21 Mar 2022 10:29:01 +0700 Subject: [PATCH 1/2] Add Calico tests Signed-off-by: Artem Glazychev --- .github/workflows/ci.yaml | 62 ++++++++++++++++++++++++++++- calico/kustomization.yaml | 9 +++++ calico/patch.yaml | 19 +++++++++ calico_test.go | 46 +++++++++++++++++++++ cluster-config-calico.yaml | 10 +++++ doc.go | 17 ++++++++ interdomain_test.go | 33 +++++++++++++++ entry_point_test.go => main_test.go | 21 +++++----- 8 files changed, 204 insertions(+), 13 deletions(-) create mode 100644 calico/kustomization.yaml create mode 100644 calico/patch.yaml create mode 100644 calico_test.go create mode 100644 cluster-config-calico.yaml create mode 100644 doc.go create mode 100644 interdomain_test.go rename entry_point_test.go => main_test.go (75%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7668dc27e..cf8490714 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -106,7 +106,7 @@ jobs: working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Integration tests run: | - go test -count 1 -timeout 1h20m -race -v -run Single + go test -count 1 -timeout 1h20m -race -v -tags=main_test env: ARTIFACTS_DIR: ${{ matrix.image }}-logs/${{ matrix.image }} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} @@ -116,6 +116,64 @@ jobs: with: name: Containers logs path: ${{ github.workspace }}/src/github.com/${{ github.repository }}/${{ matrix.image }}-logs + calico-kind: + runs-on: ubuntu-latest + env: + KUBERNETES_VERSION: ${{ secrets.NSM_KUBERNETES_VERSION }} + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.9.0 + with: + access_token: ${{ github.token }} + - uses: actions/setup-go@v1 + with: + go-version: 1.16 + github-token: ${{ github.token }} + - name: Set go env + run: | + echo GOPATH=$GITHUB_WORKSPACE >> $GITHUB_ENV + echo GO111MODULE=on >> $GITHUB_ENV + echo $GITHUB_WORKSPACE/bin >> $GITHUB_PATH + - name: Set kubernetes version + run: | + if [[ $KUBERNETES_VERSION=="" ]]; then + echo "KUBERNETES_VERSION=v1.22.1" >> $GITHUB_ENV + fi + - uses: actions/checkout@v2 + with: + path: ${{ github.workspace }}/src/github.com/${{ github.repository }} + - uses: engineerd/setup-kind@v0.5.0 + with: + config: src/github.com/${{ github.repository }}/cluster-config-calico.yaml + version: v0.11.1 + image: kindest/node:${{ env.KUBERNETES_VERSION }} + wait: 0s + - name: Setup external CNI plugin + run: | + kubectl apply -f https://projectcalico.docs.tigera.io/v3.22/manifests/tigera-operator.yaml + kubectl apply -f https://raw.githubusercontent.com/projectcalico/vpp-dataplane/master/yaml/calico/installation-default.yaml + kubectl apply -k ${{ github.workspace }}/src/github.com/${{ github.repository }}/calico + kubectl rollout status -n calico-vpp-dataplane ds/calico-vpp-node --timeout=5m + - name: Check kind cluster + run: | + kubectl version + kubectl cluster-info + kubectl get pods -n kube-system + echo "current-context:" $(kubectl config current-context) + echo "environment-kubeconfig:" ${KUBECONFIG} + working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} + - name: Integration tests + run: | + go test -count 1 -timeout 1h20m -race -v -tags=calico_test + env: + ARTIFACTS_DIR: calico-logs/${{ env.KUBERNETES_VERSION }} + working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} + - name: Upload artifacts + if: ${{ success() || failure() || cancelled() }} + uses: actions/upload-artifact@v2 + with: + name: Containers logs + path: ${{ github.workspace }}/src/github.com/${{ github.repository }}/calico-logs interdomain-kind: runs-on: ubuntu-latest env: @@ -154,7 +212,7 @@ jobs: working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Interdomain tests run: | - go test -count 1 -timeout 1h -race -v -run Interdomain + go test -count 1 -timeout 1h -race -v -tags=interdomain_test env: ARTIFACTS_DIR: interdomain-logs working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} diff --git a/calico/kustomization.yaml b/calico/kustomization.yaml new file mode 100644 index 000000000..b27c2f55b --- /dev/null +++ b/calico/kustomization.yaml @@ -0,0 +1,9 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - https://raw.githubusercontent.com/projectcalico/vpp-dataplane/master/yaml/generated/calico-vpp-kind.yaml + +patchesStrategicMerge: + - patch.yaml diff --git a/calico/patch.yaml b/calico/patch.yaml new file mode 100644 index 000000000..798e87f73 --- /dev/null +++ b/calico/patch.yaml @@ -0,0 +1,19 @@ +--- +# For our purposes it is sufficient to use fewer resources. Using default values can lead to lack of resources. +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: calico-vpp-node + namespace: calico-vpp-dataplane +spec: + template: + spec: + containers: + - name: agent + resources: + requests: + cpu: 150m + - name: vpp + resources: + requests: + cpu: 250m diff --git a/calico_test.go b/calico_test.go new file mode 100644 index 000000000..2cd776c8a --- /dev/null +++ b/calico_test.go @@ -0,0 +1,46 @@ +// Copyright (c) 2022 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. + +// +build calico_test + +package main + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/networkservicemesh/integration-tests/suites/basic" + "github.com/networkservicemesh/integration-tests/suites/heal" + "github.com/networkservicemesh/integration-tests/suites/memory" + "github.com/networkservicemesh/integration-tests/suites/observability" +) + +func TestRunHealSuite(t *testing.T) { + suite.Run(t, new(heal.Suite)) +} + +func TestRunBasicSuite(t *testing.T) { + suite.Run(t, new(basic.Suite)) +} + +func TestRunMemorySuite(t *testing.T) { + suite.Run(t, new(memory.Suite)) +} + +func TestRunObservabilitySuite(t *testing.T) { + suite.Run(t, new(observability.Suite)) +} diff --git a/cluster-config-calico.yaml b/cluster-config-calico.yaml new file mode 100644 index 000000000..b912dd6b5 --- /dev/null +++ b/cluster-config-calico.yaml @@ -0,0 +1,10 @@ +--- +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + - role: worker + - role: worker +networking: + disableDefaultCNI: true + ipFamily: dual diff --git a/doc.go b/doc.go new file mode 100644 index 000000000..6a44c4689 --- /dev/null +++ b/doc.go @@ -0,0 +1,17 @@ +// Copyright (c) 2022 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 main diff --git a/interdomain_test.go b/interdomain_test.go new file mode 100644 index 000000000..00318b14f --- /dev/null +++ b/interdomain_test.go @@ -0,0 +1,33 @@ +// Copyright (c) 2021-2022 Doc.ai and/or its affiliates. +// +// Copyright (c) 2022 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. + +// +build interdomain_test + +package main + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/networkservicemesh/integration-tests/suites/interdomain" +) + +func TestRunInterdomainSuite(t *testing.T) { + suite.Run(t, new(interdomain.Suite)) +} diff --git a/entry_point_test.go b/main_test.go similarity index 75% rename from entry_point_test.go rename to main_test.go index 5e1841d20..3f1b7bb93 100644 --- a/entry_point_test.go +++ b/main_test.go @@ -1,5 +1,7 @@ // Copyright (c) 2021-2022 Doc.ai and/or its affiliates. // +// Copyright (c) 2022 Cisco and/or its affiliates. +// // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +16,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package test +// +build main_test + +package main import ( "testing" @@ -24,31 +28,26 @@ import ( "github.com/networkservicemesh/integration-tests/suites/basic" "github.com/networkservicemesh/integration-tests/suites/features" "github.com/networkservicemesh/integration-tests/suites/heal" - "github.com/networkservicemesh/integration-tests/suites/interdomain" "github.com/networkservicemesh/integration-tests/suites/memory" "github.com/networkservicemesh/integration-tests/suites/observability" ) -func TestRunHealSuiteSingle(t *testing.T) { +func TestRunHealSuite(t *testing.T) { suite.Run(t, new(heal.Suite)) } -func TestRunFeatureSuiteSingle(t *testing.T) { +func TestRunFeatureSuite(t *testing.T) { suite.Run(t, new(features.Suite)) } -func TestRunBasicSuiteSingle(t *testing.T) { +func TestRunBasicSuite(t *testing.T) { suite.Run(t, new(basic.Suite)) } -func TestRunMemorySuiteSingle(t *testing.T) { +func TestRunMemorySuite(t *testing.T) { suite.Run(t, new(memory.Suite)) } -func TestRunObservabilitySuiteSingle(t *testing.T) { +func TestRunObservabilitySuite(t *testing.T) { suite.Run(t, new(observability.Suite)) } - -func TestRunInterdomainSuite(t *testing.T) { - suite.Run(t, new(interdomain.Suite)) -} From 58f0f7ed2607b99562363ac95c6b324f5d4413fb Mon Sep 17 00:00:00 2001 From: Artem Glazychev Date: Mon, 21 Mar 2022 21:17:04 +0700 Subject: [PATCH 2/2] Apply comments Signed-off-by: Artem Glazychev --- .github/workflows/ci.yaml | 8 ++++---- calico_test.go | 10 ++++------ doc.go | 17 ----------------- interdomain_test.go | 2 -- main_test.go | 12 +++++------- 5 files changed, 13 insertions(+), 36 deletions(-) delete mode 100644 doc.go diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cf8490714..5c71627ba 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -106,7 +106,7 @@ jobs: working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Integration tests run: | - go test -count 1 -timeout 1h20m -race -v -tags=main_test + go test -count 1 -timeout 1h20m -race -v -run Single env: ARTIFACTS_DIR: ${{ matrix.image }}-logs/${{ matrix.image }} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} @@ -158,13 +158,13 @@ jobs: run: | kubectl version kubectl cluster-info - kubectl get pods -n kube-system + kubectl get pods --all-namespaces echo "current-context:" $(kubectl config current-context) echo "environment-kubeconfig:" ${KUBECONFIG} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Integration tests run: | - go test -count 1 -timeout 1h20m -race -v -tags=calico_test + go test -count 1 -timeout 1h20m -race -v -run Calico env: ARTIFACTS_DIR: calico-logs/${{ env.KUBERNETES_VERSION }} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} @@ -212,7 +212,7 @@ jobs: working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Interdomain tests run: | - go test -count 1 -timeout 1h -race -v -tags=interdomain_test + go test -count 1 -timeout 1h -race -v -run Interdomain env: ARTIFACTS_DIR: interdomain-logs working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} diff --git a/calico_test.go b/calico_test.go index 2cd776c8a..91536fd23 100644 --- a/calico_test.go +++ b/calico_test.go @@ -14,8 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build calico_test - package main import ( @@ -29,18 +27,18 @@ import ( "github.com/networkservicemesh/integration-tests/suites/observability" ) -func TestRunHealSuite(t *testing.T) { +func TestRunHealSuiteCalico(t *testing.T) { suite.Run(t, new(heal.Suite)) } -func TestRunBasicSuite(t *testing.T) { +func TestRunBasicSuiteCalico(t *testing.T) { suite.Run(t, new(basic.Suite)) } -func TestRunMemorySuite(t *testing.T) { +func TestRunMemorySuiteCalico(t *testing.T) { suite.Run(t, new(memory.Suite)) } -func TestRunObservabilitySuite(t *testing.T) { +func TestRunObservabilitySuiteCalico(t *testing.T) { suite.Run(t, new(observability.Suite)) } diff --git a/doc.go b/doc.go deleted file mode 100644 index 6a44c4689..000000000 --- a/doc.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2022 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 main diff --git a/interdomain_test.go b/interdomain_test.go index 00318b14f..2942db284 100644 --- a/interdomain_test.go +++ b/interdomain_test.go @@ -16,8 +16,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build interdomain_test - package main import ( diff --git a/main_test.go b/main_test.go index 3f1b7bb93..b5f6f1893 100644 --- a/main_test.go +++ b/main_test.go @@ -16,8 +16,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build main_test - package main import ( @@ -32,22 +30,22 @@ import ( "github.com/networkservicemesh/integration-tests/suites/observability" ) -func TestRunHealSuite(t *testing.T) { +func TestRunHealSuiteSingle(t *testing.T) { suite.Run(t, new(heal.Suite)) } -func TestRunFeatureSuite(t *testing.T) { +func TestRunFeatureSuiteSingle(t *testing.T) { suite.Run(t, new(features.Suite)) } -func TestRunBasicSuite(t *testing.T) { +func TestRunBasicSuiteSingle(t *testing.T) { suite.Run(t, new(basic.Suite)) } -func TestRunMemorySuite(t *testing.T) { +func TestRunMemorySuiteSingle(t *testing.T) { suite.Run(t, new(memory.Suite)) } -func TestRunObservabilitySuite(t *testing.T) { +func TestRunObservabilitySuiteSingle(t *testing.T) { suite.Run(t, new(observability.Suite)) }