Skip to content

Commit e43ba71

Browse files
committed
systest: add QUIC support
This adds a job that runs systests using QUIC instead of TCP
1 parent 63dc6a8 commit e43ba71

File tree

5 files changed

+55
-9
lines changed

5 files changed

+55
-9
lines changed

.github/workflows/systest.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ jobs:
5454
5555
systest:
5656
runs-on: ubuntu-latest
57+
strategy:
58+
fail-fast: true
59+
matrix:
60+
protocol:
61+
- tcp
62+
- quic
5763
if: ${{ needs.filter-changes.outputs.nondocchanges == 'true' }}
5864
needs:
5965
- filter-changes
@@ -127,6 +133,7 @@ jobs:
127133
level: ${{ inputs.log_level }}
128134
clusters: 4
129135
norbac: 1
136+
quic: ${{ matrix.protocol == 'tcp' && 'false' || 'true' }}
130137
run: make -C systest run test_name=${{ inputs.test_name }}
131138

132139
- name: Delete pod

systest/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ node_selector ?=
2323
namespace ?=
2424
label ?=
2525
count ?= 1
26+
quic ?= false
2627

2728
configname ?= $(test_job_name)
2829
smesher_config ?= parameters/fastnet/smesher.json
@@ -63,6 +64,7 @@ template:
6364
@echo post-init-image=$(post_init_image) >> $(tmpfile)
6465
@echo keep=$(keep) >> $(tmpfile)
6566
@echo testid=$(test_id) >> $(tmpfile)
67+
@echo quic=$(quic) >> $(tmpfile)
6668

6769
.PHONY: config
6870
config: template

systest/cluster/discover.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func discoverNodes(ctx *testcontext.Context, kind string) ([]*NodeClient, error)
2626
P2P: 7513,
2727
GRPC_PUB: 9092,
2828
GRPC_PRIV: 9093,
29+
QUIC: ctx.QUIC,
2930
},
3031
})
3132
}

systest/cluster/nodes.go

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,16 @@ const (
129129
type Node struct {
130130
Name string
131131
P2P, GRPC_PUB, GRPC_PRIV uint16
132+
QUIC bool
132133
}
133134

134135
// P2PEndpoint returns full p2p endpoint, including identity.
135136
func p2pEndpoint(n Node, ip, id string) string {
136-
return fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ip, n.P2P, id)
137+
if n.QUIC {
138+
return fmt.Sprintf("/ip4/%s/udp/%d/quic-v1/p2p/%s", ip, n.P2P, id)
139+
} else {
140+
return fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ip, n.P2P, id)
141+
}
137142
}
138143

139144
// NodeClient is a Node with attached grpc connection.
@@ -368,14 +373,21 @@ func deployPoetD(ctx *testcontext.Context, id string, flags ...DeploymentFlag) (
368373

369374
func deployBootnodeSvc(ctx *testcontext.Context, id string) error {
370375
labels := nodeLabels(bootnodeApp, id)
376+
p2pProto := apiv1.ProtocolTCP
377+
if ctx.QUIC {
378+
p2pProto = apiv1.ProtocolUDP
379+
}
371380
svc := corev1.Service(id, ctx.Namespace).
372381
WithLabels(labels).
373382
WithSpec(corev1.ServiceSpec().
374383
WithSelector(labels).
375384
WithPorts(
376-
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).WithProtocol("TCP"),
377-
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).WithProtocol("TCP"),
378-
corev1.ServicePort().WithName("p2p").WithPort(7513).WithProtocol("TCP"),
385+
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).
386+
WithProtocol(apiv1.ProtocolTCP),
387+
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).
388+
WithProtocol(apiv1.ProtocolTCP),
389+
corev1.ServicePort().WithName("p2p").WithPort(7513).
390+
WithProtocol(p2pProto),
379391
).
380392
WithClusterIP("None"),
381393
)
@@ -388,15 +400,23 @@ func deployBootnodeSvc(ctx *testcontext.Context, id string) error {
388400

389401
func deployNodeSvc(ctx *testcontext.Context, id string) error {
390402
labels := nodeLabels(smesherApp, id)
403+
p2pProto := apiv1.ProtocolTCP
404+
if ctx.QUIC {
405+
p2pProto = apiv1.ProtocolUDP
406+
}
391407
svc := corev1.Service(id, ctx.Namespace).
392408
WithLabels(labels).
393409
WithSpec(corev1.ServiceSpec().
394410
WithSelector(labels).
395411
WithPorts(
396-
corev1.ServicePort().WithName("p2p").WithPort(7513).WithProtocol("TCP"),
397-
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).WithProtocol("TCP"),
398-
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).WithProtocol("TCP"),
399-
corev1.ServicePort().WithName("grpc-post").WithPort(9094).WithProtocol("TCP"),
412+
corev1.ServicePort().WithName("p2p").WithPort(7513).
413+
WithProtocol(p2pProto),
414+
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).
415+
WithProtocol(apiv1.ProtocolTCP),
416+
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).
417+
WithProtocol(apiv1.ProtocolTCP),
418+
corev1.ServicePort().WithName("grpc-post").WithPort(9094).
419+
WithProtocol(apiv1.ProtocolTCP),
400420
).
401421
WithClusterIP("None"),
402422
)
@@ -581,6 +601,7 @@ func deployNodes(ctx *testcontext.Context, kind string, from, to int, opts ...De
581601
P2P: 7513,
582602
GRPC_PUB: 9092,
583603
GRPC_PRIV: 9093,
604+
QUIC: ctx.QUIC,
584605
},
585606
}
586607
return nil
@@ -654,6 +675,7 @@ func deployRemoteNodes(ctx *testcontext.Context, from, to int,
654675
P2P: 7513,
655676
GRPC_PUB: 9092,
656677
GRPC_PRIV: 9093,
678+
QUIC: ctx.QUIC,
657679
},
658680
}
659681
return nil
@@ -726,6 +748,15 @@ func deployNode(ctx *testcontext.Context, id string, labels map[string]string, f
726748
for _, flag := range flags {
727749
cmd = append(cmd, flag.Flag())
728750
}
751+
p2pProto := apiv1.ProtocolTCP
752+
if ctx.QUIC {
753+
p2pProto = apiv1.ProtocolUDP
754+
cmd = append(cmd,
755+
"--listen", "/ip4/0.0.0.0/udp/7513/quic-v1",
756+
"--enable-tcp-transport=false",
757+
"--enable-quic-transport=true",
758+
)
759+
}
729760
deployment := appsv1.Deployment(id, ctx.Namespace).
730761
WithLabels(labels).
731762
WithSpec(appsv1.DeploymentSpec().
@@ -757,7 +788,7 @@ func deployNode(ctx *testcontext.Context, id string, labels map[string]string, f
757788
WithImage(ctx.Image).
758789
WithImagePullPolicy(apiv1.PullIfNotPresent).
759790
WithPorts(
760-
corev1.ContainerPort().WithContainerPort(7513).WithName("p2p"),
791+
corev1.ContainerPort().WithContainerPort(7513).WithName("p2p").WithProtocol(p2pProto),
761792
corev1.ContainerPort().WithContainerPort(9092).WithName("grpc-pub"),
762793
corev1.ContainerPort().WithContainerPort(9093).WithName("grpc-priv"),
763794
corev1.ContainerPort().WithContainerPort(9094).WithName("grpc-post"),

systest/testcontext/context.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ var (
132132
LayersPerEpoch = parameters.Int(
133133
ParamLayersPerEpoch, "number of layers in an epoch", 4,
134134
)
135+
quic = parameters.Bool(
136+
"quic", "if true, QUIC is used for the tests instead of TCP",
137+
)
135138
)
136139

137140
const nsfile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
@@ -175,6 +178,7 @@ type Context struct {
175178
Class string
176179
}
177180
NodeSelector map[string]string
181+
QUIC bool
178182
Log *zap.SugaredLogger
179183
}
180184

@@ -356,6 +360,7 @@ func New(t *testing.T, opts ...Opt) *Context {
356360
PostServiceImage: postServiceImage.Get(p),
357361
PostInitImage: postInitImage.Get(p),
358362
NodeSelector: nodeSelector.Get(p),
363+
QUIC: quic.Get(p),
359364
Log: logger.Sugar().Named(t.Name()),
360365
}
361366
cctx.Storage.Class = class

0 commit comments

Comments
 (0)