Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systest: add QUIC support #5902

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/systest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:

systest:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
protocol:
- tcp
- quic
if: ${{ needs.filter-changes.outputs.nondocchanges == 'true' }}
needs:
- filter-changes
Expand Down Expand Up @@ -118,7 +124,7 @@ jobs:
- name: Run tests
timeout-minutes: 60
env:
test_id: systest-${{ steps.vars.outputs.sha_short }}
test_id: systest-${{ steps.vars.outputs.sha_short }}${{ matrix.protocol == 'quic' && '-quic' || '' }}
label: sanity
storage: premium-rwo=10Gi
node_selector: cloud.google.com/gke-nodepool=gha
Expand All @@ -127,12 +133,14 @@ jobs:
level: ${{ inputs.log_level }}
clusters: 4
norbac: 1
quic: ${{ matrix.protocol == 'tcp' && 'false' || 'true' }}
run: make -C systest run test_name=${{ inputs.test_name }}

- name: Delete pod
if: always()
env:
test_id: systest-${{ steps.vars.outputs.sha_short }}
test_id: systest-${{ steps.vars.outputs.sha_short }}${{ matrix.protocol == 'quic' && '-quic' || '' }}
quic: ${{ matrix.protocol == 'tcp' && 'false' || 'true' }}
run: make -C systest clean

systest-status:
Expand Down
7 changes: 7 additions & 0 deletions systest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ post_service_image ?= $(org)/post-service:v0.7.6
post_init_image ?= $(org)/postcli:v0.12.5
smesher_image ?= $(org)/go-spacemesh-dev:$(version_info)
bs_image ?= $(org)/go-spacemesh-dev-bs:$(version_info)
quic ?= false
ifeq ($(quic),true)
test_id ?= systest-$(version_info)-quic
test_job_name ?= systest-$(version_info)-$(date)-quic
else
test_id ?= systest-$(version_info)
test_job_name ?= systest-$(version_info)-$(date)
endif
keep ?= false
clusters ?= 1
size ?= 10
Expand Down Expand Up @@ -63,6 +69,7 @@ template:
@echo post-init-image=$(post_init_image) >> $(tmpfile)
@echo keep=$(keep) >> $(tmpfile)
@echo testid=$(test_id) >> $(tmpfile)
@echo quic=$(quic) >> $(tmpfile)

.PHONY: config
config: template
Expand Down
1 change: 1 addition & 0 deletions systest/cluster/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func discoverNodes(ctx *testcontext.Context, kind string) ([]*NodeClient, error)
P2P: 7513,
GRPC_PUB: 9092,
GRPC_PRIV: 9093,
QUIC: ctx.QUIC,
},
})
}
Expand Down
49 changes: 40 additions & 9 deletions systest/cluster/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,16 @@ const (
type Node struct {
Name string
P2P, GRPC_PUB, GRPC_PRIV uint16
QUIC bool
}

// P2PEndpoint returns full p2p endpoint, including identity.
func p2pEndpoint(n Node, ip, id string) string {
return fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ip, n.P2P, id)
if n.QUIC {
return fmt.Sprintf("/ip4/%s/udp/%d/quic-v1/p2p/%s", ip, n.P2P, id)
} else {
return fmt.Sprintf("/ip4/%s/tcp/%d/p2p/%s", ip, n.P2P, id)
}
}

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

func deployBootnodeSvc(ctx *testcontext.Context, id string) error {
labels := nodeLabels(bootnodeApp, id)
p2pProto := apiv1.ProtocolTCP
if ctx.QUIC {
p2pProto = apiv1.ProtocolUDP
}
svc := corev1.Service(id, ctx.Namespace).
WithLabels(labels).
WithSpec(corev1.ServiceSpec().
WithSelector(labels).
WithPorts(
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).WithProtocol("TCP"),
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).WithProtocol("TCP"),
corev1.ServicePort().WithName("p2p").WithPort(7513).WithProtocol("TCP"),
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).
WithProtocol(apiv1.ProtocolTCP),
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).
WithProtocol(apiv1.ProtocolTCP),
corev1.ServicePort().WithName("p2p").WithPort(7513).
WithProtocol(p2pProto),
).
WithClusterIP("None"),
)
Expand All @@ -388,15 +400,23 @@ func deployBootnodeSvc(ctx *testcontext.Context, id string) error {

func deployNodeSvc(ctx *testcontext.Context, id string) error {
labels := nodeLabels(smesherApp, id)
p2pProto := apiv1.ProtocolTCP
if ctx.QUIC {
p2pProto = apiv1.ProtocolUDP
}
svc := corev1.Service(id, ctx.Namespace).
WithLabels(labels).
WithSpec(corev1.ServiceSpec().
WithSelector(labels).
WithPorts(
corev1.ServicePort().WithName("p2p").WithPort(7513).WithProtocol("TCP"),
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).WithProtocol("TCP"),
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).WithProtocol("TCP"),
corev1.ServicePort().WithName("grpc-post").WithPort(9094).WithProtocol("TCP"),
corev1.ServicePort().WithName("p2p").WithPort(7513).
WithProtocol(p2pProto),
corev1.ServicePort().WithName("grpc-pub").WithPort(9092).
WithProtocol(apiv1.ProtocolTCP),
corev1.ServicePort().WithName("grpc-priv").WithPort(9093).
WithProtocol(apiv1.ProtocolTCP),
corev1.ServicePort().WithName("grpc-post").WithPort(9094).
WithProtocol(apiv1.ProtocolTCP),
).
WithClusterIP("None"),
)
Expand Down Expand Up @@ -581,6 +601,7 @@ func deployNodes(ctx *testcontext.Context, kind string, from, to int, opts ...De
P2P: 7513,
GRPC_PUB: 9092,
GRPC_PRIV: 9093,
QUIC: ctx.QUIC,
},
}
return nil
Expand Down Expand Up @@ -654,6 +675,7 @@ func deployRemoteNodes(ctx *testcontext.Context, from, to int,
P2P: 7513,
GRPC_PUB: 9092,
GRPC_PRIV: 9093,
QUIC: ctx.QUIC,
},
}
return nil
Expand Down Expand Up @@ -726,6 +748,15 @@ func deployNode(ctx *testcontext.Context, id string, labels map[string]string, f
for _, flag := range flags {
cmd = append(cmd, flag.Flag())
}
p2pProto := apiv1.ProtocolTCP
if ctx.QUIC {
p2pProto = apiv1.ProtocolUDP
cmd = append(cmd,
"--listen", "/ip4/0.0.0.0/udp/7513/quic-v1",
"--enable-tcp-transport=false",
"--enable-quic-transport=true",
)
}
deployment := appsv1.Deployment(id, ctx.Namespace).
WithLabels(labels).
WithSpec(appsv1.DeploymentSpec().
Expand Down Expand Up @@ -757,7 +788,7 @@ func deployNode(ctx *testcontext.Context, id string, labels map[string]string, f
WithImage(ctx.Image).
WithImagePullPolicy(apiv1.PullIfNotPresent).
WithPorts(
corev1.ContainerPort().WithContainerPort(7513).WithName("p2p"),
corev1.ContainerPort().WithContainerPort(7513).WithName("p2p").WithProtocol(p2pProto),
corev1.ContainerPort().WithContainerPort(9092).WithName("grpc-pub"),
corev1.ContainerPort().WithContainerPort(9093).WithName("grpc-priv"),
corev1.ContainerPort().WithContainerPort(9094).WithName("grpc-post"),
Expand Down
5 changes: 5 additions & 0 deletions systest/testcontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ var (
LayersPerEpoch = parameters.Int(
ParamLayersPerEpoch, "number of layers in an epoch", 4,
)
quic = parameters.Bool(
"quic", "if true, QUIC is used for the tests instead of TCP",
)
)

const nsfile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
Expand Down Expand Up @@ -175,6 +178,7 @@ type Context struct {
Class string
}
NodeSelector map[string]string
QUIC bool
Log *zap.SugaredLogger
}

Expand Down Expand Up @@ -356,6 +360,7 @@ func New(t *testing.T, opts ...Opt) *Context {
PostServiceImage: postServiceImage.Get(p),
PostInitImage: postInitImage.Get(p),
NodeSelector: nodeSelector.Get(p),
QUIC: quic.Get(p),
Log: logger.Sugar().Named(t.Name()),
}
cctx.Storage.Class = class
Expand Down
1 change: 1 addition & 0 deletions systest/tests/distributed_post_verification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestPostMalfeasanceProof(t *testing.T) {
cfg.P2P.PrivateNetwork = true
cfg.Bootstrap.URL = cluster.BootstrapperGlobalEndpoint(ctx.Namespace, 0)
cfg.P2P.MinPeers = 2
cfg.P2P.EnableQUICTransport = ctx.QUIC
ctx.Log.Debugw("Prepared config", "cfg", cfg)

goldenATXID := cl.GoldenATX()
Expand Down
Loading