Skip to content

Commit 43fce69

Browse files
authored
Merge pull request #107 from numtide/add-resource-handler-specific-child-resource-sample
Add back child resource samples for e2e testing
2 parents 18db56f + bd8af3b commit 43fce69

File tree

9 files changed

+205
-11
lines changed

9 files changed

+205
-11
lines changed

pkg/resource-handler/controller/cell/cell_controller_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ func TestCellReconciler_Reconcile(t *testing.T) {
9494
},
9595
Spec: multigresv1alpha1.CellSpec{
9696
Name: "zone2",
97+
Images: multigresv1alpha1.CellImages{
98+
MultiGateway: "custom/multigateway:v1.0.0",
99+
},
97100
MultiGateway: multigresv1alpha1.StatelessSpec{
98101
Replicas: ptr.To(int32(5)),
99102
},
100-
MultiGatewayImage: "custom/multigateway:v1.0.0",
101103
},
102104
},
103105
existingObjects: []client.Object{

pkg/resource-handler/controller/cell/integration_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ func TestCellReconciliation(t *testing.T) {
6969
Spec: multigresv1alpha1.CellSpec{
7070
Name: "zone1",
7171
Zone: "us-west-1a",
72+
Images: multigresv1alpha1.CellImages{
73+
MultiGateway: "ghcr.io/multigres/multigres:main",
74+
},
7275
MultiGateway: multigresv1alpha1.StatelessSpec{
7376
Replicas: ptr.To(int32(2)),
7477
},
@@ -153,6 +156,9 @@ func TestCellReconciliation(t *testing.T) {
153156
Spec: multigresv1alpha1.CellSpec{
154157
Name: "zone2",
155158
Zone: "us-west-1b",
159+
Images: multigresv1alpha1.CellImages{
160+
MultiGateway: "ghcr.io/multigres/multigres:main",
161+
},
156162
MultiGateway: multigresv1alpha1.StatelessSpec{
157163
Replicas: ptr.To(int32(3)),
158164
},
@@ -235,9 +241,11 @@ func TestCellReconciliation(t *testing.T) {
235241
Namespace: "default",
236242
},
237243
Spec: multigresv1alpha1.CellSpec{
238-
Name: "zone3",
239-
Zone: "us-west-1c",
240-
MultiGatewayImage: "custom/multigateway:v1.0.0",
244+
Name: "zone3",
245+
Zone: "us-west-1c",
246+
Images: multigresv1alpha1.CellImages{
247+
MultiGateway: "custom/multigateway:v1.0.0",
248+
},
241249
MultiGateway: multigresv1alpha1.StatelessSpec{
242250
Replicas: ptr.To(int32(2)),
243251
},
@@ -322,6 +330,9 @@ func TestCellReconciliation(t *testing.T) {
322330
Spec: multigresv1alpha1.CellSpec{
323331
Name: "zone4",
324332
Zone: "us-west-1d",
333+
Images: multigresv1alpha1.CellImages{
334+
MultiGateway: "ghcr.io/multigres/multigres:main",
335+
},
325336
MultiGateway: multigresv1alpha1.StatelessSpec{
326337
Replicas: ptr.To(int32(2)),
327338
Affinity: &corev1.Affinity{

pkg/resource-handler/controller/cell/multigateway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func BuildMultiGatewayDeployment(
4545
}
4646

4747
image := DefaultMultiGatewayImage
48-
if cell.Spec.MultiGatewayImage != "" {
49-
image = cell.Spec.MultiGatewayImage
48+
if cell.Spec.Images.MultiGateway != "" {
49+
image = cell.Spec.Images.MultiGateway
5050
}
5151

5252
name := cell.Name + "-multigateway"

pkg/resource-handler/controller/cell/multigateway_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ func TestBuildMultiGatewayDeployment(t *testing.T) {
236236
UID: "image-uid",
237237
},
238238
Spec: multigresv1alpha1.CellSpec{
239-
Name: "zone3",
240-
MultiGatewayImage: "custom/multigateway:v1.2.3",
239+
Name: "zone3",
240+
Images: multigresv1alpha1.CellImages{
241+
MultiGateway: "custom/multigateway:v1.2.3",
242+
},
241243
GlobalTopoServer: multigresv1alpha1.GlobalTopoServerRef{
242244
Address: "global-topo:2379",
243245
RootPath: "/multigres/global",
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: multigres.com/v1alpha1
2+
kind: Cell
3+
metadata:
4+
name: kind-cell-sample
5+
namespace: default
6+
spec:
7+
# Logical name of the cell
8+
name: zone-a
9+
10+
# Physical zone placement (use either 'zone' or 'region', not both)
11+
zone: us-west-1a
12+
13+
# Container image for multigateway
14+
multigatewayImage: ghcr.io/multigres/multigres:main
15+
16+
# MultiGateway deployment - query routing
17+
multigateway:
18+
replicas: 1
19+
resources:
20+
requests:
21+
cpu: 50m
22+
memory: 128Mi
23+
limits:
24+
cpu: 200m
25+
memory: 256Mi
26+
27+
# Reference to the global topology server
28+
globalTopoServer:
29+
address: kind-global-topo:2379
30+
rootPath: /multigres/global
31+
implementation: etcd2
32+
33+
# Cell-local topology server configuration (optional)
34+
# If specified, creates a local etcd cluster for this cell
35+
topoServer:
36+
etcd:
37+
image: quay.io/coreos/etcd:v3.5.12
38+
replicas: 1
39+
storage:
40+
size: 1Gi
41+
resources:
42+
requests:
43+
cpu: 50m
44+
memory: 128Mi
45+
limits:
46+
cpu: 200m
47+
memory: 256Mi
48+
49+
# List of all cells in the cluster for discovery
50+
allCells:
51+
- zone-a
52+
53+
# Topology reconciliation settings
54+
topologyReconciliation:
55+
registerCell: true
56+
prunePoolers: true
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
apiVersion: multigres.com/v1alpha1
2+
kind: Shard
3+
metadata:
4+
name: kind-shard-sample
5+
namespace: default
6+
spec:
7+
# Shard identification
8+
databaseName: mydb
9+
tableGroupName: users
10+
shardName: "0"
11+
12+
# Container images for shard components
13+
images:
14+
multiorch: ghcr.io/multigres/multigres:main
15+
multipooler: ghcr.io/multigres/multigres:main
16+
postgres: postgres:16-alpine
17+
18+
# Reference to the global topology server
19+
globalTopoServer:
20+
address: kind-global-topo:2379
21+
rootPath: /multigres/global
22+
implementation: etcd2
23+
24+
# MultiOrch configuration for shard orchestration
25+
multiorch:
26+
cells:
27+
- zone-a
28+
replicas: 1
29+
resources:
30+
requests:
31+
cpu: 50m
32+
memory: 64Mi
33+
limits:
34+
cpu: 200m
35+
memory: 128Mi
36+
37+
# Shard pools - different types of PostgreSQL replicas
38+
pools:
39+
# Primary replica pool
40+
primary:
41+
type: readWrite
42+
cells:
43+
- zone-a
44+
replicasPerCell: 1
45+
46+
# Storage configuration - kind uses local storage provisioner
47+
storage:
48+
size: 1Gi
49+
50+
# PostgreSQL container configuration - lower resources for kind
51+
postgres:
52+
resources:
53+
requests:
54+
cpu: 100m
55+
memory: 256Mi
56+
limits:
57+
cpu: 500m
58+
memory: 512Mi
59+
60+
# MultiPooler container configuration
61+
multipooler:
62+
resources:
63+
requests:
64+
cpu: 50m
65+
memory: 64Mi
66+
limits:
67+
cpu: 200m
68+
memory: 128Mi
69+
70+
# Read replica pool
71+
replica:
72+
type: readOnly
73+
cells:
74+
- zone-a
75+
replicasPerCell: 1
76+
77+
storage:
78+
size: 1Gi
79+
80+
postgres:
81+
resources:
82+
requests:
83+
cpu: 100m
84+
memory: 256Mi
85+
limits:
86+
cpu: 500m
87+
memory: 512Mi
88+
89+
multipooler:
90+
resources:
91+
requests:
92+
cpu: 50m
93+
memory: 64Mi
94+
limits:
95+
cpu: 200m
96+
memory: 128Mi
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: multigres.com/v1alpha1
2+
kind: TopoServer
3+
metadata:
4+
name: kind-toposerver-sample
5+
namespace: default
6+
spec:
7+
# Etcd configuration for the topology server
8+
etcd:
9+
# etcd container image
10+
image: quay.io/coreos/etcd:v3.5.12
11+
12+
# Number of etcd replicas (must be odd: 1, 3, 5, etc.)
13+
# Using 1 replica for kind to minimize resource usage
14+
replicas: 1
15+
16+
# Storage configuration for etcd data - kind uses local storage provisioner
17+
storage:
18+
size: 1Gi
19+
20+
# Resource requirements for etcd containers - lower for kind
21+
resources:
22+
requests:
23+
cpu: 50m
24+
memory: 128Mi
25+
limits:
26+
cpu: 200m
27+
memory: 256Mi

pkg/resource-handler/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.0
44

55
require (
66
github.com/google/go-cmp v0.7.0
7-
github.com/numtide/multigres-operator/api v0.0.0-20251229104516-c9d07419a88e
7+
github.com/numtide/multigres-operator/api v0.0.0-20260103121224-057738b43b3b
88
github.com/numtide/multigres-operator/pkg/testutil v0.0.0-20251213002906-55493b734373
99
k8s.io/api v0.34.3
1010
k8s.io/apimachinery v0.34.3

pkg/resource-handler/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFd
9090
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
9191
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
9292
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
93-
github.com/numtide/multigres-operator/api v0.0.0-20251229104516-c9d07419a88e h1:dA5W+VZMTnSx4DtxjX/1Xw2IFY7uAhHBcMNA92NivgI=
94-
github.com/numtide/multigres-operator/api v0.0.0-20251229104516-c9d07419a88e/go.mod h1:A1bBmTxHr+362dGZ5G6u2S4xsP6enbgdUS/UJUOmKbc=
93+
github.com/numtide/multigres-operator/api v0.0.0-20260103121224-057738b43b3b h1:twErev/AdyVQvlYa5vbo5wqq+NlexZJmIm0pwEQd5qI=
94+
github.com/numtide/multigres-operator/api v0.0.0-20260103121224-057738b43b3b/go.mod h1:A1bBmTxHr+362dGZ5G6u2S4xsP6enbgdUS/UJUOmKbc=
9595
github.com/numtide/multigres-operator/pkg/testutil v0.0.0-20251213002906-55493b734373 h1:B9uGjUsG0rMi+dGt2blEDpr8wbwnE/W1xcpuxZwvOYk=
9696
github.com/numtide/multigres-operator/pkg/testutil v0.0.0-20251213002906-55493b734373/go.mod h1:+NQa7dSvQqxhBOE9XcE9RWXLvOvNaw0keCc29Y7pjyQ=
9797
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=

0 commit comments

Comments
 (0)