Skip to content

Commit

Permalink
Calico fixes
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 Mar 23, 2022
1 parent 3e59929 commit 7f6d136
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .cloudtest.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
version: 1.0
root: "./.tests/cloud_test/"
timeout: 10800 # 3 hour total total timeout
timeout: 7200 # 2 hour total total timeout
shuffle-enabled: true
statistics:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion .cloudtest_calico.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
version: 1.0
root: "./.tests/cloud_test_calico/"
timeout: 10800 # 3 hour total total timeout
timeout: 7200 # 2 hour total total timeout
shuffle-enabled: true
statistics:
enabled: true
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ jobs:
- name: Install cloudtest # 3. Install cloudtest
run: |
go get github.com/networkservicemesh/cloudtest@master
# GOPROXY=direct go get github.com/Mixaster995/cloudtest@no-cleanup
env:
GO111MODULE: on
GOBIN: /bin
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/networkservicemesh/integratiohuhgyn-k8s-packet
module github.com/networkservicemesh/integration-k8s-packet

go 1.16

Expand Down
32 changes: 0 additions & 32 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,65 +17,33 @@
package main_test

import (
"os"
"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 TestHeal(t *testing.T) {
if isCalico() {
t.Skip("not available with Calico")
}
suite.Run(t, new(heal.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))
}
5 changes: 3 additions & 2 deletions scripts/calico/deploy-calico.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function on_error() {
}
trap 'on_error' ERR

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 scripts/calico

kubectl -n calico-vpp-dataplane rollout status daemonset/calico-vpp-node --timeout=5m
kubectl -n kube-system rollout status deployment/calico-kube-controllers --timeout=5m
kubectl rollout status -n calico-vpp-dataplane ds/calico-vpp-node --timeout=10m
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/projectcalico/vpp-dataplane/master/yaml/generated/calico-vpp-nohuge.yaml

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

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
if [[ "$1" -gt 1 ]]
then
shift "$1"
else
shift
fi
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")

# Unbond interface and set IP address
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}"
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 7f6d136

Please sign in to comment.