Skip to content

Commit

Permalink
fix ovnic e2e (#1763)
Browse files Browse the repository at this point in the history
  • Loading branch information
lut777 authored Aug 3, 2022
1 parent 51bf142 commit cd00ddb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,13 @@ kind-install-ic:
zone=az1 ic_db_host=$$ic_db_host gateway_node_name=kube-ovn1-control-plane j2 yamls/ovn-ic.yaml.j2 -o ovn-ic-1.yaml
kubectl config use-context kind-kube-ovn
kubectl apply -f ovn-ic-0.yaml
sleep 6
kubectl -n kube-system get pods | grep ovs-ovn | awk '{print $$1}' | xargs kubectl -n kube-system delete pod
kubectl config use-context kind-kube-ovn1
kubectl apply -f ovn-ic-1.yaml
sleep 6
kubectl -n kube-system get pods | grep ovs-ovn | awk '{print $$1}' | xargs kubectl -n kube-system delete pod


.PHONY: kind-install-cilium
kind-install-cilium: kind-load-image kind-untaint-control-plane
Expand Down
16 changes: 16 additions & 0 deletions test/e2e-ovnic/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package e2e_ovnic_test
import (
"context"
"fmt"
"net"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -49,6 +50,13 @@ var _ = SynchronizedAfterSuite(func() {}, func() {
checkLSP("ts-az1", pods.Items[0], f)
checkLSP("ts-az0", pods.Items[0], f)

output, err = exec.Command("kubectl", "-n", "kube-system", "-l", "app=kube-ovn-pinger", "get", "pod", "-o=jsonpath={.items[0].status.podIP}").CombinedOutput()
Expect(err).NotTo(HaveOccurred())
if net.ParseIP(string(output)) == nil {
Fail(fmt.Sprintf("pinger ip %s not right", output))
}
ip0 := string(output)

// To avoid the situation that the wrong kube-config context is loaded in framework, and then the test cloud always
// pass the test. a replacement kube-client solution is introduced to force the correct context pod-list to be read.
// Then if framework read the wrong context, it will get wrong pod which from another cluster.
Expand Down Expand Up @@ -76,6 +84,14 @@ var _ = SynchronizedAfterSuite(func() {}, func() {

checkLSP("ts-az1", pods1.Items[0], f)
checkLSP("ts-az0", pods1.Items[0], f)

output, err = exec.Command("kubectl", "-n", "kube-system", "-l", "app=kube-ovn-pinger", "get", "pod", "-o=jsonpath={.items[0].metadata.name}").CombinedOutput()
Expect(err).NotTo(HaveOccurred())
Expect(output).ShouldNot(BeEmpty())

output, err = exec.Command("kubectl", "-n", "kube-system", "exec", "-i", string(output), "--", "/usr/bin/ping", ip0, "-c2").CombinedOutput()
Expect(err).NotTo(HaveOccurred())
Expect(string(output)).Should(ContainSubstring("0% packet loss"))
})

func buildConfigFromFlags(context, kubeconfigPath string) (*rest.Config, error) {
Expand Down

0 comments on commit cd00ddb

Please sign in to comment.