Skip to content

Commit

Permalink
calico
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
  • Loading branch information
glazychev-art committed Feb 25, 2022
1 parent 0b3481c commit 34fac17
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 72 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ jobs:
env:
GO111MODULE: on
GOBIN: /bin
- name: Checkout deployments # 4. Checkout deployments
uses: actions/checkout@v2
with:
repository: networkservicemesh/deployments-k8s
path: networkservicemesh/deployments-k8s
- name: Compute suffix # 5. Compute suffix for cloudtest input and output paths
id: suffix
run: |
Expand Down
4 changes: 1 addition & 3 deletions cloudtest/packet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ providers:
env:
- CLUSTER_RULES_PREFIX=null # To not add any specific code
- KUBECONFIG=$(tempdir)/config
- CLUSTER_NAME=$(cluster-name)-$(date)-${GITHUB_RUN_NUMBER}-$(rands10)
- CLUSTER_NAME=test-$(cluster-name)-$(date)-${GITHUB_RUN_NUMBER}-$(rands10)
env-check:
- PACKET_AUTH_TOKEN
- PACKET_PROJECT_ID
Expand All @@ -37,10 +37,8 @@ providers:
hardware-reservations:
- 2cf78481-53b0-46c8-a084-6e9815acdb0b
- 2361d3c2-f694-4fa7-a683-a9f69e2abe7c
- 70b51e39-2e65-4a64-8191-dd28386c0b80
- 4f27da36-a911-45a5-ab81-0e789348e3fe
- 7741d4a8-8555-492b-8d73-63c2f0715d16
- d173dbde-8510-454e-b0c2-c120c397cdf5
scripts:
install: "echo all deps installed"
setup: |
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ require (
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/networkservicemesh/integration-tests => github.com/glazychev-art/integration-tests v0.0.0-20220225082059-2b2495896525
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/glazychev-art/integration-tests v0.0.0-20220225082059-2b2495896525 h1:5oPskwUElyd01o5JW4eWNCu4wrZ+FZsShcEAbil16ZY=
github.com/glazychev-art/integration-tests v0.0.0-20220225082059-2b2495896525/go.mod h1:0o7WrzxlHEwnDSuZPEM1BnKd4hr7+akKgymoAoTTbv8=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down Expand Up @@ -158,8 +160,6 @@ github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8m
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/networkservicemesh/gotestmd v0.0.0-20211116145945-871d2aaf07ab h1:/dIr8Nky77grI3s9Rc78eFH9M1Svobyj2XJBaKm27ts=
github.com/networkservicemesh/gotestmd v0.0.0-20211116145945-871d2aaf07ab/go.mod h1:8EWnekTRNX+NxBdTFE24WqUoM7SgJHbiafDBrIIdOmQ=
github.com/networkservicemesh/integration-tests v0.0.0-20220204150126-670c146366da h1:YqmZghVc2XwkiKJRcud98AIqO9kSDh7JwxTBVWfkQc4=
github.com/networkservicemesh/integration-tests v0.0.0-20220204150126-670c146366da/go.mod h1:0o7WrzxlHEwnDSuZPEM1BnKd4hr7+akKgymoAoTTbv8=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
84 changes: 33 additions & 51 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,47 @@
package main_test

import (
"os"
"github.com/networkservicemesh/integration-tests/suites/basic"
"testing"

"github.com/stretchr/testify/suite"

"github.com/networkservicemesh/integration-tests/suites/calico"
"github.com/networkservicemesh/integration-tests/suites/heal"
"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/sriov"
)

func isCalico() bool {
return os.Getenv("CALICO") == "on"
}

func TestMemory(t *testing.T) {
if isCalico() {
t.Skip("not available with Calico")
}
suite.Run(t, new(memory.Suite))
}

func TestSRIOV(t *testing.T) {
if isCalico() {
t.Skip("not available with Calico")
}
suite.Run(t, new(sriov.Suite))
}

func TestMultiForwarder(t *testing.T) {
if isCalico() {
t.Skip("not available with Calico")
}
suite.Run(t, new(multiforwarder.Suite))
}
//func isCalico() bool {
// return os.Getenv("CALICO") == "on"
//}

func TestHeal(t *testing.T) {
if isCalico() {
t.Skip("not available with Calico")
}
suite.Run(t, new(heal.Suite))
}
//func TestMemory(t *testing.T) {
// suite.Run(t, new(memory.Suite))
//}
//
//func TestSRIOV(t *testing.T) {
// suite.Run(t, new(sriov.Suite))
//}
//
//func TestMultiForwarder(t *testing.T) {
// suite.Run(t, new(multiforwarder.Suite))
//}
//
//func TestHeal(t *testing.T) {
// suite.Run(t, new(heal.Suite))
//}

func TestRunObservabilitySuite(t *testing.T) {
suite.Run(t, new(observability.Suite))
}
//func TestRunObservabilitySuite(t *testing.T) {
// suite.Run(t, new(observability.Suite))
//}

func TestBasic(t *testing.T) {
if isCalico() {
t.Skip("not available with Calico")
}
suite.Run(t, new(basic.Suite))
}

func TestCalico(t *testing.T) {
if !isCalico() {
t.Skip("not available without Calico")
}
suite.Run(t, new(calico.Suite))
}
//
//func TestRunFeatureSuiteSingle(t *testing.T) {
// suite.Run(t, new(features.Suite))
//}

//func TestCalico(t *testing.T) {
// if !isCalico() {
// t.Skip("not available without Calico")
// }
// suite.Run(t, new(calico.Suite))
//}
2 changes: 1 addition & 1 deletion scripts/calico/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- https://raw.githubusercontent.com/projectcalico/vpp-dataplane/v0.17.0-calicov3.20.2/yaml/generated/calico-vpp-nohuge.yaml
- https://raw.githubusercontent.com/glazychev-art/test-repo/calico/calico-vpp-nohuge.yaml

patchesStrategicMerge:
- patch.yaml
36 changes: 33 additions & 3 deletions scripts/calico/setup-interfaces.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,37 @@

set -e

ip="$1"
cdr2mask ()
{
# Number of args to shift, 255..255, first non-255 byte, zeroes
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
[ $1 -gt 1 ] && shift $1 || shift
echo ${1-0}.${2-0}.${3-0}.${4-0}
}

ip addr add "${ip}" dev eno2
ip link set up dev eno2
iface="$1"
ip="$2"
cidr="$3"
mask=$(cdr2mask $3)

cd /etc/network/
awk -v pattern="iface $1 inet" -v ip="$2" -v mask="$mask" '
$0 ~ pattern {
printf "%s static\n",pattern;
printf " address %s\n",ip;
printf " netmask %s\n",mask;
getline;
while ($0 != "") {
if ($1=="bond-master") {
next;
break
};
print;
getline
}
} 1
' interfaces > interfaces.tmp && mv interfaces.tmp interfaces
cd
ifenslave -d bond0 "${iface}"
ip addr change "${ip}/${cidr}" dev "${iface}"
ip link set up dev "${iface}"
8 changes: 8 additions & 0 deletions scripts/calico/unbond-interface.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

cd /etc/network/
awk -v pattern="iface $1" '$0 ~ pattern {print $0; getline; while($0 != "") {if($1=="bond-master") {next; break}; print; getline}} 1' interfaces > interfaces.tmp && mv interfaces.tmp interfaces
cd
ifenslave -d bond0 $1
15 changes: 8 additions & 7 deletions scripts/create-kubernetes-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ if [[ "$CALICO" == "on" ]]; then # calico

CALICO_MASTER_IP="10.0.0.$(( base_ip + 1 ))"
CALICO_WORKER_IP="10.0.0.$(( base_ip + 2 ))"
CALICO_SUBNET_MASK="30"
CALICO_CIDR_PREFIX="30"
CALICO_INTERFACE="eno2"
fi

ENVS="KUBERNETES_VERSION CALICO"
Expand Down Expand Up @@ -53,24 +54,24 @@ wait_pids "${pids}" "SR-IOV config failed" || exit 21

if [[ "$CALICO" == "on" ]]; then # calico
# 3. Create Calico scripts directory on nodes.
ssh ${SSH_OPTS} root@${master_ip} mkdir calico || exit 31
ssh ${SSH_OPTS} root@${worker_ip} mkdir calico || exit 32
ssh ${SSH_OPTS} root@${master_ip} mkdir -p calico || exit 31
ssh ${SSH_OPTS} root@${worker_ip} mkdir -p calico || exit 32

# 4. Setup Calico interfaces.
scp ${SSH_OPTS} scripts/calico/setup-interfaces.sh root@${master_ip}:calico/setup-interfaces.sh || exit 41
scp ${SSH_OPTS} scripts/calico/setup-interfaces.sh root@${worker_ip}:calico/setup-interfaces.sh || exit 42

pids=""
ssh ${SSH_OPTS} root@${master_ip} ./calico/setup-interfaces.sh "${CALICO_MASTER_IP}/${CALICO_SUBNET_MASK}" &
ssh ${SSH_OPTS} root@${master_ip} ./calico/setup-interfaces.sh "${CALICO_INTERFACE}" "${CALICO_MASTER_IP}" "${CALICO_CIDR_PREFIX}" &
pids+=" $!"
ssh ${SSH_OPTS} root@${worker_ip} ./calico/setup-interfaces.sh "${CALICO_WORKER_IP}/${CALICO_SUBNET_MASK}" &
ssh ${SSH_OPTS} root@${worker_ip} ./calico/setup-interfaces.sh "${CALICO_INTERFACE}" "${CALICO_WORKER_IP}" "${CALICO_CIDR_PREFIX}" &
pids+=" $!"
wait_pids "${pids}" "setup Calico interfaces failed" || exit 43
fi

# 5. Create k8s scripts directory on nodes.
ssh ${SSH_OPTS} root@${master_ip} mkdir k8s || exit 51
ssh ${SSH_OPTS} root@${worker_ip} mkdir k8s || exit 52
ssh ${SSH_OPTS} root@${master_ip} mkdir -p k8s || exit 51
ssh ${SSH_OPTS} root@${worker_ip} mkdir -p k8s || exit 52

# 6. Config docker.
scp ${SSH_OPTS} scripts/k8s/config-docker.sh root@${master_ip}:k8s/config-docker.sh || exit 61
Expand Down

0 comments on commit 34fac17

Please sign in to comment.