Skip to content

Commit

Permalink
add e2e ovs
Browse files Browse the repository at this point in the history
Signed-off-by: Icarus9913 <[email protected]>
  • Loading branch information
Icarus9913 committed Nov 9, 2023
1 parent 0f94b2b commit 7f5fe72
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 100 deletions.
21 changes: 14 additions & 7 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ kind-init: check_env prepare
INSTALL_NETTOOLS=$(INSTALL_NETTOOLS) \
E2E_VLAN_GATEWAY_IMAGE=$(E2E_VLAN_GATEWAY_IMAGE) \
VLAN_GATEWAY_CONTAINER=$(VLAN_GATEWAY_CONTAINER) \
INSTALL_KUBEVIRT=$(INSTALL_KUBEVIRT) \
HOST_ADDITIONAL_INTERFACE=$(HOST_ADDITIONAL_INTERFACE) \
BRIDGE_INTERFACE=$(BRIDGE_INTERFACE) \
$(QUIET) bash scripts/config-network.sh
DOCKER_ADDITIONAL_NETWORK=$(DOCKER_ADDITIONAL_NETWORK) \
HOST_ADDITIONAL_INTERFACE=$(HOST_ADDITIONAL_INTERFACE) \
BRIDGE_INTERFACE=$(BRIDGE_INTERFACE) \
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
HTTP_PROXY=$(HTTP_PROXY) \
$(QUIET) bash scripts/install-ovs.sh
@echo -e "\033[35m [Step 5] Install The CNI-Plugins: $(CNI_PACKAGE_VERSION) \033[0m"
$(QUIET) bash scripts/cni-install.sh $(E2E_CLUSTER_NAME) $(DOWNLOAD_DIR)
ifeq ($(INSTALL_OVERLAY_CNI),true)
@echo -e "\033[35m [Step 6] Install Default-CNI: Calico-$(CALICO_VERSION) Cilium-$(CILIUM_VERSION) \033[0m"
E2E_KUBECONFIG=$(E2E_KUBECONFIG) \
Expand Down Expand Up @@ -51,14 +62,10 @@ ifeq ($(INSTALL_MULTUS),true)
@ IMAGE_MULTUS=$(IMAGE_MULTUS_NAME) \
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
MULTUS_DEFAULT_CNI_NAME=$(MULTUS_DEFAULT_CNI_VLAN0) \
MULTUS_DEFAULT_CNI_CALICO=$(MULTUS_DEFAULT_CNI_CALICO) \
MULTUS_DEFAULT_CNI_CILIUM=$(MULTUS_DEFAULT_CNI_CILIUM) \
MULTUS_DEFAULT_CNI_VLAN100=$(MULTUS_DEFAULT_CNI_VLAN100) \
MULTUS_DEFAULT_CNI_VLAN200=$(MULTUS_DEFAULT_CNI_VLAN200) \
MULTUS_ADDITIONAL_CNI_VLAN100=$(MULTUS_ADDITIONAL_CNI_VLAN100) \
MULTUS_ADDITIONAL_CNI_VLAN200=$(MULTUS_ADDITIONAL_CNI_VLAN200) \
MULTUS_KUBEVIRT_CNI_VLAN30=$(MULTUS_KUBEVIRT_CNI_VLAN30) \
MULTUS_KUBEVIRT_CNI_VLAN40=$(MULTUS_KUBEVIRT_CNI_VLAN40) \
MULTUS_OVS_CNI_VLAN30=$(MULTUS_OVS_CNI_VLAN30) \
MULTUS_OVS_CNI_VLAN40=$(MULTUS_OVS_CNI_VLAN40) \
INSTALL_KUBEVIRT=$(INSTALL_KUBEVIRT) \
RELEASE_NAMESPACE=$(RELEASE_NAMESPACE) \
DISABLE_KUBE_PROXY=$(DISABLE_KUBE_PROXY) \
Expand All @@ -82,7 +89,7 @@ ifeq ($(INSTALL_SPIDERDOCTOR),true)
$(QUIET) bash scripts/install-spiderdoctor.sh
endif
ifeq ($(INSTALL_KUBEVIRT),true)
@echo -e "\033[35m [Step 10] Install kubevirt \033[0m"
@echo -e "\033[35m [Step 11] Install kubevirt \033[0m"
E2E_KUBECONFIG=$(E2E_KUBECONFIG) \
E2E_CLUSTER_NAME=$(E2E_CLUSTER_NAME) \
HTTP_PROXY=$(HTTP_PROXY) \
Expand Down
9 changes: 7 additions & 2 deletions test/Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ MULTUS_DEFAULT_CNI_CILIUM := cilium
MULTUS_DEFAULT_CNI_VLAN0 := macvlan-vlan0
MULTUS_DEFAULT_CNI_VLAN100 := macvlan-vlan100
MULTUS_DEFAULT_CNI_VLAN200 := macvlan-vlan200
MULTUS_KUBEVIRT_CNI_VLAN30 := kubevirt-macvlan-vlan30
MULTUS_KUBEVIRT_CNI_VLAN40 := kubevirt-macvlan-vlan40
MULTUS_OVS_CNI_VLAN30 := ovs-vlan30
MULTUS_OVS_CNI_VLAN40 := ovs-vlan40

ifeq ($(E2E_CHINA_IMAGE_REGISTRY),true)
E2E_MULTUS_IMAGE_REGISTER ?= ghcr.m.daocloud.io
Expand Down Expand Up @@ -212,3 +212,8 @@ ifeq ($(E2E_CHINA_IMAGE_REGISTRY),true)
else
E2E_KUBEVIRT_IMAGE_REPO ?= quay.io
endif

#================= ovs
DOCKER_ADDITIONAL_NETWORK := spider_eth1
HOST_ADDITIONAL_INTERFACE := eth1
BRIDGE_INTERFACE := br1
2 changes: 1 addition & 1 deletion test/doc/kubevirt.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
|---------|-------------------------------------------------------------------------------|----------|-------|--------|-------|
| F00001 | Succeed to keep static IP for kubevirt VM/VMI after restarting the VM/VMI pod | P1 | | done | |
| F00002 | Succeed to keep static IP for the kubevirt VM live migration | P1 | | done | |
| F00003 | Succeed to allocation multiple NICs | P1 | | done | |
| F00003 | Succeed to allocate multiple NICs | P1 | | done | |
12 changes: 6 additions & 6 deletions test/e2e/common/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ var (
MacvlanUnderlayVlan0 string = "macvlan-vlan0"
MacvlanVlan100 string = "macvlan-vlan100"
MacvlanVlan200 string = "macvlan-vlan200"
KubevirtMacvlan30 string = "kubevirt-macvlan-vlan30"
KubevirtMacvlan40 string = "kubevirt-macvlan-vlan40"
KubevirtPoolIPv4Vlan30 string = "kubevirt-vlan30-v4"
KubevirtPoolIPv6Vlan30 string = "kubevirt-vlan30-v6"
KubevirtPoolIPv4Vlan40 string = "kubevirt-vlan40-v4"
KubevirtPoolIPv6Vlan40 string = "kubevirt-vlan40-v6"
OvsVlan30 string = "ovs-vlan30"
OvsVlan40 string = "ovs-vlan40"
SpiderPoolIPv4SubnetVlan30 string = "vlan30-v4"
SpiderPoolIPv6SubnetVlan30 string = "vlan30-v6"
SpiderPoolIPv4SubnetVlan40 string = "vlan40-v4"
SpiderPoolIPv6SubnetVlan40 string = "vlan40-v6"
SpiderPoolIPv4SubnetDefault string = "default-v4-subnet"
SpiderPoolIPv6SubnetDefault string = "default-v6-subnet"
SpiderPoolIPv4SubnetVlan100 string = "vlan100-v4"
Expand Down
34 changes: 22 additions & 12 deletions test/e2e/kubevirt/kubevirt_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,48 +51,58 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())

// make sure we have macvlan net-attach-def resource
_, err = frame.GetMultusInstance(common.KubevirtMacvlan30, common.MultusNs)
_, err = frame.GetMultusInstance(common.MacvlanUnderlayVlan0, common.MultusNs)
if nil != err {
if errors.IsNotFound(err) {
Skip(fmt.Sprintf("no kubevirt multus CR '%s/%s' installed, ignore this suite", common.MultusNs, common.KubevirtMacvlan30))
Skip(fmt.Sprintf("no kubevirt multus CR '%s/%s' installed, ignore this suite", common.MultusNs, common.MacvlanUnderlayVlan0))
}
Fail(err.Error())
}
_, err = frame.GetMultusInstance(common.KubevirtMacvlan40, common.MultusNs)

// make sure we have ovs net-attach-def resource
_, err = frame.GetMultusInstance(common.OvsVlan30, common.MultusNs)
if nil != err {
if errors.IsNotFound(err) {
Skip(fmt.Sprintf("no kubevirt multus CR '%s/%s' installed, ignore this suite", common.MultusNs, common.KubevirtMacvlan40))
Skip(fmt.Sprintf("no kubevirt multus CR '%s/%s' installed, ignore this suite", common.MultusNs, common.OvsVlan30))
}
Fail(err.Error())
}
_, err = frame.GetMultusInstance(common.OvsVlan40, common.MultusNs)
if nil != err {
if errors.IsNotFound(err) {
Skip(fmt.Sprintf("no kubevirt multus CR '%s/%s' installed, ignore this suite", common.MultusNs, common.OvsVlan40))
}
Fail(err.Error())
}

if frame.Info.IpV4Enabled {
_, err := getSpiderIPPoolByName(common.KubevirtPoolIPv4Vlan30)
_, err := getSpiderIPPoolByName(common.SpiderPoolIPv4SubnetVlan30)
if nil != err {
if errors.IsNotFound(err) {
Skip(fmt.Sprintf("no kubevirt IPv4 IPPool resource '%s' installed, ignore this suite", common.KubevirtPoolIPv4Vlan30))
Skip(fmt.Sprintf("no kubevirt IPv4 IPPool resource '%s' installed, ignore this suite", common.SpiderPoolIPv4SubnetVlan30))
}
Fail(err.Error())
}
_, err = getSpiderIPPoolByName(common.KubevirtPoolIPv4Vlan40)
_, err = getSpiderIPPoolByName(common.SpiderPoolIPv4SubnetVlan40)
if nil != err {
if errors.IsNotFound(err) {
Skip(fmt.Sprintf("no kubevirt IPv4 IPPool resource '%s' installed, ignore this suite", common.KubevirtPoolIPv4Vlan40))
Skip(fmt.Sprintf("no kubevirt IPv4 IPPool resource '%s' installed, ignore this suite", common.SpiderPoolIPv4SubnetVlan40))
}
Fail(err.Error())
}
}
if frame.Info.IpV6Enabled {
_, err := getSpiderIPPoolByName(common.KubevirtPoolIPv6Vlan30)
_, err := getSpiderIPPoolByName(common.SpiderPoolIPv6SubnetVlan30)
if nil != err {
if errors.IsNotFound(err) {
Skip(fmt.Sprintf("no kubevirt IPv6 IPPool resource '%s' installed, ignore this suite", common.KubevirtPoolIPv6Vlan30))
Skip(fmt.Sprintf("no kubevirt IPv6 IPPool resource '%s' installed, ignore this suite", common.SpiderPoolIPv6SubnetVlan30))
}
Fail(err.Error())
}
_, err = getSpiderIPPoolByName(common.KubevirtPoolIPv6Vlan40)
_, err = getSpiderIPPoolByName(common.SpiderPoolIPv6SubnetVlan40)
if nil != err {
if errors.IsNotFound(err) {
Skip(fmt.Sprintf("no kubevirt IPv6 IPPool resource '%s' installed, ignore this suite", common.KubevirtPoolIPv6Vlan40))
Skip(fmt.Sprintf("no kubevirt IPv6 IPPool resource '%s' installed, ignore this suite", common.SpiderPoolIPv6SubnetVlan40))
}
Fail(err.Error())
}
Expand Down
22 changes: 13 additions & 9 deletions test/e2e/kubevirt/kubevirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
kubevirtv1 "kubevirt.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/spidernet-io/spiderpool/pkg/constant"
spiderpoolv2beta1 "github.com/spidernet-io/spiderpool/pkg/k8s/apis/spiderpool.spidernet.io/v2beta1"
"github.com/spidernet-io/spiderpool/test/e2e/common"
)
Expand Down Expand Up @@ -200,44 +201,47 @@ var _ = Describe("test kubevirt", Label("kubevirt"), func() {

It("Succeed to allocation multiple NICs", Label("F00003"), func() {
// 1. create a kubevirt vm with bridge + multus multiple NIC network mode
macvlan30 := "macvlan30"
macvlan40 := "macvlan40"
ovs30 := "ovs30"
ovs40 := "ovs40"
virtualMachine.Spec.Template.Spec.Networks = []kubevirtv1.Network{
{
Name: macvlan30,
Name: ovs30,
NetworkSource: kubevirtv1.NetworkSource{
Multus: &kubevirtv1.MultusNetwork{
NetworkName: fmt.Sprintf("%s/%s", common.MultusNs, common.KubevirtMacvlan30),
NetworkName: fmt.Sprintf("%s/%s", common.MultusNs, common.OvsVlan30),
Default: true,
},
},
},
{
Name: macvlan40,
Name: ovs40,
NetworkSource: kubevirtv1.NetworkSource{
Multus: &kubevirtv1.MultusNetwork{
NetworkName: fmt.Sprintf("%s/%s", common.MultusNs, common.KubevirtMacvlan40),
NetworkName: fmt.Sprintf("%s/%s", common.MultusNs, common.OvsVlan40),
},
},
},
}
virtualMachine.Spec.Template.Spec.Domain.Devices.Interfaces = []kubevirtv1.Interface{
{
Name: macvlan30,
Name: ovs30,
InterfaceBindingMethod: kubevirtv1.InterfaceBindingMethod{
Bridge: &kubevirtv1.InterfaceBridge{},
},
},
{
Name: macvlan40,
Name: ovs40,
InterfaceBindingMethod: kubevirtv1.InterfaceBindingMethod{
Bridge: &kubevirtv1.InterfaceBridge{},
},
},
}

// with virtualMachine.Spec.Template.Spec.Networks set with multus, we don't need to add multus annotations
virtualMachine.SetAnnotations(map[string]string{})
anno := map[string]string{
constant.AnnoDefaultRouteInterface: constant.ClusterDefaultInterfaceName,
}
virtualMachine.Spec.Template.ObjectMeta.SetAnnotations(anno)
virtualMachine.Name = fmt.Sprintf("%s-%s", virtualMachine.Name, utilrand.String(randomLength))
virtualMachine.Namespace = namespace
GinkgoWriter.Printf("try to create kubevirt VM: %v \n", virtualMachine)
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/install-kubevirt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright Authors of Spider

set -o errexit -o nounset -o pipefail
set -o errexit -o nounset -o pipefail -o xtrace

CURRENT_FILENAME=$( basename $0 )

Expand Down
Loading

0 comments on commit 7f5fe72

Please sign in to comment.