From bf9a262cfc34818aeca142995e83502872df626b Mon Sep 17 00:00:00 2001 From: ajaskolski Date: Fri, 24 Oct 2025 13:54:23 +0200 Subject: [PATCH 1/2] chore(tests): convert remote datastore remote tests to testcontainers approach using real service; add ci tests with real catalog service --- .github/workflows/pull-request-main.yml | 34 ++- .github/workflows/schedule-main.yml | 56 +++- datastore/catalog/remote/README.md | 85 +++++- datastore/catalog/remote/main_test.go | 73 +++++ .../catalog/remote/testcontainer_setup.go | 283 ++++++++++++++++++ go.mod | 1 + go.sum | 9 + 7 files changed, 532 insertions(+), 9 deletions(-) create mode 100644 datastore/catalog/remote/main_test.go create mode 100644 datastore/catalog/remote/testcontainer_setup.go diff --git a/.github/workflows/pull-request-main.yml b/.github/workflows/pull-request-main.yml index 09150304e..3deae7239 100644 --- a/.github/workflows/pull-request-main.yml +++ b/.github/workflows/pull-request-main.yml @@ -45,8 +45,8 @@ jobs: # disable the checkptr runtime check due a false positive in github.com/xssnick/tonutils-go # causing tests in ci to fail "fatal error: checkptr: pointer arithmetic result points to invalid allocation" # https://github.com/xssnick/tonutils-go/issues/310 - # Exclude provider packages which use Docker containers - go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -coverprofile=coverage.txt $(go list ./... | grep -v '/provider') + # Exclude provider packages which use Docker containers and remote catalog tests + go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -coverprofile=coverage.txt $(go list ./... | grep -v '/provider' | grep -v '/remote') use-go-cache: true artifact-name: unit-tests @@ -71,11 +71,39 @@ jobs: use-go-cache: true artifact-name: provider-tests + ci-test-catalog-remote: + name: Catalog Remote Tests + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + id-token: write + contents: read + actions: read + env: + CATALOG_SERVICE_IMAGE: ${{ secrets.AWS_ACCOUNT_NUMBER_PROD }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/op-catalog-service:latest + steps: + - name: Pull Catalog Service ECR Image + uses: smartcontractkit/.github/actions/pull-private-ecr-image@2f8f0baf38e46140c6a119eb551a56eaaabcc09e # pull-private-ecr-image@1.0.0 + with: + aws-account-number: ${{ secrets.AWS_ACCOUNT_NUMBER_PROD }} + aws-region: ${{ secrets.AWS_REGION }} + aws-role-arn: ${{ secrets.ECR_READ_ROLE_ARN }} + ecr-repository: "op-catalog-service" + image-tag: "latest" + + - name: Run Catalog Remote Integration Tests + uses: smartcontractkit/.github/actions/ci-test-go@dfcba48f05933158428bce867d790e3d5a9baa6b # ci-test-go@1.1.0 + with: + # Must cd into datastore/catalog/remote because TestMain only runs from package directory + go-test-cmd: cd datastore/catalog/remote && go test -v -race -timeout 10m -gcflags=all=-d=checkptr=0 -coverprofile=../../../coverage.txt + use-go-cache: true + artifact-name: catalog-remote-tests + sonarqube: name: Sonar Scan if: github.event_name == 'pull_request' runs-on: ubuntu-24.04 - needs: [ci-test, ci-test-provider, ci-lint-misc, ci-lint] + needs: [ci-test, ci-test-provider, ci-test-catalog-remote, ci-lint-misc, ci-lint] permissions: contents: read actions: read diff --git a/.github/workflows/schedule-main.yml b/.github/workflows/schedule-main.yml index 33fbf4bec..66afff515 100644 --- a/.github/workflows/schedule-main.yml +++ b/.github/workflows/schedule-main.yml @@ -40,19 +40,65 @@ jobs: actions: read steps: - name: Build and test - uses: smartcontractkit/.github/actions/ci-test-go@eeb76b5870e3c17856d5a60fd064a053c023b5f5 # ci-test-go@1.0.0 + uses: smartcontractkit/.github/actions/ci-test-go@dfcba48f05933158428bce867d790e3d5a9baa6b # ci-test-go@1.1.0 + with: + # disable the checkptr runtime check due a false positive in github.com/xssnick/tonutils-go + # Exclude provider packages which use Docker containers and remote catalog tests + go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -coverprofile=coverage.txt $(go list ./... | grep -v '/provider' | grep -v '/remote') + use-go-cache: true + artifact-name: unit-tests + + ci-test-provider: + name: Provider Tests + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + id-token: write + contents: read + actions: read + steps: + - name: Build and test provider packages + uses: smartcontractkit/.github/actions/ci-test-go@dfcba48f05933158428bce867d790e3d5a9baa6b # ci-test-go@1.1.0 with: # disable the checkptr runtime check due a false positive in github.com/xssnick/tonutils-go - # causing tests in ci to fail "fatal error: checkptr: pointer arithmetic result points to invalid allocation" - # https://github.com/xssnick/tonutils-go/issues/310 # -p 2 -parallel 3 = 2 packages, 3 tests max = 6 containers max - go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -p 2 -parallel 3 -coverprofile=coverage.txt $(go list ./...) + # Only run provider packages which use Docker containers + go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -p 2 -parallel 3 -coverprofile=coverage.txt $(go list ./... | grep '/provider') + use-go-cache: true + artifact-name: provider-tests + + ci-test-catalog-remote: + name: Catalog Remote Tests + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + id-token: write + contents: read + actions: read + env: + CATALOG_SERVICE_IMAGE: ${{ secrets.AWS_ACCOUNT_NUMBER_PROD }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/op-catalog-service:latest + steps: + - name: Pull Catalog Service ECR Image + uses: smartcontractkit/.github/actions/pull-private-ecr-image@2f8f0baf38e46140c6a119eb551a56eaaabcc09e # pull-private-ecr-image@1.0.0 + with: + aws-account-number: ${{ secrets.AWS_ACCOUNT_NUMBER_PROD }} + aws-region: ${{ secrets.AWS_REGION }} + aws-role-arn: ${{ secrets.ECR_READ_ROLE_ARN }} + ecr-repository: "op-catalog-service" + image-tag: "latest" + + - name: Run Catalog Remote Integration Tests + uses: smartcontractkit/.github/actions/ci-test-go@dfcba48f05933158428bce867d790e3d5a9baa6b # ci-test-go@1.1.0 + with: + # Must cd into datastore/catalog/remote because TestMain only runs from package directory + go-test-cmd: cd datastore/catalog/remote && go test -v -race -timeout 10m -gcflags=all=-d=checkptr=0 -coverprofile=../../../coverage.txt use-go-cache: true + artifact-name: catalog-remote-tests sonarqube: name: Sonar Scan runs-on: ubuntu-24.04 - needs: [ci-test, ci-lint-misc, ci-lint] + needs: [ci-test, ci-test-provider, ci-test-catalog-remote, ci-lint-misc, ci-lint] permissions: contents: read actions: read diff --git a/datastore/catalog/remote/README.md b/datastore/catalog/remote/README.md index 34e1e4581..164125111 100644 --- a/datastore/catalog/remote/README.md +++ b/datastore/catalog/remote/README.md @@ -6,4 +6,87 @@ state to be maintained through that stream connection. If the stream closes, normal cleanup will rollback the transaction. The [Catalog service APIs] include message to begin, commit, and roll-back a transaction. -[Catalog service APIs]: http://github.com/smartcontractkit/chainlink-catalog +[Catalog service APIs]: http://github.com/smartcontractkit/op-catalog + +## Running Tests + +The tests in this package use **testcontainers** to automatically start the required services: +- PostgreSQL database +- Catalog service (from ECR or local image) +- Database migration + +**Important:** Testcontainers uses images from your local Docker daemon. You must either: +1. Build the image locally: `docker build -t op-catalog-service:latest .` +2. Pull from ECR with a specific tag: `docker pull 123123123123.dkr.ecr.us-east-1.amazonaws.com/chainlink-catalog-service:TAG` + - Use `aws ecr describe-images` to find available tags + - Common patterns: version tags (v0.0.1) + +### Quick Start (Local Build) + +```bash +# Build the catalog service image first +cd op-catalog +docker build -t op-catalog-service:latest . + +# Run the tests (must be in the remote directory) +cd ../chainlink-deployments-framework/datastore/catalog/remote +go test -v +``` + +## Configuration Options + +### Environment Variables + +- `CATALOG_SERVICE_IMAGE`: The Docker image to use for the catalog service + - Default: `op-catalog-service:latest` + - CI: Set to the ECR image URL + - Example: `export CATALOG_SERVICE_IMAGE="123456789.dkr.ecr.us-east-1.amazonaws.com/op-catalog-service:latest"` + +- `CATALOG_GRPC_ADDRESS`: Connect to an existing catalog service instead of starting containers + - Example: `export CATALOG_GRPC_ADDRESS="localhost:8080"` + +## Running Without Testcontainers + +If you prefer to manage the services manually: + +### Option 1: Docker Compose + +```bash +cd op-catalog +docker-compose up -d + +# Wait for the service to be ready +sleep 5 + +# Run tests pointing to the local service +cd ../chainlink-deployments-framework/datastore/catalog/remote +export CATALOG_GRPC_ADDRESS="localhost:8080" +go test -v +``` + +## CI/CD Integration + +The CI workflow automatically: +1. Downloads the latest Catalog service image from ECR +2. Runs the tests with testcontainers using the downloaded image +3. Generates coverage reports + +See `.github/workflows/pull-request-main.yml` for the full configuration. + +## Test Workflow + +The test setup follows this flow: + +1. **TestMain** (`main_test.go`) - Entry point that: + - Checks for `CATALOG_GRPC_ADDRESS` environment variable + - If not set, starts testcontainers automatically + - Sets up PostgreSQL and Catalog service + - Runs all tests + - Cleans up containers + +2. **TestContainerSetup** (`testcontainer_setup.go`) - Manages: + - Docker network creation + - PostgreSQL container startup + - Database migration via catalog service + - Catalog service container startup + - Port mapping and connection details diff --git a/datastore/catalog/remote/main_test.go b/datastore/catalog/remote/main_test.go new file mode 100644 index 000000000..db96ba860 --- /dev/null +++ b/datastore/catalog/remote/main_test.go @@ -0,0 +1,73 @@ +package remote + +import ( + "context" + "log" + "os" + "testing" + "time" +) + +var ( + // globalTestSetup is the shared testcontainer setup for all remote tests + globalTestSetup *TestContainerSetup + // catalogGRPCAddress is the address of the catalog service for tests + catalogGRPCAddress string +) + +// TestMain is the entry point for all tests in this package +// It sets up testcontainers once for all tests and tears them down at the end +func TestMain(m *testing.M) { + // Check if we should use an existing catalog service instead of testcontainers + existingAddr := os.Getenv("CATALOG_GRPC_ADDRESS") + if existingAddr != "" { + log.Printf("Using existing catalog service at: %s", existingAddr) + catalogGRPCAddress = existingAddr + // Run tests and exit + os.Exit(m.Run()) + } + + // Setup context with timeout for initialization + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() + + log.Println("========================================") + log.Println("Setting up testcontainers for catalog remote tests...") + log.Println("========================================") + + // Setup testcontainers + setup, err := SetupCatalogTestContainers(ctx) + if err != nil { + log.Fatalf("Failed to setup testcontainers: %v", err) + } + globalTestSetup = setup + catalogGRPCAddress = setup.GetCatalogGRPCAddress() + + log.Println("========================================") + log.Println("Testcontainers setup complete!") + log.Printf("PostgreSQL DSN: %s", setup.PostgresDSN) + log.Printf("Catalog gRPC Address: %s", catalogGRPCAddress) + log.Println("========================================") + + // Set the environment variable so tests can find the service + os.Setenv("CATALOG_GRPC_ADDRESS", catalogGRPCAddress) + + // Run all tests + exitCode := m.Run() + + // Cleanup + log.Println("========================================") + log.Println("Cleaning up testcontainers...") + log.Println("========================================") + + // Use a fresh context for cleanup to avoid timeout issues + cleanupCtx, cleanupCancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cleanupCancel() + + if err := globalTestSetup.Teardown(cleanupCtx); err != nil { + log.Printf("Warning: Failed to teardown testcontainers: %v", err) + } + + log.Println("Cleanup complete!") + os.Exit(exitCode) +} diff --git a/datastore/catalog/remote/testcontainer_setup.go b/datastore/catalog/remote/testcontainer_setup.go new file mode 100644 index 000000000..22472230c --- /dev/null +++ b/datastore/catalog/remote/testcontainer_setup.go @@ -0,0 +1,283 @@ +package remote + +import ( + "context" + "fmt" + "log" + "os" + "strings" + "time" + + "github.com/testcontainers/testcontainers-go" + "github.com/testcontainers/testcontainers-go/modules/postgres" + "github.com/testcontainers/testcontainers-go/network" + "github.com/testcontainers/testcontainers-go/wait" +) + +const ( + postgresImage = "postgres:16-alpine" + postgresContainerName = "postgres-container" + postgresUser = "postgres" + postgresPassword = "postgres" + postgresDB = "op_catalog_db" + postgresPort = "5432" + catalogImageEnv = "CATALOG_SERVICE_IMAGE" + catalogImageRepo = "op-catalog-service" + catalogImageTag = "latest" + catalogPort = "8080" + networkName = "chainlink_catalog_network" +) + +// TestContainerSetup holds all testcontainer resources for catalog service testing +type TestContainerSetup struct { + PostgresContainer *postgres.PostgresContainer + CatalogContainer testcontainers.Container + PostgresDSN string + CatalogGRPCAddr string + Network *testcontainers.DockerNetwork +} + +// SetupCatalogTestContainers initializes all required containers for testing: +// 1. PostgreSQL database +// 2. Catalog service (with db migration) +func SetupCatalogTestContainers(ctx context.Context) (*TestContainerSetup, error) { + setup := &TestContainerSetup{} + + // Create a network for containers to communicate + net, err := network.New(ctx, network.WithDriver("bridge")) + if err != nil { + return nil, fmt.Errorf("failed to create network: %w", err) + } + setup.Network = net + + // Start PostgreSQL + log.Println("Starting PostgreSQL container...") + if err := setup.startPostgres(ctx); err != nil { + return nil, fmt.Errorf("failed to start postgres: %w", err) + } + log.Printf("PostgreSQL started at: %s", setup.PostgresDSN) + + // Start Catalog Service (which includes migration step) + log.Println("Starting Catalog service container...") + if err := setup.startCatalogService(ctx); err != nil { + return nil, fmt.Errorf("failed to start catalog service: %w", err) + } + log.Printf("Catalog service started at: %s", setup.CatalogGRPCAddr) + + return setup, nil +} + +// startPostgres starts a PostgreSQL container +func (s *TestContainerSetup) startPostgres(ctx context.Context) error { + postgresContainer, err := postgres.Run(ctx, + postgresImage, + postgres.WithDatabase(postgresDB), + postgres.WithUsername(postgresUser), + postgres.WithPassword(postgresPassword), + testcontainers.WithWaitStrategy( + wait.ForLog("database system is ready to accept connections"). + WithOccurrence(2). + WithStartupTimeout(30*time.Second), + ), + withNetwork(s.Network.Name, postgresContainerName), + ) + if err != nil { + return fmt.Errorf("failed to start postgres container: %w", err) + } + + s.PostgresContainer = postgresContainer + + // Get the mapped port for local access + localPort, err := postgresContainer.MappedPort(ctx, postgresPort) + if err != nil { + return fmt.Errorf("failed to get postgres mapped port: %w", err) + } + + // Build DSN for local access + s.PostgresDSN = fmt.Sprintf("postgres://%s:%s@localhost:%d/%s?sslmode=disable", + postgresUser, postgresPassword, localPort.Int(), postgresDB) + + return nil +} + +// withNetwork is a helper function to attach a container to a network with a specific name +func withNetwork(networkName, containerName string) testcontainers.CustomizeRequestOption { + return func(req *testcontainers.GenericContainerRequest) error { + req.Networks = append(req.Networks, networkName) + if containerName != "" { + if req.NetworkAliases == nil { + req.NetworkAliases = make(map[string][]string) + } + req.NetworkAliases[networkName] = []string{containerName} + } + + return nil + } +} + +// startCatalogService starts the catalog service container from ECR image +func (s *TestContainerSetup) startCatalogService(ctx context.Context) error { + // Get the catalog image from environment or use default + catalogImage := os.Getenv(catalogImageEnv) + if catalogImage == "" { + // Default to local image or ECR format + catalogImage = fmt.Sprintf("%s:%s", catalogImageRepo, catalogImageTag) + log.Printf("CATALOG_SERVICE_IMAGE not set, using default: %s", catalogImage) + } + + log.Printf("Running database migration using catalog image...") + + // Run migration in a one-off container + // The migration container must be on the same network as PostgreSQL + // so it can connect using the container name instead of localhost + // NOTE: Must override entrypoint since Dockerfile sets it to "service start" + + // Build DSN using postgres container name for network communication + // Format: postgres://user:pass@postgres-container:5432/dbname?sslmode=disable + migrationDSN := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", + postgresUser, + postgresPassword, + postgresContainerName, + "5432", // Internal postgres port (not the mapped host port) + postgresDB, + ) + + migrationReq := testcontainers.ContainerRequest{ + Image: catalogImage, + Entrypoint: []string{"/app/op-catalog"}, // Override the Dockerfile ENTRYPOINT + Cmd: []string{ + "migrate", + "up", + "--postgres-dsn", + migrationDSN, // Use postgres container name for network communication + }, + Networks: []string{s.Network.Name}, // IMPORTANT: Must be on same network as postgres + WaitingFor: wait.ForExit(). + WithExitTimeout(2 * time.Minute), + } + + migrationContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ + ContainerRequest: migrationReq, + Started: true, + }) + if err != nil { + return fmt.Errorf("failed to start migration container: %w", err) + } + + // Wait for migration to complete and check exit code + state, err := migrationContainer.State(ctx) + if err != nil { + return fmt.Errorf("failed to get migration container state: %w", err) + } + + if state.ExitCode != 0 { + // Get logs for debugging + logReader, logErr := migrationContainer.Logs(ctx) + if logErr == nil && logReader != nil { + logBytes := make([]byte, 8192) + n, _ := logReader.Read(logBytes) + log.Printf("Migration logs: %s", string(logBytes[:n])) + } + + return fmt.Errorf("migration failed with exit code: %d", state.ExitCode) + } + + // Terminate migration container + if terminateErr := migrationContainer.Terminate(ctx); terminateErr != nil { + log.Printf("Warning: failed to terminate migration container: %v", terminateErr) + } + + log.Println("Database migration completed successfully") + + // Get postgres container IP for service-to-db communication + postgresIP, err := s.PostgresContainer.ContainerIP(ctx) + if err != nil { + return fmt.Errorf("failed to get postgres IP: %w", err) + } + + // Build DSN for container-to-container communication + containerPostgresDSN := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable", + postgresUser, postgresPassword, postgresIP, postgresPort, postgresDB) + + // Now start the catalog service + // NOTE: Must override entrypoint for the service to use env vars + serviceReq := testcontainers.ContainerRequest{ + Image: catalogImage, + Entrypoint: []string{"/app/op-catalog"}, // Override the Dockerfile ENTRYPOINT + Cmd: []string{ + "service", + "start", + }, + Env: map[string]string{ + "CATALOG_POSTGRES_DSN": containerPostgresDSN, + "CATALOG_LISTEN_ADDRESS": "0.0.0.0", + "CATALOG_LISTEN_PORT": catalogPort, + }, + ExposedPorts: []string{catalogPort + "/tcp"}, + Networks: []string{s.Network.Name}, + WaitingFor: wait.ForLog("gRPC server listening"). + WithStartupTimeout(30 * time.Second). + WithPollInterval(500 * time.Millisecond), + } + + catalogContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ + ContainerRequest: serviceReq, + Started: true, + }) + if err != nil { + return fmt.Errorf("failed to start catalog service: %w", err) + } + + s.CatalogContainer = catalogContainer + + // Get the mapped port for local gRPC access + mappedPort, err := catalogContainer.MappedPort(ctx, catalogPort) + if err != nil { + return fmt.Errorf("failed to get catalog service mapped port: %w", err) + } + + s.CatalogGRPCAddr = fmt.Sprintf("localhost:%d", mappedPort.Int()) + + return nil +} + +// Teardown cleans up all containers and networks +func (s *TestContainerSetup) Teardown(ctx context.Context) error { + log.Println("Tearing down test containers...") + + var errs []string + + // Terminate catalog service + if s.CatalogContainer != nil { + if err := s.CatalogContainer.Terminate(ctx); err != nil { + errs = append(errs, fmt.Sprintf("failed to terminate catalog container: %v", err)) + } + } + + // Terminate postgres + if s.PostgresContainer != nil { + if err := s.PostgresContainer.Terminate(ctx); err != nil { + errs = append(errs, fmt.Sprintf("failed to terminate postgres container: %v", err)) + } + } + + // Remove network + if s.Network != nil { + if err := s.Network.Remove(ctx); err != nil { + errs = append(errs, fmt.Sprintf("failed to remove network: %v", err)) + } + } + + if len(errs) > 0 { + return fmt.Errorf("teardown errors: %s", strings.Join(errs, "; ")) + } + + log.Println("Teardown complete") + + return nil +} + +// GetCatalogGRPCAddress returns the gRPC address for catalog service +func (s *TestContainerSetup) GetCatalogGRPCAddress() string { + return s.CatalogGRPCAddr +} diff --git a/go.mod b/go.mod index f34a3b50e..f618cae7f 100644 --- a/go.mod +++ b/go.mod @@ -44,6 +44,7 @@ require ( github.com/spf13/viper v1.21.0 github.com/stretchr/testify v1.11.1 github.com/testcontainers/testcontainers-go v0.38.0 + github.com/testcontainers/testcontainers-go/modules/postgres v0.38.0 github.com/xssnick/tonutils-go v1.13.0 github.com/zksync-sdk/zksync2-go v1.1.1-0.20250620124214-2c742ee399c6 go.uber.org/zap v1.27.0 diff --git a/go.sum b/go.sum index acb620ba7..a884a506c 100644 --- a/go.sum +++ b/go.sum @@ -429,10 +429,15 @@ github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgS github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA= github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= +github.com/jackc/pgx/v5 v5.5.4 h1:Xp2aQS8uXButQdnCMWNmvx6UysWQQC+u1EoizjguY+8= +github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.3.0 h1:eHK/5clGOatcjX3oWGBO/MpxpbHzSwud5EWTSCI+MX0= github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -516,6 +521,8 @@ github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U= github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mdelapenya/tlscert v0.2.0 h1:7H81W6Z/4weDvZBNOfQte5GpIMo0lGYEeWbkGp5LJHI= +github.com/mdelapenya/tlscert v0.2.0/go.mod h1:O4njj3ELLnJjGdkN7M/vIVCpZ+Cf0L6muqOG4tLSl8o= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= @@ -761,6 +768,8 @@ github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= github.com/testcontainers/testcontainers-go v0.38.0 h1:d7uEapLcv2P8AvH8ahLqDMMxda2W9gQN1nRbHS28HBw= github.com/testcontainers/testcontainers-go v0.38.0/go.mod h1:C52c9MoHpWO+C4aqmgSU+hxlR5jlEayWtgYrb8Pzz1w= +github.com/testcontainers/testcontainers-go/modules/postgres v0.38.0 h1:KFdx9A0yF94K70T6ibSuvgkQQeX1xKlZVF3hEagXEtY= +github.com/testcontainers/testcontainers-go/modules/postgres v0.38.0/go.mod h1:T/QRECND6N6tAKMxF1Za+G2tpwnGEHcODzHRsgIpw9M= github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY= github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= From 5297341a10724fb55a356e5054935c738a53cea0 Mon Sep 17 00:00:00 2001 From: ajaskolski Date: Mon, 27 Oct 2025 13:22:53 +0100 Subject: [PATCH 2/2] bot comments updates --- .github/workflows/pull-request-main.yml | 2 +- .github/workflows/schedule-main.yml | 2 +- datastore/catalog/remote/README.md | 8 ++++++-- datastore/catalog/remote/testcontainer_setup.go | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull-request-main.yml b/.github/workflows/pull-request-main.yml index 3deae7239..9b940b715 100644 --- a/.github/workflows/pull-request-main.yml +++ b/.github/workflows/pull-request-main.yml @@ -46,7 +46,7 @@ jobs: # causing tests in ci to fail "fatal error: checkptr: pointer arithmetic result points to invalid allocation" # https://github.com/xssnick/tonutils-go/issues/310 # Exclude provider packages which use Docker containers and remote catalog tests - go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -coverprofile=coverage.txt $(go list ./... | grep -v '/provider' | grep -v '/remote') + go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -coverprofile=coverage.txt $(go list ./... | grep -v '/provider' | grep -v '/catalog/remote') use-go-cache: true artifact-name: unit-tests diff --git a/.github/workflows/schedule-main.yml b/.github/workflows/schedule-main.yml index 66afff515..1505a1186 100644 --- a/.github/workflows/schedule-main.yml +++ b/.github/workflows/schedule-main.yml @@ -44,7 +44,7 @@ jobs: with: # disable the checkptr runtime check due a false positive in github.com/xssnick/tonutils-go # Exclude provider packages which use Docker containers and remote catalog tests - go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -coverprofile=coverage.txt $(go list ./... | grep -v '/provider' | grep -v '/remote') + go-test-cmd: go test -race -gcflags=all=-d=checkptr=0 -coverprofile=coverage.txt $(go list ./... | grep -v '/provider' | grep -v '/catalog/remote') use-go-cache: true artifact-name: unit-tests diff --git a/datastore/catalog/remote/README.md b/datastore/catalog/remote/README.md index 164125111..d6c9722e0 100644 --- a/datastore/catalog/remote/README.md +++ b/datastore/catalog/remote/README.md @@ -16,8 +16,12 @@ The tests in this package use **testcontainers** to automatically start the requ - Database migration **Important:** Testcontainers uses images from your local Docker daemon. You must either: -1. Build the image locally: `docker build -t op-catalog-service:latest .` -2. Pull from ECR with a specific tag: `docker pull 123123123123.dkr.ecr.us-east-1.amazonaws.com/chainlink-catalog-service:TAG` +1. Build the image locally from the `op-catalog` directory: + ```bash + cd op-catalog + docker build -t op-catalog-service:latest . + ``` +2. Pull from ECR with a specific tag: `docker pull 123123123123.dkr.ecr.us-east-1.amazonaws.com/op-catalog-service:TAG` - Use `aws ecr describe-images` to find available tags - Common patterns: version tags (v0.0.1) diff --git a/datastore/catalog/remote/testcontainer_setup.go b/datastore/catalog/remote/testcontainer_setup.go index 22472230c..3fb6bbb11 100644 --- a/datastore/catalog/remote/testcontainer_setup.go +++ b/datastore/catalog/remote/testcontainer_setup.go @@ -138,7 +138,7 @@ func (s *TestContainerSetup) startCatalogService(ctx context.Context) error { postgresUser, postgresPassword, postgresContainerName, - "5432", // Internal postgres port (not the mapped host port) + postgresPort, postgresDB, )