Skip to content

Commit 3766222

Browse files
committed
e2e: run specs in parallel (#2375)
1 parent 67fd6ef commit 3766222

File tree

8 files changed

+88
-53
lines changed

8 files changed

+88
-53
lines changed

.github/workflows/build-x86-image.yaml

+41-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: Build x86 Image
22

33
on:
44
pull_request:
5-
types:
6-
- opened
7-
- synchronize
8-
- reopened
9-
- labeled
105
branches:
116
- master
127
- release-*
@@ -167,7 +162,11 @@ jobs:
167162
key: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-${{ hashFiles(format('{0}/**/go.sum', env.E2E_DIR)) }}
168163
restore-keys: ${{ runner.os }}-e2e-${{ env.GO_FULL_VER }}-x86-
169164

170-
- run: make e2e-compile
165+
- name: Install ginkgo
166+
working-directory: ${{ env.E2E_DIR }}
167+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
168+
169+
- run: make e2e-build
171170
working-directory: ${{ env.E2E_DIR }}
172171

173172
k8s-conformance-e2e:
@@ -237,6 +236,10 @@ jobs:
237236
with:
238237
install_only: true
239238

239+
- name: Install ginkgo
240+
working-directory: ${{ env.E2E_DIR }}
241+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
242+
240243
- name: Download image
241244
uses: actions/download-artifact@v3
242245
with:
@@ -329,6 +332,10 @@ jobs:
329332
with:
330333
install_only: true
331334

335+
- name: Install ginkgo
336+
working-directory: ${{ env.E2E_DIR }}
337+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
338+
332339
- name: Download image
333340
uses: actions/download-artifact@v3
334341
with:
@@ -417,6 +424,10 @@ jobs:
417424
with:
418425
install_only: true
419426

427+
- name: Install ginkgo
428+
working-directory: ${{ env.E2E_DIR }}
429+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
430+
420431
- name: Download image
421432
uses: actions/download-artifact@v3
422433
with:
@@ -481,6 +492,10 @@ jobs:
481492
with:
482493
install_only: true
483494

495+
- name: Install ginkgo
496+
working-directory: ${{ env.E2E_DIR }}
497+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
498+
484499
- name: Download image
485500
uses: actions/download-artifact@v3
486501
with:
@@ -563,6 +578,10 @@ jobs:
563578
with:
564579
install_only: true
565580

581+
- name: Install ginkgo
582+
working-directory: ${{ env.E2E_DIR }}
583+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
584+
566585
- name: Download image
567586
uses: actions/download-artifact@v3
568587
with:
@@ -644,6 +663,10 @@ jobs:
644663
with:
645664
install_only: true
646665

666+
- name: Install ginkgo
667+
working-directory: ${{ env.E2E_DIR }}
668+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
669+
647670
- name: Download image
648671
uses: actions/download-artifact@v3
649672
with:
@@ -868,6 +891,10 @@ jobs:
868891
with:
869892
install_only: true
870893

894+
- name: Install ginkgo
895+
working-directory: ${{ env.E2E_DIR }}
896+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
897+
871898
- name: Download kube-ovn image
872899
uses: actions/download-artifact@v3
873900
with:
@@ -996,6 +1023,10 @@ jobs:
9961023
with:
9971024
install_only: true
9981025

1026+
- name: Install ginkgo
1027+
working-directory: ${{ env.E2E_DIR }}
1028+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
1029+
9991030
- name: Download image
10001031
uses: actions/download-artifact@v3
10011032
with:
@@ -1087,6 +1118,10 @@ jobs:
10871118
with:
10881119
install_only: true
10891120

1121+
- name: Install ginkgo
1122+
working-directory: ${{ env.E2E_DIR }}
1123+
run: go install -v -mod=mod github.com/onsi/ginkgo/v2/ginkgo
1124+
10901125
- name: Download image
10911126
uses: actions/download-artifact@v3
10921127
with:

Makefile.e2e

+25-22
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,41 @@ K8S_CONFORMANCE_E2E_FOCUS += "sig-network.*Feature:IPv6DualStack"
1919
endif
2020

2121
define ginkgo_option
22-
--ginkgo.$(1)=$(shell echo '$(2)' | sed -E 's/^[[:space:]]+//' | sed -E 's/"[[:space:]]+"/" --ginkgo.$(1)="/g')
22+
--$(1)=$(shell echo '$(2)' | sed -E 's/^[[:space:]]+//' | sed -E 's/"[[:space:]]+"/" --$(1)="/g')
2323
endef
2424

2525
.PHONY: e2e
2626
e2e: kube-ovn-conformance-e2e
2727

28-
.PHONY: e2e-compile
29-
e2e-compile:
30-
go test ./test/e2e/k8s-network -c -o test/e2e/k8s-network/e2e.test
31-
go test ./test/e2e/kube-ovn -c -o test/e2e/kube-ovn/e2e.test
32-
go test ./test/e2e/ovn-ic -c -o test/e2e/ovn-ic/e2e.test
33-
go test ./test/e2e/lb-svc -c -o test/e2e/lb-svc/e2e.test
28+
.PHONY: e2e-build
29+
e2e-build:
30+
ginkgo build ./test/e2e/k8s-network
31+
ginkgo build ./test/e2e/kube-ovn
32+
ginkgo build ./test/e2e/ovn-ic
33+
ginkgo build ./test/e2e/lb-svc
3434

3535
.PHONY: k8s-conformance-e2e
3636
k8s-conformance-e2e:
37-
go test ./test/e2e/k8s-network -c -o test/e2e/k8s-network/e2e.test
38-
./test/e2e/k8s-network/e2e.test --ginkgo.timeout=1h \
37+
ginkgo build ./test/e2e/k8s-network
38+
ginkgo -p --randomize-all --timeout=1h \
3939
$(call ginkgo_option,focus,$(K8S_CONFORMANCE_E2E_FOCUS)) \
40-
$(call ginkgo_option,skip,$(K8S_CONFORMANCE_E2E_SKIP))
40+
$(call ginkgo_option,skip,$(K8S_CONFORMANCE_E2E_SKIP)) \
41+
./test/e2e/k8s-network/k8s-network.test
4142

4243
.PHONY: k8s-netpol-legacy-e2e
4344
k8s-netpol-legacy-e2e:
44-
go test ./test/e2e/k8s-network -c -o test/e2e/k8s-network/e2e.test
45-
./test/e2e/k8s-network/e2e.test --ginkgo.timeout=2h \
46-
$(call ginkgo_option,focus,$(K8S_NETPOL_LEGACY_E2E_FOCUS))
45+
ginkgo build ./test/e2e/k8s-network
46+
ginkgo -p --randomize-all --timeout=2h \
47+
$(call ginkgo_option,focus,$(K8S_NETPOL_LEGACY_E2E_FOCUS)) \
48+
./test/e2e/k8s-network/k8s-network.test
4749

4850
.PHONY: k8s-netpol-e2e
4951
k8s-netpol-e2e:
50-
go test ./test/e2e/k8s-network -c -o test/e2e/k8s-network/e2e.test
51-
./test/e2e/k8s-network/e2e.test --ginkgo.timeout=2h \
52+
ginkgo build ./test/e2e/k8s-network
53+
ginkgo -p --randomize-all --timeout=2h \
5254
$(call ginkgo_option,focus,$(K8S_NETPOL_E2E_FOCUS)) \
53-
$(call ginkgo_option,skip,$(K8S_NETPOL_E2E_SKIP))
55+
$(call ginkgo_option,skip,$(K8S_NETPOL_E2E_SKIP)) \
56+
./test/e2e/k8s-network/k8s-network.test
5457

5558
.PHONY: cyclonus-netpol-e2e
5659
cyclonus-netpol-e2e:
@@ -68,24 +71,24 @@ cyclonus-netpol-e2e:
6871

6972
.PHONY: kube-ovn-conformance-e2e
7073
kube-ovn-conformance-e2e:
71-
go test ./test/e2e/kube-ovn -c -o test/e2e/kube-ovn/e2e.test
74+
ginkgo build ./test/e2e/kube-ovn
7275
E2E_BRANCH=$(E2E_BRANCH) \
7376
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
7477
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
75-
./test/e2e/kube-ovn/e2e.test --ginkgo.focus=CNI:Kube-OVN
78+
ginkgo -p --randomize-all --focus=CNI:Kube-OVN ./test/e2e/kube-ovn/kube-ovn.test
7679

7780
.PHONY: kube-ovn-ic-conformance-e2e
7881
kube-ovn-ic-conformance-e2e:
79-
go test ./test/e2e/ovn-ic -c -o test/e2e/ovn-ic/e2e.test
82+
ginkgo build ./test/e2e/ovn-ic
8083
E2E_BRANCH=$(E2E_BRANCH) \
8184
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
8285
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
83-
./test/e2e/ovn-ic/e2e.test --ginkgo.focus=CNI:Kube-OVN
86+
ginkgo -p --randomize-all --focus=CNI:Kube-OVN ./test/e2e/ovn-ic/ovn-ic.test
8487

8588
.PHONY: kube-ovn-lb-svc-conformance-e2e
8689
kube-ovn-lb-svc-conformance-e2e:
87-
go test ./test/e2e/lb-svc -c -o test/e2e/lb-svc/e2e.test
90+
ginkgo build ./test/e2e/lb-svc
8891
E2E_BRANCH=$(E2E_BRANCH) \
8992
E2E_IP_FAMILY=$(E2E_IP_FAMILY) \
9093
E2E_NETWORK_MODE=$(E2E_NETWORK_MODE) \
91-
./test/e2e/lb-svc/e2e.test --ginkgo.focus=CNI:Kube-OVN
94+
ginkgo -p --randomize-all --focus=CNI:Kube-OVN ./test/e2e/lb-svc/lb-svc.test

test/e2e/framework/framework.go

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ func Describe(text string, body func()) bool {
136136
return ginkgo.Describe("[CNI:Kube-OVN] "+text, body)
137137
}
138138

139+
func SerialDescribe(text string, body func()) bool {
140+
return ginkgo.Describe("[CNI:Kube-OVN] "+text, ginkgo.Serial, body)
141+
}
142+
139143
func OrderedDescribe(text string, body func()) bool {
140144
return ginkgo.Describe("[CNI:Kube-OVN] "+text, ginkgo.Ordered, body)
141145
}

test/e2e/k8s-network/e2e_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ func init() {
2424
config.CopyFlags(config.Flags, flag.CommandLine)
2525
framework.RegisterCommonFlags(flag.CommandLine)
2626
framework.RegisterClusterFlags(flag.CommandLine)
27+
}
2728

28-
// Parse all the flags
29-
flag.Parse()
29+
func TestE2E(t *testing.T) {
3030
if framework.TestContext.KubeConfig == "" {
3131
framework.TestContext.KubeConfig = filepath.Join(os.Getenv("HOME"), ".kube", "config")
3232
}
3333
framework.AfterReadingAllFlags(&framework.TestContext)
34-
}
3534

36-
func TestE2E(t *testing.T) {
3735
e2e.RunE2ETests(t)
3836
}

test/e2e/kube-ovn/e2e_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ func init() {
2929
config.CopyFlags(config.Flags, flag.CommandLine)
3030
framework.RegisterCommonFlags(flag.CommandLine)
3131
framework.RegisterClusterFlags(flag.CommandLine)
32+
}
3233

33-
// Parse all the flags
34-
flag.Parse()
34+
func TestE2E(t *testing.T) {
3535
if framework.TestContext.KubeConfig == "" {
3636
framework.TestContext.KubeConfig = filepath.Join(os.Getenv("HOME"), ".kube", "config")
3737
}
3838
framework.AfterReadingAllFlags(&framework.TestContext)
39-
}
4039

41-
func TestE2E(t *testing.T) {
4240
e2e.RunE2ETests(t)
4341
}

test/e2e/kube-ovn/underlay/underlay.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func makeProviderNetwork(providerNetworkName string, exchangeLinkName bool, link
4444
return framework.MakeProviderNetwork(providerNetworkName, exchangeLinkName, defaultInterface, customInterfaces, nil)
4545
}
4646

47-
var _ = framework.Describe("[group:underlay]", func() {
47+
var _ = framework.SerialDescribe("[group:underlay]", func() {
4848
f := framework.NewDefaultFramework("underlay")
4949

5050
var skip bool

test/e2e/lb-svc/e2e_test.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"flag"
66
"fmt"
77
"math/big"
8+
"math/rand"
89
"os"
910
"path/filepath"
1011
"strings"
@@ -40,24 +41,22 @@ func init() {
4041
config.CopyFlags(config.Flags, flag.CommandLine)
4142
k8sframework.RegisterCommonFlags(flag.CommandLine)
4243
k8sframework.RegisterClusterFlags(flag.CommandLine)
44+
}
4345

44-
// Parse all the flags
45-
flag.Parse()
46+
func TestE2E(t *testing.T) {
4647
if k8sframework.TestContext.KubeConfig == "" {
4748
k8sframework.TestContext.KubeConfig = filepath.Join(os.Getenv("HOME"), ".kube", "config")
4849
}
4950
k8sframework.AfterReadingAllFlags(&k8sframework.TestContext)
50-
}
5151

52-
func TestE2E(t *testing.T) {
5352
e2e.RunE2ETests(t)
5453
}
5554

5655
func lbSvcDeploymentName(serviceName string) string {
5756
return "lb-svc-" + serviceName
5857
}
5958

60-
var _ = framework.Describe("[group:lb-svc]", func() {
59+
var _ = framework.SerialDescribe("[group:lb-svc]", func() {
6160
f := framework.NewDefaultFramework("lb-svc")
6261

6362
var skip bool
@@ -76,7 +75,7 @@ var _ = framework.Describe("[group:lb-svc]", func() {
7675
serviceName = "service-" + framework.RandomSuffix()
7776

7877
if skip {
79-
ginkgo.Skip("underlay spec only runs on kind clusters")
78+
ginkgo.Skip("lb svc spec only runs on kind clusters")
8079
}
8180

8281
if clusterName == "" {
@@ -87,7 +86,7 @@ var _ = framework.Describe("[group:lb-svc]", func() {
8786
cluster, ok := kind.IsKindProvided(k8sNodes.Items[0].Spec.ProviderID)
8887
if !ok {
8988
skip = true
90-
ginkgo.Skip("underlay spec only runs on kind clusters")
89+
ginkgo.Skip("lb svc spec only runs on kind clusters")
9190
}
9291
clusterName = cluster
9392
}
@@ -140,8 +139,8 @@ var _ = framework.Describe("[group:lb-svc]", func() {
140139
service := framework.MakeService(serviceName, corev1.ServiceTypeLoadBalancer, annotations, selector, ports, corev1.ServiceAffinityNone)
141140
_ = serviceClient.CreateSync(service)
142141

143-
ginkgo.By("Waiting for 5 seconds")
144-
time.Sleep(5 * time.Second)
142+
ginkgo.By("Waiting for 10 seconds")
143+
time.Sleep(10 * time.Second)
145144

146145
deploymentName := lbSvcDeploymentName(serviceName)
147146
ginkgo.By("Getting deployment " + deploymentName)
@@ -178,7 +177,7 @@ var _ = framework.Describe("[group:lb-svc]", func() {
178177
framework.ConformanceIt("should allocate static external IP for service", func() {
179178
ginkgo.By("Creating service " + serviceName)
180179
base := util.Ip2BigInt(gateway)
181-
lbIP := util.BigInt2Ip(base.Add(base, big.NewInt(100)))
180+
lbIP := util.BigInt2Ip(base.Add(base, big.NewInt(50+rand.Int63n(50))))
182181
ports := []corev1.ServicePort{{
183182
Name: "tcp",
184183
Protocol: corev1.ProtocolTCP,

test/e2e/ovn-ic/e2e_test.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,22 @@ func init() {
4242
config.CopyFlags(config.Flags, flag.CommandLine)
4343
k8sframework.RegisterCommonFlags(flag.CommandLine)
4444
k8sframework.RegisterClusterFlags(flag.CommandLine)
45+
}
4546

46-
// Parse all the flags
47-
flag.Parse()
47+
func TestE2E(t *testing.T) {
4848
if k8sframework.TestContext.KubeConfig == "" {
4949
k8sframework.TestContext.KubeConfig = filepath.Join(os.Getenv("HOME"), ".kube", "config")
5050
}
5151
k8sframework.AfterReadingAllFlags(&k8sframework.TestContext)
5252

5353
var err error
5454
if clusters, err = kind.ListClusters(); err != nil {
55-
panic(fmt.Sprintf("failed to list kind clusters: %v", err))
55+
t.Fatalf("failed to list kind clusters: %v", err)
5656
}
5757
if len(clusters) < 2 {
58-
panic("no enough kind clusters to run ovn-ic e2e testing")
58+
t.Fatal("no enough kind clusters to run ovn-ic e2e testing")
5959
}
60-
}
6160

62-
func TestE2E(t *testing.T) {
6361
e2e.RunE2ETests(t)
6462
}
6563

0 commit comments

Comments
 (0)