-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add foundational control plane support for Spock 6 clusters #457
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
base: main
Are you sure you want to change the base?
Changes from all commits
5fac615
17c1fbb
cc51563
875a554
5d7c834
974c883
ed2b97a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| //go:build e2e_test | ||
|
|
||
| package e2e | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/jackc/pgx/v5" | ||
| controlplane "github.com/pgEdge/control-plane/api/apiv1/gen/control_plane" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // spock6DevImage is a floating/mutable tag tracking the latest Spock 6 | ||
| // development build. Not pinned to a specific build number: the scheduled | ||
| // CI job re-running this test picks up whatever the tag currently resolves | ||
| // to, with no extra plumbing needed to point CI at "latest." | ||
| const spock6DevImage = "ghcr.io/pgedge/pgedge-postgres:18-spock6-standard" | ||
|
|
||
| // TestSpock6AddNode validates the add-node workflow end-to-end against a | ||
| // real Spock 6 cluster: creates a 2-node database pinned to a Spock 6 dev | ||
| // image via orchestrator_opts.swarm.image (bypassing manifest version | ||
| // constraints, since spock6 manifest entries are deliberately "dev" | ||
| // stability and never auto-selected), adds a 3rd node, and confirms the | ||
| // full mesh reaches "replicating" — exercising the Spock-major-gated | ||
| // spock.progress query (PeerCatchupResource). | ||
| func TestSpock6AddNode(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| const ( | ||
| username = "admin" | ||
| password = "password" | ||
| dbName = "spock6_add_node_db" | ||
| ) | ||
|
|
||
| ctx, cancel := context.WithTimeout(t.Context(), 10*time.Minute) | ||
| defer cancel() | ||
|
|
||
| hostIDs := fixture.HostIDs() | ||
|
|
||
| nodeSpec := func(name, hostID string) *controlplane.DatabaseNodeSpec { | ||
| return &controlplane.DatabaseNodeSpec{ | ||
| Name: name, | ||
| HostIds: []controlplane.Identifier{controlplane.Identifier(hostID)}, | ||
| OrchestratorOpts: &controlplane.OrchestratorOpts{ | ||
| Swarm: &controlplane.SwarmOpts{Image: pointerTo(spock6DevImage)}, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| t.Log("Step 1: Creating 2-node Spock 6 database fixture") | ||
| db := fixture.NewDatabaseFixture(ctx, t, &controlplane.CreateDatabaseRequest{ | ||
| Spec: &controlplane.DatabaseSpec{ | ||
| DatabaseName: dbName, | ||
| PostgresVersion: pointerTo("18.6"), | ||
| SpockVersion: pointerTo("6"), | ||
| Port: pointerTo(0), | ||
| PatroniPort: pointerTo(0), | ||
| DatabaseUsers: []*controlplane.DatabaseUserSpec{{ | ||
| Username: username, | ||
| Password: pointerTo(password), | ||
| DbOwner: pointerTo(true), | ||
| Attributes: []string{"LOGIN", "SUPERUSER"}, | ||
| }}, | ||
| Nodes: []*controlplane.DatabaseNodeSpec{ | ||
| nodeSpec("n1", hostIDs[0]), | ||
| nodeSpec("n2", hostIDs[1]), | ||
| }, | ||
| }, | ||
| }) | ||
| t.Logf("Database created: %s", db.ID) | ||
|
|
||
| t.Log("Step 2: Adding n3 node with n1 as source") | ||
| db.Spec.Nodes = append(db.Spec.Nodes, func() *controlplane.DatabaseNodeSpec { | ||
| n := nodeSpec("n3", hostIDs[2]) | ||
| n.SourceNode = pointerTo("n1") | ||
| return n | ||
| }()) | ||
| require.NoError(t, db.Update(ctx, UpdateOptions{Spec: db.Spec})) | ||
| t.Log("Add-node completed successfully against Spock 6") | ||
|
|
||
| t.Log("Step 3: Waiting for full mesh replication") | ||
| db.WaitForReplication(ctx, t, username, password) | ||
| t.Log("Replication complete") | ||
|
|
||
| t.Log("Step 4: Verifying spock.spock_version() reports major 6 on the new node") | ||
| n3Opts := ConnectionOptions{ | ||
| Matcher: And(WithNode("n3"), WithRole("primary")), | ||
| Username: username, | ||
| Password: password, | ||
| } | ||
| db.WithConnection(ctx, n3Opts, t, func(conn *pgx.Conn) { | ||
| var version string | ||
| err := conn.QueryRow(ctx, "SELECT spock.spock_version();").Scan(&version) | ||
| require.NoError(t, err) | ||
| assert.Regexp(t, `^6\.`, version, "expected node n3 to be running Spock 6, got %q", version) | ||
| }) | ||
|
Comment on lines
+29
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Preserve failed Spock 6 E2E environments. Add the standard 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a nightly job for this? It looks like we've only been publishing new images once every few weeks.