Skip to content

test/e2e: add CockroachDB test script with custom devDB support#326

Merged
giautm merged 6 commits intomasterfrom
copilot/add-crdb-test-script
Jan 28, 2026
Merged

test/e2e: add CockroachDB test script with custom devDB support#326
giautm merged 6 commits intomasterfrom
copilot/add-crdb-test-script

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 26, 2026

Plan for Adding CockroachDB Test Script

This PR adds a new test script for CockroachDB (CRDB) based on the existing MySQL schema-custom-devdb.txtar test.

Checklist:

  • Create schema-cockroachdb-custom-devdb.txtar test file with CockroachDB-specific configuration
  • Add CockroachDB support to test framework (dbConfig)
  • Add support for container args in dbConfig struct
  • Validate the test file format matches existing txtar test structure
  • Verify code compiles successfully
  • Fix startup probe to use SQL check instead of cockroach init
  • Add COCKROACH_DATABASE env var to schema-invalid.yaml for consistency with MySQL test pattern
  • Fix pod readiness issue by using HTTP health checks instead of SQL probes
  • Bind HTTP server to 0.0.0.0 for Kubernetes probes to work correctly
  • Review and finalize changes
Original prompt

This PR introduces a new test script for CockroachDB (CRDB), inspired by the existing schema-custom-devdb.txtar test script for MySQL. The CRDB script has been tailored to work with CockroachDB, including updated container details, SQL schema, and corresponding configurations.\n\n---\n\nContents of the new CRDB test script:\nplaintext\n1| db cockroachdb/cockroach:latest DB_URL\n2| kubectl create secret generic db-creds --from-literal=url=${DB_URL}\n3| \n4| # Wait for the first pod to be created\n5| kubectl-wait-available deploy/cockroachdb\n6| # Wait for the DB ready before creating the schema\n7| kubectl-wait-ready -l app=cockroachdb pods\n8| \n9| # Create the configmap to store the schema.sql\n10| kubectl create configmap crdb-schema --from-file=./schema-v1 --dry-run=client -o yaml\n11| stdin stdout\n12| kubectl apply -f -\n13| \n14| # Create the schema\n15| kubectl apply -f schema.yaml\n16| kubectl-wait-ready AtlasSchema/cockroachdb\n17| \n18| kubectl get -o jsonpath --template='{.status.observed_hash}' AtlasSchema/cockroachdb\n19| stdout oAoRLC2AXyGha6pKDollSqBB5ovjB\+qK78aAN9dkOow\=\n20| \n21| # Make sure the dev database with the custom container is created\n22| kubectl get deployment cockroachdb-atlas-dev-db -o jsonpath='{.spec.template.spec.containers[0].name}'\n23| stdout cockroachdb-dev-foo\n24| \n25| -- schema-v1/schema.sql --\n26| create table users (\n27| id serial primary key,\n28| name varchar(255) not null,\n29| email varchar(255) unique not null,\n30| short_bio varchar(255) not null\n31| );\n32| -- schema.yaml --\n33| apiVersion: db.atlasgo.io/v1alpha1\n34| kind: AtlasSchema\n35| metadata:\n36| name: cockroachdb\n37| spec:\n38| urlFrom:\n39| secretKeyRef:\n40| name: db-creds\n41| key: url\n42| schema:\n43| configMapKeyRef:\n44| key: schema.sql\n45| name: crdb-schema\n46| devURL: postgres://root:pass@localhost:26257/dev?sslmode=disable\n47| devDB:\n48| spec:\n49| containers:\n50| - name: cockroachdb-dev-foo\n51| image: cockroachdb/cockroach:latest\n52| args: ["start-single-node", "--insecure"]\n53| env:\n54| - name: COCKROACH_DATABASE\n55| value: dev\n56| ports:\n57| - containerPort: 26257\n58| name: cockroachdb\n59| readinessProbe:\n60| exec:\n61| command:\n62| - cockroach\n63| - sql\n64| - --insecure\n65| - -e\n66| - SELECT 1\n67| periodSeconds: 5\n68| failureThreshold: 3\n69| startupProbe:\n70| exec:\n71| command: ["cockroach", "init", "--insecure"]\n72| failureThreshold: 30\n73| periodSeconds: 10\n74| \n75| -- schema-invalid.yaml --\n76| apiVersion: db.atlasgo.io/v1alpha1\n77| kind: AtlasSchema\n78| metadata:\n79| name: cockroachdb\n80| spec:\n81| urlFrom:\n82| secretKeyRef:\n83| name: db-creds\n84| key: url\n85| schema:\n86| configMapKeyRef:\n87| key: schema.sql\n88| name: crdb-schema\n89| devDB:\n90| spec:\n91| containers:\n92| - name: cockroachdb-dev-foo\n93| image: cockroachdb/cockroach:latest\n94| args: ["start-single-node", "--insecure"]\n95| ports:\n96| - containerPort: 26257\n97| name: cockroachdb\n98| readinessProbe:\n99| exec:\n100| command:\n101| - cockroach\n102| - sql\n103| - --insecure\n104| - -e\n105| - SELECT 1\n106| periodSeconds: 5\n107| failureThreshold: 3\n108| startupProbe:\n109| exec:\n110| command: ["cockroach", "init", "--insecure"]\n111| failureThreshold: 30\n112| periodSeconds: 10\n

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 26, 2026 20:50
Co-authored-by: giautm <12751435+giautm@users.noreply.github.com>
Co-authored-by: giautm <12751435+giautm@users.noreply.github.com>
Co-authored-by: giautm <12751435+giautm@users.noreply.github.com>
Co-authored-by: giautm <12751435+giautm@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new test script for CockroachDB based on MySQL Add CockroachDB test script with custom devDB support Jan 26, 2026
Copilot AI requested a review from giautm January 26, 2026 20:58
@giautm giautm changed the title Add CockroachDB test script with custom devDB support test/e2e: add CockroachDB test script with custom devDB support Jan 26, 2026
@giautm
Copy link
Copy Markdown
Member

giautm commented Jan 27, 2026

@copilot the pod CockroachDB never in ready state after created, check and fix the issue.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot the pod CockroachDB never in ready state after created, check and fix the issue.

Fixed in commit 1f0d749. The issue was that the SQL-based probes were running before CockroachDB completed initialization. Changed to use HTTP health checks on port 8080 (/health for startup, /health?ready=1 for readiness) which CockroachDB exposes and are available immediately when the process starts.

@giautm
Copy link
Copy Markdown
Member

giautm commented Jan 27, 2026

@copilot the pod CockroachDB never in ready state after created, check and fix the issue.

Fixed in commit 1f0d749. The issue was that the SQL-based probes were running before CockroachDB completed initialization. Changed to use HTTP health checks on port 8080 (/health for startup, /health?ready=1 for readiness) which CockroachDB exposes and are available immediately when the process starts.

@copilot still it unable to run. Can you try to run the container directly and check its status, health, etc?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot the pod CockroachDB never in ready state after created, check and fix the issue.

Fixed in commit [1f0d749](1f0d7496f30821d7f66b3c3fbd...

Fixed in commit f04b5b4. The issue was that CockroachDB's HTTP server binds to localhost (127.0.0.1) by default, which is not accessible from Kubernetes probes. Added --http-addr=0.0.0.0:8080 to bind the HTTP server to all interfaces, allowing the health check probes to reach the container from within Kubernetes. I tested the container directly and confirmed both the /health and /health?ready=1 endpoints work correctly, as well as SQL connectivity.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • instance-data.ec2.internal
    • Triggering command: /cockroach/cockroach /cockroach/cockroach start-single-node --listening-url-file=server_fifo --pid-file=server_pid --advertise-addr=127.0.0.1:26257 --certs-dir=certs --log=file-defaults: {dir: ./cockroach-data/logs} --insecure (dns block)
    • Triggering command: /cockroach/cockroach /cockroach/cockroach start-single-node --listening-url-file=server_fifo --pid-file=server_pid --advertise-addr=127.0.0.1:26257 --certs-dir=certs --log=file-defaults: {dir: ./cockroach-data/logs} --insecure --http-addr=0.0.0.0:8080 (dns block)
  • metadata.google.internal
    • Triggering command: /cockroach/cockroach /cockroach/cockroach start-single-node --listening-url-file=server_fifo --pid-file=server_pid --advertise-addr=127.0.0.1:26257 --certs-dir=certs --log=file-defaults: {dir: ./cockroach-data/logs} --insecure (dns block)
    • Triggering command: /cockroach/cockroach /cockroach/cockroach start-single-node --listening-url-file=server_fifo --pid-file=server_pid --advertise-addr=127.0.0.1:26257 --certs-dir=certs --log=file-defaults: {dir: ./cockroach-data/logs} --insecure --http-addr=0.0.0.0:8080 (dns block)
  • register.cockroachdb.com
    • Triggering command: /cockroach/cockroach /cockroach/cockroach start-single-node --listening-url-file=server_fifo --pid-file=server_pid --advertise-addr=127.0.0.1:26257 --certs-dir=certs --log=file-defaults: {dir: ./cockroach-data/logs} --insecure (dns block)
    • Triggering command: /cockroach/cockroach /cockroach/cockroach start-single-node --listening-url-file=server_fifo --pid-file=server_pid --advertise-addr=127.0.0.1:26257 --certs-dir=certs --log=file-defaults: {dir: ./cockroach-data/logs} --insecure --http-addr=0.0.0.0:8080 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@giautm giautm force-pushed the copilot/add-crdb-test-script branch from f04b5b4 to 75e596d Compare January 28, 2026 07:34
@giautm giautm marked this pull request as ready for review January 28, 2026 07:35
@giautm giautm force-pushed the copilot/add-crdb-test-script branch from 75e596d to fd7c6af Compare January 28, 2026 08:32
@giautm giautm merged commit 6ac44cc into master Jan 28, 2026
3 of 4 checks passed
@giautm giautm deleted the copilot/add-crdb-test-script branch January 28, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants