From f66f8e24a1a6b75ae833f5e1f6f6017df812f4d8 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Tue, 12 Nov 2024 10:25:10 +0100 Subject: [PATCH 01/66] test: add antithesis test --- test/antithesis/Earthfile | 46 +++++++ test/antithesis/config/Earthfile | 12 ++ test/antithesis/config/docker-compose.yml | 87 ++++++++++++++ test/antithesis/config/gateway/Caddyfile | 9 ++ test/antithesis/image/Earthfile | 47 ++++++++ test/antithesis/image/entrypoint.sh | 11 ++ test/antithesis/workload/Earthfile | 40 +++++++ test/antithesis/workload/cmd/lifecycle.go | 31 +++++ test/antithesis/workload/cmd/root.go | 30 +++++ test/antithesis/workload/cmd/run.go | 48 ++++++++ test/antithesis/workload/cmd/utils.go | 59 +++++++++ test/antithesis/workload/cmd/utils_test.go | 20 ++++ test/antithesis/workload/cmd/workload.go | 133 +++++++++++++++++++++ test/antithesis/workload/go.mod | 24 ++++ test/antithesis/workload/go.sum | 31 +++++ test/antithesis/workload/main.go | 11 ++ 16 files changed, 639 insertions(+) create mode 100644 test/antithesis/Earthfile create mode 100644 test/antithesis/config/Earthfile create mode 100644 test/antithesis/config/docker-compose.yml create mode 100644 test/antithesis/config/gateway/Caddyfile create mode 100644 test/antithesis/image/Earthfile create mode 100644 test/antithesis/image/entrypoint.sh create mode 100644 test/antithesis/workload/Earthfile create mode 100644 test/antithesis/workload/cmd/lifecycle.go create mode 100644 test/antithesis/workload/cmd/root.go create mode 100644 test/antithesis/workload/cmd/run.go create mode 100644 test/antithesis/workload/cmd/utils.go create mode 100644 test/antithesis/workload/cmd/utils_test.go create mode 100644 test/antithesis/workload/cmd/workload.go create mode 100644 test/antithesis/workload/go.mod create mode 100644 test/antithesis/workload/go.sum create mode 100644 test/antithesis/workload/main.go diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile new file mode 100644 index 0000000000..a11d104882 --- /dev/null +++ b/test/antithesis/Earthfile @@ -0,0 +1,46 @@ +VERSION 0.8 + +IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core + +FROM core+base-image + +run: + COPY ../..+sources/src /src + LET TAG=$(tar cf - /src | sha1sum | awk '{print $1}') + + WAIT + BUILD +requirements-build --TAG=$TAG + END + + FROM curlimages/curl + ARG ANTITHESIS_USERNAME=formance + ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT + RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ + --fail \ + --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ + -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance -d "{ + \"params\": { + \"custom.duration\": \"0.1\", + \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", + \"antithesis.config_image\": \"antithesis-config-dev:$TAG\", + \"antithesis.images\": \"ledger:$TAG;workload:$TAG\" + } + }" + +run-local: + LOCALLY + + WAIT + BUILD +requirements-build + END + + RUN --no-cache docker compose -f config/docker-compose.yml up workload + RUN --no-cache docker compose -f config/docker-compose.yml down -v + +requirements-build: + ARG TAG=latest + ARG --required ANTITHESIS_REPOSITORY + + BUILD --pass-args ./config+build + BUILD --pass-args ./image+build + BUILD --pass-args ./workload+build \ No newline at end of file diff --git a/test/antithesis/config/Earthfile b/test/antithesis/config/Earthfile new file mode 100644 index 0000000000..936b8c4dfc --- /dev/null +++ b/test/antithesis/config/Earthfile @@ -0,0 +1,12 @@ +VERSION 0.8 + +IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core + +build: + FROM --platform=linux/amd64 scratch + ARG TAG=latest + ARG --required ANTITHESIS_REPOSITORY + COPY docker-compose.yml /docker-compose.yml + COPY --dir gateway /gateway + + SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/antithesis-config-dev:$TAG \ No newline at end of file diff --git a/test/antithesis/config/docker-compose.yml b/test/antithesis/config/docker-compose.yml new file mode 100644 index 0000000000..3d33654d9b --- /dev/null +++ b/test/antithesis/config/docker-compose.yml @@ -0,0 +1,87 @@ +--- +networks: + formance: + driver: bridge + ipam: + config: + - subnet: 10.0.29.0/24 + +services: + postgres: + image: "postgres:15-alpine" + hostname: postgres + container_name: postgres + command: + - -c + - max_connections=100 + environment: + POSTGRES_USER: "ledger" + POSTGRES_PASSWORD: "ledger" + POSTGRES_DB: "ledger" + PGDATA: /data/postgres + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U ledger" ] + interval: 10s + timeout: 5s + retries: 5 + networks: + formance: + ipv4_address: 10.0.29.16 + + ledger1: + image: "us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:latest" + hostname: ledger1 + container_name: ledger1 + environment: + POSTGRES_URI: "postgresql://ledger:ledger@10.0.29.16:5432/ledger?sslmode=disable" + BIND: ":8080" + networks: + formance: + ipv4_address: 10.0.29.17 + depends_on: + postgres: + condition: service_healthy + + ledger2: + image: "us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:latest" + hostname: ledger2 + container_name: ledger2 + environment: + POSTGRES_URI: "postgresql://ledger:ledger@10.0.29.16:5432/ledger?sslmode=disable" + BIND: ":8080" + networks: + formance: + ipv4_address: 10.0.29.18 + depends_on: + postgres: + condition: service_healthy + + workload: + image: "us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/workload:latest" + hostname: workload + container_name: workload + networks: + formance: + ipv4_address: 10.0.29.19 + depends_on: + - gateway + + gateway: + image: "ghcr.io/formancehq/gateway:v2.0.0-rc.20" + hostname: gateway + container_name: gateway + volumes: + - ./gateway/Caddyfile:/etc/caddy/Caddyfile + ports: + - "8080:8080" + networks: + formance: + ipv4_address: 10.0.29.20 + depends_on: + - ledger1 + - ledger2 + healthcheck: + test: curl --fail http://localhost:8080 || exit 1 + interval: 2s + retries: 5 + start_period: 1s \ No newline at end of file diff --git a/test/antithesis/config/gateway/Caddyfile b/test/antithesis/config/gateway/Caddyfile new file mode 100644 index 0000000000..2eb65652c7 --- /dev/null +++ b/test/antithesis/config/gateway/Caddyfile @@ -0,0 +1,9 @@ +{ + # Local env dev config + auto_https off + debug +} + +:8080 { + reverse_proxy ledger1:8080 ledger2:8080 +} diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile new file mode 100644 index 0000000000..eef58211bf --- /dev/null +++ b/test/antithesis/image/Earthfile @@ -0,0 +1,47 @@ +VERSION 0.8 + +IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core + +FROM core+base-image + +CACHE --sharing=shared --id go-mod-cache /go/pkg/mod +CACHE --sharing=shared --id go-cache /root/.cache/go-build + +compile: + FROM --platform=linux/amd64 golang:1.22.2 + CACHE --sharing=shared --id go-mod-cache /go/pkg/mod + CACHE --sharing=shared --id go-cache /root/.cache/go-build + + COPY ../../..+sources/src /src + RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + WORKDIR /src + + RUN go mod download + RUN mkdir -p /ledger_instrumented + RUN /go/bin/antithesis-go-instrumentor . /ledger_instrumented + + WORKDIR /ledger_instrumented/customer + RUN go mod download + RUN go build -race -o ledger + + SAVE ARTIFACT /ledger_instrumented/customer/ledger + SAVE ARTIFACT /ledger_instrumented/symbols + +build: + FROM --platform=linux/amd64 ubuntu:latest + RUN apt-get update -y && apt-get install -y postgresql-client curl + ARG TAG=latest + + COPY (+compile/ledger) /bin/ledger + COPY (+compile/symbols) /symbols + COPY entrypoint.sh /bin/entrypoint.sh + + RUN chmod 777 /bin/ledger + RUN chmod 777 /bin/entrypoint.sh + + ENTRYPOINT ["/bin/entrypoint.sh"] + EXPOSE 8080 + + ARG --required ANTITHESIS_REPOSITORY + + SAVE IMAGE --push --no-manifest-list "${ANTITHESIS_REPOSITORY}/ledger:${TAG}" \ No newline at end of file diff --git a/test/antithesis/image/entrypoint.sh b/test/antithesis/image/entrypoint.sh new file mode 100644 index 0000000000..37973d9470 --- /dev/null +++ b/test/antithesis/image/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# make sure pg is ready to accept connections +until pg_isready -d ledger -h 10.0.29.16 -U ledger +do + echo "Waiting for postgres at: $POSTGRES_URI" + sleep 2; +done + +echo "Postgres is ready; serving ledger!" + +ledger serve diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile new file mode 100644 index 0000000000..bd792457fd --- /dev/null +++ b/test/antithesis/workload/Earthfile @@ -0,0 +1,40 @@ +VERSION 0.7 + +FROM --platform=linux/amd64 golang:1.22.2 + +CACHE --sharing=shared --id go-mod-cache /go/pkg/mod +CACHE --sharing=shared --id go-cache /root/.cache/go-build + +compile: + CACHE --id go-mod-cache /go/pkg/mod + CACHE --id go-cache /root/.cache/go-build + + RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + + COPY ../../..+lint/pkg /src/pkg + COPY ../../..+lint/internal /src/internal + COPY ../../..+lint/cmd /src/cmd + COPY ../../..+lint/*.go /src/ + COPY ../../..+tidy/go.mod /src/ + COPY ../../..+tidy/go.sum /src/ + + WORKDIR /src/test/antithesis/workload + COPY *.go go.* . + COPY --dir cmd . + + RUN mkdir -p /workload_instrumented + RUN /go/bin/antithesis-go-instrumentor -assert_only . + RUN go build -o main + + SAVE ARTIFACT main + +build: + FROM --platform=linux/amd64 ubuntu:latest + ARG TAG=latest + COPY (+compile/main) /bin/workload + RUN chmod 777 /bin/workload + ENTRYPOINT ["/bin/workload"] + + ARG --required ANTITHESIS_REPOSITORY + + SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:${TAG} \ No newline at end of file diff --git a/test/antithesis/workload/cmd/lifecycle.go b/test/antithesis/workload/cmd/lifecycle.go new file mode 100644 index 0000000000..f649e02954 --- /dev/null +++ b/test/antithesis/workload/cmd/lifecycle.go @@ -0,0 +1,31 @@ +package cmd + +import ( + "context" + "fmt" + "github.com/formancehq/ledger/pkg/client" + "os" + "time" +) + +func waitServicesReady(ctx context.Context, client *client.Formance) { + fmt.Println("Waiting for services to be ready") + waitingServicesCtx, cancel := context.WithDeadline(ctx, time.Now().Add(30*time.Second)) + defer cancel() + + for { + select { + case <-time.After(time.Second): + fmt.Println("Trying to get info of the ledger...") + _, err := client.Ledger.GetInfo(ctx) + if err != nil { + fmt.Printf("error pinging ledger: %s\r\n", err) + continue + } + return + case <-waitingServicesCtx.Done(): + fmt.Printf("timeout waiting for services to be ready\r\n") + os.Exit(1) + } + } +} diff --git a/test/antithesis/workload/cmd/root.go b/test/antithesis/workload/cmd/root.go new file mode 100644 index 0000000000..7eac0b0d67 --- /dev/null +++ b/test/antithesis/workload/cmd/root.go @@ -0,0 +1,30 @@ +package cmd + +import ( + "os" + + "github.com/spf13/cobra" +) + + + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "antithesis", + Run: run, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + err := rootCmd.Execute() + if err != nil { + os.Exit(1) + } +} + +func init() { + rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} + + diff --git a/test/antithesis/workload/cmd/run.go b/test/antithesis/workload/cmd/run.go new file mode 100644 index 0000000000..42b1cb24b6 --- /dev/null +++ b/test/antithesis/workload/cmd/run.go @@ -0,0 +1,48 @@ +package cmd + +import ( + "context" + "fmt" + "github.com/formancehq/ledger/pkg/client/models/operations" + "github.com/spf13/cobra" + "net/http" + "time" + + "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/formancehq/ledger/pkg/client" +) + +type Details map[string]any + +func run(cmd *cobra.Command, _ []string) { + client := client.New( + client.WithServerURL("http://gateway:8080"), + client.WithClient(&http.Client{ + Timeout: 10 * time.Second, + }), + ) + + waitServicesReady(cmd.Context(), client) + runWorkload(cmd.Context(), client) +} + +func createLedger(ctx context.Context, client *client.Formance) error { + + deadline := time.Now().Add(10 * time.Second) + ctx, cancel := context.WithDeadline(ctx, deadline) + defer cancel() + + fmt.Printf("Creating ledger with deadline %s...\r\n", deadline) + _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ + Ledger: "default", + }) + fmt.Println("Ledger created!") + + if assert.Always(err == nil, "ledger should have been created", Details{ + "error": fmt.Sprintf("%+v\n", err), + }); err != nil { + return err + } + + return nil +} diff --git a/test/antithesis/workload/cmd/utils.go b/test/antithesis/workload/cmd/utils.go new file mode 100644 index 0000000000..a98b713a79 --- /dev/null +++ b/test/antithesis/workload/cmd/utils.go @@ -0,0 +1,59 @@ +package cmd + +import ( + "fmt" + "math/big" + "sync" + + "github.com/antithesishq/antithesis-sdk-go/random" +) + +func randomBigInt() *big.Int { + v := random.GetRandom() + ret := big.NewInt(0) + ret.SetString(fmt.Sprintf("%d", v), 10) + return ret +} + +type IDSeq struct { + sync.Mutex + Count int64 + Sum *big.Int +} + +func NewIDSeq() *IDSeq { + return &IDSeq{ + Count: 0, + Sum: big.NewInt(0), + } +} + +func (s *IDSeq) Register(id *big.Int) { + s.Lock() + defer s.Unlock() + + s.Count++ + s.Sum.Add(s.Sum, id) +} + +func (s *IDSeq) Check() error { + s.Lock() + defer s.Unlock() + + // As the IDs are generated sequentially, the + // expected sum is the sum of the first n integers + // where n is the number of IDs generated. + expectedSum := big.NewInt(0).Div( + big.NewInt(0).Mul( + big.NewInt(s.Count-1), + big.NewInt(0).Add(big.NewInt(s.Count-1), big.NewInt(1)), + ), + big.NewInt(2), + ) + + if s.Sum.Cmp(expectedSum) != 0 { + return fmt.Errorf("sum of IDs is incorrect") + } + + return nil +} diff --git a/test/antithesis/workload/cmd/utils_test.go b/test/antithesis/workload/cmd/utils_test.go new file mode 100644 index 0000000000..fd6190661b --- /dev/null +++ b/test/antithesis/workload/cmd/utils_test.go @@ -0,0 +1,20 @@ +package cmd + +import ( + "fmt" + "math/big" + "testing" +) + +func TestIDSeq(t *testing.T) { + idSeq := NewIDSeq() + + for i := 0; i < 10; i++ { + idSeq.Register(big.NewInt(int64(i))) + } + + if err := idSeq.Check(); err != nil { + fmt.Println(idSeq.Count, idSeq.Sum) + t.Errorf("IDSeq check failed") + } +} diff --git a/test/antithesis/workload/cmd/workload.go b/test/antithesis/workload/cmd/workload.go new file mode 100644 index 0000000000..c5c1fb5f65 --- /dev/null +++ b/test/antithesis/workload/cmd/workload.go @@ -0,0 +1,133 @@ +package cmd + +import ( + "context" + "fmt" + "github.com/alitto/pond" + "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/antithesishq/antithesis-sdk-go/lifecycle" + "github.com/antithesishq/antithesis-sdk-go/random" + "github.com/formancehq/ledger/pkg/client" + "github.com/formancehq/ledger/pkg/client/models/components" + "github.com/formancehq/ledger/pkg/client/models/operations" + "github.com/formancehq/stack/libs/go-libs/pointer" + "go.uber.org/atomic" + "math" + "math/big" +) + +func runWorkload(ctx context.Context, client *client.Formance) { + err := createLedger(ctx, client) + if err != nil { + assert.Always(err == nil, "ledger should have been created", Details{ + "error": err, + }) + return + } + + lifecycle.SetupComplete(Details{ + "Ledger": "Available", + }) + + const count = 1000 + + hasError := atomic.NewBool(false) + totalAmount := big.NewInt(0) + idSeq := NewIDSeq() + + pool := pond.New(20, 10000) + + fmt.Printf("Insert %d transactions...\r\n", count) + for i := 0; i < count; i++ { + amount := randomBigInt() + totalAmount = totalAmount.Add(totalAmount, amount) + pool.Submit(func() { + id, err := runTx(ctx, client, amount) + + if err != nil { + hasError.CompareAndSwap(false, true) + return + } + + idSeq.Register(id) + }) + } + + pool.StopAndWait() + + //err = idSeq.Check() + //assert.Always(err == nil, "IDSeq check should pass", Details{ + // "count": idSeq.Count, + // "sum": idSeq.Sum, + //}) + // + //if err != nil { + // fmt.Println("Error checking ID sequence", err) + // hasError.CompareAndSwap(false, true) + // os.Exit(1) + // return + //} + + cond := !hasError.Load() + if assert.Always(cond, "all transactions should have been written", Details{ + "error": fmt.Sprintf("%+v\n", err), + }); !cond { + return + } + + fmt.Println("Checking balance of 'world'...") + account, err := client.Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ + Address: "world", + Expand: pointer.For("volumes"), + Ledger: "default", + }) + + cond = err == nil + if assert.Always(cond, "we should be able to query account 'world'", Details{ + "error": fmt.Sprintf("%+v\n", err), + }); !cond { + return + } + + output := account.V2AccountResponse.Data.Volumes["USD/2"].Output + + cond = output != nil + if assert.Always(cond, "Expect output of world for USD/2 to be not empty", Details{}); !cond { + return + } + fmt.Printf("Expect output of world to be %s and got %d\r\n", totalAmount, output) + assert.Always( + output.Cmp(totalAmount) == 0, + "output of 'world' should match", + Details{ + "output": output, + }, + ) +} + +func runTx(ctx context.Context, client *client.Formance, amount *big.Int) (*big.Int, error) { + orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) + dest := fmt.Sprintf("orders:%s", orderID) + + res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ + V2PostTransaction: components.V2PostTransaction{ + Postings: []components.V2Posting{{ + Amount: amount, + Asset: "USD/2", + Destination: dest, + Source: "world", + }}, + }, + Ledger: "default", + }) + + assert.Always( + err == nil, + "creating transaction from @world to $account always return a nil error", + Details{ + "error": fmt.Sprintf("%+v\n", err), + }, + ) + + return res.V2CreateTransactionResponse.Data.ID, err +} diff --git a/test/antithesis/workload/go.mod b/test/antithesis/workload/go.mod new file mode 100644 index 0000000000..5a614925e5 --- /dev/null +++ b/test/antithesis/workload/go.mod @@ -0,0 +1,24 @@ +module github.com/formancehq/ledger/test/antithesis + +go 1.21 + +toolchain go1.22.0 + +replace github.com/formancehq/ledger/pkg/client => ../../../pkg/client + +require ( + github.com/alitto/pond v1.8.3 + github.com/antithesishq/antithesis-sdk-go v0.3.8 + github.com/formancehq/formance-sdk-go/v2 v2.1.3 + github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 + github.com/formancehq/stack/libs/go-libs v0.0.0-20240412081813-558ce638a33b + go.uber.org/atomic v1.10.0 +) + +require ( + github.com/cenkalti/backoff/v4 v4.3.0 // indirect + github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/cobra v1.8.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/test/antithesis/workload/go.sum b/test/antithesis/workload/go.sum new file mode 100644 index 0000000000..8bc0368e56 --- /dev/null +++ b/test/antithesis/workload/go.sum @@ -0,0 +1,31 @@ +github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= +github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= +github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= +github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= +github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= +github.com/formancehq/formance-sdk-go/v2 v2.1.3 h1:9RpF1DkkJZWsKO2sFgF6DVr0bEaCUYNdI6bC3J0Yrz0= +github.com/formancehq/formance-sdk-go/v2 v2.1.3/go.mod h1:NjU319mP7CaRRpCEAuqP4biPuCBLd+OY5hD8PYOG+JY= +github.com/formancehq/stack/libs/go-libs v0.0.0-20240412081813-558ce638a33b h1:Z1DaupQL+i5dgZjCnhdGDs2Zevzv8DuyCSddnnDWjBw= +github.com/formancehq/stack/libs/go-libs v0.0.0-20240412081813-558ce638a33b/go.mod h1:YdhBeBSjIECXCw7g5V1Ie9LxFCXCme0s15lP2D6grVU= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/test/antithesis/workload/main.go b/test/antithesis/workload/main.go new file mode 100644 index 0000000000..3ef2e966d4 --- /dev/null +++ b/test/antithesis/workload/main.go @@ -0,0 +1,11 @@ +/* +Copyright © 2024 NAME HERE + +*/ +package main + +import "github.com/formancehq/ledger/test/antithesis/cmd" + +func main() { + cmd.Execute() +} From df41f3d685dec961dc48434e17eda3542f22153c Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Wed, 13 Nov 2024 11:24:41 +0100 Subject: [PATCH 02/66] chore: some test --- test/antithesis/config/docker-compose.yml | 7 +------ test/antithesis/config/gateway/Caddyfile | 5 ++++- test/antithesis/workload/cmd/run.go | 4 +++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/antithesis/config/docker-compose.yml b/test/antithesis/config/docker-compose.yml index 3d33654d9b..79a1da0fd3 100644 --- a/test/antithesis/config/docker-compose.yml +++ b/test/antithesis/config/docker-compose.yml @@ -79,9 +79,4 @@ services: ipv4_address: 10.0.29.20 depends_on: - ledger1 - - ledger2 - healthcheck: - test: curl --fail http://localhost:8080 || exit 1 - interval: 2s - retries: 5 - start_period: 1s \ No newline at end of file + - ledger2 \ No newline at end of file diff --git a/test/antithesis/config/gateway/Caddyfile b/test/antithesis/config/gateway/Caddyfile index 2eb65652c7..95dd650008 100644 --- a/test/antithesis/config/gateway/Caddyfile +++ b/test/antithesis/config/gateway/Caddyfile @@ -5,5 +5,8 @@ } :8080 { - reverse_proxy ledger1:8080 ledger2:8080 + reverse_proxy { + to ledger1:8080 ledger2:8080 + lb_policy first + } } diff --git a/test/antithesis/workload/cmd/run.go b/test/antithesis/workload/cmd/run.go index 42b1cb24b6..79fd06ae3c 100644 --- a/test/antithesis/workload/cmd/run.go +++ b/test/antithesis/workload/cmd/run.go @@ -23,6 +23,7 @@ func run(cmd *cobra.Command, _ []string) { ) waitServicesReady(cmd.Context(), client) + <-time.After(10 * time.Second) runWorkload(cmd.Context(), client) } @@ -36,7 +37,6 @@ func createLedger(ctx context.Context, client *client.Formance) error { _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: "default", }) - fmt.Println("Ledger created!") if assert.Always(err == nil, "ledger should have been created", Details{ "error": fmt.Sprintf("%+v\n", err), @@ -44,5 +44,7 @@ func createLedger(ctx context.Context, client *client.Formance) error { return err } + fmt.Println("Ledger created!") + return nil } From eead415e8d400f41ca3c91daeb4d6b095e9041d0 Mon Sep 17 00:00:00 2001 From: Geoffrey Ragot Date: Wed, 13 Nov 2024 21:32:03 +0100 Subject: [PATCH 03/66] feat: first workable setup --- go.mod | 26 +++--- go.sum | 56 +++++------ test/antithesis/Earthfile | 25 ++--- test/antithesis/config/Earthfile | 3 +- test/antithesis/config/docker-compose.yml | 6 ++ test/antithesis/image/Earthfile | 5 +- test/antithesis/workload/Earthfile | 74 +++++++++++---- .../main.go | 30 ++++++ .../cmds/singleton_driver_main/main.go} | 93 ++++++++----------- test/antithesis/workload/bin/init/main.go | 35 +++++++ test/antithesis/workload/cmd/lifecycle.go | 31 ------- test/antithesis/workload/cmd/root.go | 30 ------ test/antithesis/workload/cmd/run.go | 50 ---------- test/antithesis/workload/cmd/utils.go | 59 ------------ test/antithesis/workload/cmd/utils_test.go | 20 ---- test/antithesis/workload/go.mod | 19 ++-- test/antithesis/workload/go.sum | 44 +++++---- test/antithesis/workload/internal/utils.go | 50 ++++++++++ test/antithesis/workload/main.go | 11 --- test/rolling-upgrades/go.mod | 2 +- test/rolling-upgrades/go.sum | 4 +- tools/generator/go.mod | 2 +- tools/generator/go.sum | 56 +++++------ 23 files changed, 332 insertions(+), 399 deletions(-) create mode 100644 test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go rename test/antithesis/workload/{cmd/workload.go => bin/cmds/singleton_driver_main/main.go} (50%) create mode 100644 test/antithesis/workload/bin/init/main.go delete mode 100644 test/antithesis/workload/cmd/lifecycle.go delete mode 100644 test/antithesis/workload/cmd/root.go delete mode 100644 test/antithesis/workload/cmd/run.go delete mode 100644 test/antithesis/workload/cmd/utils.go delete mode 100644 test/antithesis/workload/cmd/utils_test.go create mode 100644 test/antithesis/workload/internal/utils.go delete mode 100644 test/antithesis/workload/main.go diff --git a/go.mod b/go.mod index 2fca2d73fb..12f9eba8f6 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20241009100908-5f46f2705ca3 - github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 + github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/go-chi/chi/v5 v5.1.0 github.com/go-chi/cors v1.2.1 @@ -68,20 +68,20 @@ require ( github.com/ajg/form v1.5.1 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 // indirect - github.com/aws/aws-sdk-go-v2 v1.32.4 // indirect - github.com/aws/aws-sdk-go-v2/config v1.28.3 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.17.44 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19 // indirect + github.com/aws/aws-sdk-go-v2 v1.32.5 // indirect + github.com/aws/aws-sdk-go-v2/config v1.28.5 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.17.46 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 // indirect github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.4.23 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.32.4 // indirect - github.com/aws/smithy-go v1.22.0 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 // indirect + github.com/aws/smithy-go v1.22.1 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect diff --git a/go.sum b/go.sum index 1cb9b579f5..45e793ceed 100644 --- a/go.sum +++ b/go.sum @@ -30,34 +30,34 @@ github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYW github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 h1:UyjtGmO0Uwl/K+zpzPwLoXzMhcN9xmnR2nrqJoBrg3c= github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0/go.mod h1:TJAXuFs2HcMib3sN5L0gUC+Q01Qvy3DemvA55WuC+iA= -github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= -github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= -github.com/aws/aws-sdk-go-v2/config v1.28.3 h1:kL5uAptPcPKaJ4q0sDUjUIdueO18Q7JDzl64GpVwdOM= -github.com/aws/aws-sdk-go-v2/config v1.28.3/go.mod h1:SPEn1KA8YbgQnwiJ/OISU4fz7+F6Fe309Jf0QTsRCl4= -github.com/aws/aws-sdk-go-v2/credentials v1.17.44 h1:qqfs5kulLUHUEXlHEZXLJkgGoF3kkUeFUTVA585cFpU= -github.com/aws/aws-sdk-go-v2/credentials v1.17.44/go.mod h1:0Lm2YJ8etJdEdw23s+q/9wTpOeo2HhNE97XcRa7T8MA= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19 h1:woXadbf0c7enQ2UGCi8gW/WuKmE0xIzxBF/eD94jMKQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19/go.mod h1:zminj5ucw7w0r65bP6nhyOd3xL6veAUMc3ElGMoLVb4= +github.com/aws/aws-sdk-go-v2 v1.32.5 h1:U8vdWJuY7ruAkzaOdD7guwJjD06YSKmnKCJs7s3IkIo= +github.com/aws/aws-sdk-go-v2 v1.32.5/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= +github.com/aws/aws-sdk-go-v2/config v1.28.5 h1:Za41twdCXbuyyWv9LndXxZZv3QhTG1DinqlFsSuvtI0= +github.com/aws/aws-sdk-go-v2/config v1.28.5/go.mod h1:4VsPbHP8JdcdUDmbTVgNL/8w9SqOkM5jyY8ljIxLO3o= +github.com/aws/aws-sdk-go-v2/credentials v1.17.46 h1:AU7RcriIo2lXjUfHFnFKYsLCwgbz1E7Mm95ieIRDNUg= +github.com/aws/aws-sdk-go-v2/credentials v1.17.46/go.mod h1:1FmYyLGL08KQXQ6mcTlifyFXfJVCNJTVGuQP4m0d/UA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 h1:sDSXIrlsFSFJtWKLQS4PUWRvrT580rrnuLydJrCQ/yA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20/go.mod h1:WZ/c+w0ofps+/OUqMwWgnfrgzZH1DZO1RIkktICsqnY= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.4.23 h1:B2qK61ZXCQu8tkD6eG/gUiIt9Vw9tmWFD7Xo02JPdMY= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.4.23/go.mod h1:02rz9vMZsrOX9IwUcpoGZM4jPprFNPmtD6t9Ume9ECY= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 h1:A2w6m6Tmr+BNXjDsr7M90zkWjsu4JXHwrzPg235STs4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23/go.mod h1:35EVp9wyeANdujZruvHiQUAo9E3vbhnIO1mTCAxMlY0= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 h1:pgYW9FCabt2M25MoHYCfMrVY2ghiiBKYWUVXfwZs+sU= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23/go.mod h1:c48kLgzO19wAu3CPkDWC28JbaJ+hfQlsdl7I2+oqIbk= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 h1:4usbeaes3yJnCFC7kfeyhkdkPtoRYPa/hTmCqMpKpLI= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24/go.mod h1:5CI1JemjVwde8m2WG3cz23qHKPOxbpkq0HaoreEgLIY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 h1:N1zsICrQglfzaBnrfM0Ys00860C+QFwu6u/5+LomP+o= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24/go.mod h1:dCn9HbJ8+K31i8IQ8EWmWj0EiIk0+vKiHNMxTTYveAg= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 h1:tHxQi/XHPK0ctd/wdOw0t7Xrc2OxcRCnVzv8lwWPu0c= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4/go.mod h1:4GQbF1vJzG60poZqWatZlhP31y8PGCCVTvIGPdaaYJ0= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 h1:HJwZwRt2Z2Tdec+m+fPjvdmkq2s9Ra+VR0hjF7V2o40= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.5/go.mod h1:wrMCEwjFPms+V86TCQQeOxQF/If4vT44FGIOFiMC2ck= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 h1:zcx9LiGWZ6i6pjdcoE9oXAB6mUdeyC36Ia/QEiIvYdg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4/go.mod h1:Tp/ly1cTjRLGBBmNccFumbZ8oqpZlpdhFf80SrRh4is= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.4 h1:yDxvkz3/uOKfxnv8YhzOi9m+2OGIxF+on3KOISbK5IU= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.4/go.mod h1:9XEUty5v5UAsMiFOBJrNibZgwCeOma73jgGwwhgffa8= -github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= -github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 h1:wtpJ4zcwrSbwhECWQoI/g6WM9zqCcSpHDJIWSbMLOu4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5/go.mod h1:qu/W9HXQbbQ4+1+JcZp0ZNPV31ym537ZJN+fiS7Ti8E= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 h1:3zu537oLmsPfDMyjnUS2g+F2vITgy5pB74tHI+JBNoM= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.6/go.mod h1:WJSZH2ZvepM6t6jwu4w/Z45Eoi75lPN7DcydSRtJg6Y= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 h1:K0OQAsDywb0ltlFrZm0JHPY3yZp/S9OaoLU33S7vPS8= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5/go.mod h1:ORITg+fyuMoeiQFiVGoqB3OydVTLkClw/ljbblMq6Cc= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 h1:6SZUVRQNvExYlMLbHdlKB48x0fLbc2iVROyaNEwBHbU= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1/go.mod h1:GqWyYCwLXnlUB1lOAXQyNSPqPLQJvmo8J0DWBzp9mtg= +github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= +github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw= @@ -104,8 +104,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 h1:l6jieaR+sn4Ff+puBDMbTYmT2HTYC7Yt7GTxBAwC3eU= -github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9/go.mod h1:m0uKkey9OC/AeyWMwjMfZqhLzoWrPFBk8vuYdSSYj4Y= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778 h1:k/PmHjR692rBLxCanof/lD0c1K8WLKCNYCl5y1EHJPg= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778/go.mod h1:6vkHEfWEkDSPOv/G2o1Exxra3ouuYxRiCkznwKxTMHU= github.com/formancehq/numscript v0.0.9-0.20241009144012-1150c14a1417 h1:LOd5hxnXDIBcehFrpW1OnXk+VSs0yJXeu1iAOO+Hji4= github.com/formancehq/numscript v0.0.9-0.20241009144012-1150c14a1417/go.mod h1:btuSv05cYwi9BvLRxVs5zrunU+O1vTgigG1T6UsawcY= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= @@ -142,8 +142,8 @@ github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIx github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= +github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile index a11d104882..ff11c9213b 100644 --- a/test/antithesis/Earthfile +++ b/test/antithesis/Earthfile @@ -5,11 +5,8 @@ IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core FROM core+base-image run: - COPY ../..+sources/src /src - LET TAG=$(tar cf - /src | sha1sum | awk '{print $1}') - WAIT - BUILD +requirements-build --TAG=$TAG + BUILD +requirements-build END FROM curlimages/curl @@ -22,25 +19,17 @@ run: \"params\": { \"custom.duration\": \"0.1\", \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", - \"antithesis.config_image\": \"antithesis-config-dev:$TAG\", - \"antithesis.images\": \"ledger:$TAG;workload:$TAG\" + \"antithesis.config_image\": \"antithesis-config:latest\", + \"antithesis.images\": \"ledger:latest;workload:latest\" } }" -run-local: - LOCALLY - - WAIT - BUILD +requirements-build - END - - RUN --no-cache docker compose -f config/docker-compose.yml up workload - RUN --no-cache docker compose -f config/docker-compose.yml down -v - requirements-build: - ARG TAG=latest ARG --required ANTITHESIS_REPOSITORY BUILD --pass-args ./config+build BUILD --pass-args ./image+build - BUILD --pass-args ./workload+build \ No newline at end of file + BUILD --pass-args ./workload+build + +pre-commit: + BUILD ./workload+pre-commit \ No newline at end of file diff --git a/test/antithesis/config/Earthfile b/test/antithesis/config/Earthfile index 936b8c4dfc..201f9c5094 100644 --- a/test/antithesis/config/Earthfile +++ b/test/antithesis/config/Earthfile @@ -4,9 +4,8 @@ IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core build: FROM --platform=linux/amd64 scratch - ARG TAG=latest ARG --required ANTITHESIS_REPOSITORY COPY docker-compose.yml /docker-compose.yml COPY --dir gateway /gateway - SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/antithesis-config-dev:$TAG \ No newline at end of file + SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/antithesis-config:latest \ No newline at end of file diff --git a/test/antithesis/config/docker-compose.yml b/test/antithesis/config/docker-compose.yml index 79a1da0fd3..8de28914a9 100644 --- a/test/antithesis/config/docker-compose.yml +++ b/test/antithesis/config/docker-compose.yml @@ -35,6 +35,9 @@ services: environment: POSTGRES_URI: "postgresql://ledger:ledger@10.0.29.16:5432/ledger?sslmode=disable" BIND: ":8080" + POSTGRES_CONN_MAX_IDLE_TIME: "1m0s" + POSTGRES_MAX_IDLE_CONNS: "20" + POSTGRES_MAX_OPEN_CONNS: "20" networks: formance: ipv4_address: 10.0.29.17 @@ -48,6 +51,9 @@ services: container_name: ledger2 environment: POSTGRES_URI: "postgresql://ledger:ledger@10.0.29.16:5432/ledger?sslmode=disable" + POSTGRES_CONN_MAX_IDLE_TIME: "1m0s" + POSTGRES_MAX_IDLE_CONNS: "20" + POSTGRES_MAX_OPEN_CONNS: "20" BIND: ":8080" networks: formance: diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index eef58211bf..b6b9b5e071 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -21,7 +21,6 @@ compile: RUN /go/bin/antithesis-go-instrumentor . /ledger_instrumented WORKDIR /ledger_instrumented/customer - RUN go mod download RUN go build -race -o ledger SAVE ARTIFACT /ledger_instrumented/customer/ledger @@ -30,13 +29,11 @@ compile: build: FROM --platform=linux/amd64 ubuntu:latest RUN apt-get update -y && apt-get install -y postgresql-client curl - ARG TAG=latest COPY (+compile/ledger) /bin/ledger COPY (+compile/symbols) /symbols COPY entrypoint.sh /bin/entrypoint.sh - RUN chmod 777 /bin/ledger RUN chmod 777 /bin/entrypoint.sh ENTRYPOINT ["/bin/entrypoint.sh"] @@ -44,4 +41,4 @@ build: ARG --required ANTITHESIS_REPOSITORY - SAVE IMAGE --push --no-manifest-list "${ANTITHESIS_REPOSITORY}/ledger:${TAG}" \ No newline at end of file + SAVE IMAGE --push --no-manifest-list "${ANTITHESIS_REPOSITORY}/ledger:latest" \ No newline at end of file diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile index bd792457fd..fb4aa9f202 100644 --- a/test/antithesis/workload/Earthfile +++ b/test/antithesis/workload/Earthfile @@ -4,6 +4,44 @@ FROM --platform=linux/amd64 golang:1.22.2 CACHE --sharing=shared --id go-mod-cache /go/pkg/mod CACHE --sharing=shared --id go-cache /root/.cache/go-build +CACHE --sharing=shared --id golangci-cache /root/.cache/golangci-lint + +sources: + COPY --dir ../../..+lint/* /src/ + COPY ../../..+tidy/* /src/ + + WORKDIR /src/test/antithesis/workload + COPY go.* . + COPY --dir bin internal . + + SAVE ARTIFACT /src + +tidy: + FROM +sources + + CACHE --id go-mod-cache /go/pkg/mod + CACHE --id go-cache /root/.cache/go-build + + WORKDIR /src/test/antithesis/workload + RUN go mod tidy + + SAVE ARTIFACT go.mod AS LOCAL go.mod + SAVE ARTIFACT go.sum AS LOCAL go.sum + +lint: + #todo: get config from core + FROM +tidy + + RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0 + + CACHE --id go-mod-cache /go/pkg/mod + CACHE --id go-cache /root/.cache/go-build + CACHE --id golangci-cache /root/.cache/golangci-lint + + RUN golangci-lint run --fix --timeout 5m + + SAVE ARTIFACT bin AS LOCAL bin + SAVE ARTIFACT internal AS LOCAL internal compile: CACHE --id go-mod-cache /go/pkg/mod @@ -11,30 +49,32 @@ compile: RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - COPY ../../..+lint/pkg /src/pkg - COPY ../../..+lint/internal /src/internal - COPY ../../..+lint/cmd /src/cmd - COPY ../../..+lint/*.go /src/ - COPY ../../..+tidy/go.mod /src/ - COPY ../../..+tidy/go.sum /src/ + COPY +sources/src /src WORKDIR /src/test/antithesis/workload - COPY *.go go.* . - COPY --dir cmd . - RUN mkdir -p /workload_instrumented - RUN /go/bin/antithesis-go-instrumentor -assert_only . - RUN go build -o main + RUN mkdir -p /out/cmds + + RUN antithesis-go-instrumentor -assert_only . + RUN go build -o /out/init ./bin/init + + FOR file IN $(ls bin/cmds) + RUN go build -o /out/cmds/$file ./bin/cmds/$file + END - SAVE ARTIFACT main + SAVE ARTIFACT /out build: FROM --platform=linux/amd64 ubuntu:latest - ARG TAG=latest - COPY (+compile/main) /bin/workload - RUN chmod 777 /bin/workload - ENTRYPOINT ["/bin/workload"] + COPY (+compile/out/init) /init + ENTRYPOINT ["/init"] + + COPY (+compile/out/cmds/*) /opt/antithesis/test/v1/main/ ARG --required ANTITHESIS_REPOSITORY - SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:${TAG} \ No newline at end of file + SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest + +pre-commit: + BUILD +tidy + BUILD +lint \ No newline at end of file diff --git a/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go b/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go new file mode 100644 index 0000000000..959a32bd47 --- /dev/null +++ b/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go @@ -0,0 +1,30 @@ +package main + +import ( + "context" + "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/formancehq/ledger/pkg/client/models/operations" + "github.com/formancehq/ledger/test/antithesis/internal" + "math/big" +) + +func main() { + ctx := context.Background() + client := internal.NewClient() + + aggregated, err := client.Ledger.V2.GetBalancesAggregated(ctx, operations.V2GetBalancesAggregatedRequest{ + Ledger: "default", + }) + if err != nil { + assert.Always(err == nil, "error getting aggregated balances", internal.Details{ + "error": err, + }) + return + } + + for asset, volumes := range aggregated.V2AggregateBalancesResponse.Data { + assert.Always(volumes.Cmp(new(big.Int)) == 0, "aggregated volumes for asset "+asset+" should be 0", internal.Details{ + "error": err, + }) + } +} diff --git a/test/antithesis/workload/cmd/workload.go b/test/antithesis/workload/bin/cmds/singleton_driver_main/main.go similarity index 50% rename from test/antithesis/workload/cmd/workload.go rename to test/antithesis/workload/bin/cmds/singleton_driver_main/main.go index c5c1fb5f65..ca295a9a20 100644 --- a/test/antithesis/workload/cmd/workload.go +++ b/test/antithesis/workload/bin/cmds/singleton_driver_main/main.go @@ -1,115 +1,105 @@ -package cmd +package main import ( "context" "fmt" "github.com/alitto/pond" "github.com/antithesishq/antithesis-sdk-go/assert" - "github.com/antithesishq/antithesis-sdk-go/lifecycle" "github.com/antithesishq/antithesis-sdk-go/random" + "github.com/formancehq/go-libs/v2/pointer" "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" - "github.com/formancehq/stack/libs/go-libs/pointer" + "github.com/formancehq/ledger/test/antithesis/internal" "go.uber.org/atomic" "math" "math/big" ) -func runWorkload(ctx context.Context, client *client.Formance) { +func main() { + ctx := context.Background() + client := internal.NewClient() + err := createLedger(ctx, client) if err != nil { - assert.Always(err == nil, "ledger should have been created", Details{ + assert.Always(err == nil, "ledger should have been created", internal.Details{ "error": err, }) return } - lifecycle.SetupComplete(Details{ - "Ledger": "Available", - }) - const count = 1000 hasError := atomic.NewBool(false) totalAmount := big.NewInt(0) - idSeq := NewIDSeq() - pool := pond.New(20, 10000) + pool := pond.New(10, 10000) - fmt.Printf("Insert %d transactions...\r\n", count) for i := 0; i < count; i++ { - amount := randomBigInt() + amount := internal.RandomBigInt() totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { - id, err := runTx(ctx, client, amount) - - if err != nil { + if !internal.AssertAlwaysErrNil( + runTx(ctx, client, amount), + "creating transaction from @world to $account always return a nil error", + ) { hasError.CompareAndSwap(false, true) - return } - - idSeq.Register(id) }) } pool.StopAndWait() - //err = idSeq.Check() - //assert.Always(err == nil, "IDSeq check should pass", Details{ - // "count": idSeq.Count, - // "sum": idSeq.Sum, - //}) - // - //if err != nil { - // fmt.Println("Error checking ID sequence", err) - // hasError.CompareAndSwap(false, true) - // os.Exit(1) - // return - //} - cond := !hasError.Load() - if assert.Always(cond, "all transactions should have been written", Details{ - "error": fmt.Sprintf("%+v\n", err), - }); !cond { + if assert.Always(cond, "all transactions should have been written", internal.Details{}); !cond { return } - fmt.Println("Checking balance of 'world'...") account, err := client.Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ Address: "world", Expand: pointer.For("volumes"), Ledger: "default", }) - cond = err == nil - if assert.Always(cond, "we should be able to query account 'world'", Details{ - "error": fmt.Sprintf("%+v\n", err), - }); !cond { + if !internal.AssertAlwaysErrNil(err, "we should be able to query account 'world'") { return } output := account.V2AccountResponse.Data.Volumes["USD/2"].Output - cond = output != nil - if assert.Always(cond, "Expect output of world for USD/2 to be not empty", Details{}); !cond { + if !internal.AssertAlways(output != nil, "Expect output of world for USD/2 to be not empty", internal.Details{}) { return } - fmt.Printf("Expect output of world to be %s and got %d\r\n", totalAmount, output) + assert.Always( output.Cmp(totalAmount) == 0, "output of 'world' should match", - Details{ + internal.Details{ "output": output, }, ) } -func runTx(ctx context.Context, client *client.Formance, amount *big.Int) (*big.Int, error) { +func createLedger(ctx context.Context, client *client.Formance) error { + + _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ + Ledger: "default", + }) + + if assert.Always(err == nil, "ledger should have been created", internal.Details{ + "error": fmt.Sprintf("%+v\n", err), + }); err != nil { + return err + } + + return nil +} + +func runTx(ctx context.Context, client *client.Formance, amount *big.Int) error { orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) dest := fmt.Sprintf("orders:%s", orderID) - res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ + _, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Postings: []components.V2Posting{{ Amount: amount, @@ -120,14 +110,5 @@ func runTx(ctx context.Context, client *client.Formance, amount *big.Int) (*big. }, Ledger: "default", }) - - assert.Always( - err == nil, - "creating transaction from @world to $account always return a nil error", - Details{ - "error": fmt.Sprintf("%+v\n", err), - }, - ) - - return res.V2CreateTransactionResponse.Data.ID, err + return err } diff --git a/test/antithesis/workload/bin/init/main.go b/test/antithesis/workload/bin/init/main.go new file mode 100644 index 0000000000..a469dbe5d3 --- /dev/null +++ b/test/antithesis/workload/bin/init/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "context" + "github.com/antithesishq/antithesis-sdk-go/lifecycle" + "github.com/formancehq/ledger/test/antithesis/internal" + "os" + "os/signal" + "syscall" + "time" +) + +func main() { + ctx := context.Background() + client := internal.NewClient() + + for { + time.Sleep(time.Second) + + _, err := client.Ledger.GetInfo(ctx) + if err != nil { + continue + } + break + } + + lifecycle.SetupComplete(map[string]any{ + "Ledger": "Available", + }) + + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) + + <-sigs +} diff --git a/test/antithesis/workload/cmd/lifecycle.go b/test/antithesis/workload/cmd/lifecycle.go deleted file mode 100644 index f649e02954..0000000000 --- a/test/antithesis/workload/cmd/lifecycle.go +++ /dev/null @@ -1,31 +0,0 @@ -package cmd - -import ( - "context" - "fmt" - "github.com/formancehq/ledger/pkg/client" - "os" - "time" -) - -func waitServicesReady(ctx context.Context, client *client.Formance) { - fmt.Println("Waiting for services to be ready") - waitingServicesCtx, cancel := context.WithDeadline(ctx, time.Now().Add(30*time.Second)) - defer cancel() - - for { - select { - case <-time.After(time.Second): - fmt.Println("Trying to get info of the ledger...") - _, err := client.Ledger.GetInfo(ctx) - if err != nil { - fmt.Printf("error pinging ledger: %s\r\n", err) - continue - } - return - case <-waitingServicesCtx.Done(): - fmt.Printf("timeout waiting for services to be ready\r\n") - os.Exit(1) - } - } -} diff --git a/test/antithesis/workload/cmd/root.go b/test/antithesis/workload/cmd/root.go deleted file mode 100644 index 7eac0b0d67..0000000000 --- a/test/antithesis/workload/cmd/root.go +++ /dev/null @@ -1,30 +0,0 @@ -package cmd - -import ( - "os" - - "github.com/spf13/cobra" -) - - - -// rootCmd represents the base command when called without any subcommands -var rootCmd = &cobra.Command{ - Use: "antithesis", - Run: run, -} - -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() { - err := rootCmd.Execute() - if err != nil { - os.Exit(1) - } -} - -func init() { - rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") -} - - diff --git a/test/antithesis/workload/cmd/run.go b/test/antithesis/workload/cmd/run.go deleted file mode 100644 index 79fd06ae3c..0000000000 --- a/test/antithesis/workload/cmd/run.go +++ /dev/null @@ -1,50 +0,0 @@ -package cmd - -import ( - "context" - "fmt" - "github.com/formancehq/ledger/pkg/client/models/operations" - "github.com/spf13/cobra" - "net/http" - "time" - - "github.com/antithesishq/antithesis-sdk-go/assert" - "github.com/formancehq/ledger/pkg/client" -) - -type Details map[string]any - -func run(cmd *cobra.Command, _ []string) { - client := client.New( - client.WithServerURL("http://gateway:8080"), - client.WithClient(&http.Client{ - Timeout: 10 * time.Second, - }), - ) - - waitServicesReady(cmd.Context(), client) - <-time.After(10 * time.Second) - runWorkload(cmd.Context(), client) -} - -func createLedger(ctx context.Context, client *client.Formance) error { - - deadline := time.Now().Add(10 * time.Second) - ctx, cancel := context.WithDeadline(ctx, deadline) - defer cancel() - - fmt.Printf("Creating ledger with deadline %s...\r\n", deadline) - _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ - Ledger: "default", - }) - - if assert.Always(err == nil, "ledger should have been created", Details{ - "error": fmt.Sprintf("%+v\n", err), - }); err != nil { - return err - } - - fmt.Println("Ledger created!") - - return nil -} diff --git a/test/antithesis/workload/cmd/utils.go b/test/antithesis/workload/cmd/utils.go deleted file mode 100644 index a98b713a79..0000000000 --- a/test/antithesis/workload/cmd/utils.go +++ /dev/null @@ -1,59 +0,0 @@ -package cmd - -import ( - "fmt" - "math/big" - "sync" - - "github.com/antithesishq/antithesis-sdk-go/random" -) - -func randomBigInt() *big.Int { - v := random.GetRandom() - ret := big.NewInt(0) - ret.SetString(fmt.Sprintf("%d", v), 10) - return ret -} - -type IDSeq struct { - sync.Mutex - Count int64 - Sum *big.Int -} - -func NewIDSeq() *IDSeq { - return &IDSeq{ - Count: 0, - Sum: big.NewInt(0), - } -} - -func (s *IDSeq) Register(id *big.Int) { - s.Lock() - defer s.Unlock() - - s.Count++ - s.Sum.Add(s.Sum, id) -} - -func (s *IDSeq) Check() error { - s.Lock() - defer s.Unlock() - - // As the IDs are generated sequentially, the - // expected sum is the sum of the first n integers - // where n is the number of IDs generated. - expectedSum := big.NewInt(0).Div( - big.NewInt(0).Mul( - big.NewInt(s.Count-1), - big.NewInt(0).Add(big.NewInt(s.Count-1), big.NewInt(1)), - ), - big.NewInt(2), - ) - - if s.Sum.Cmp(expectedSum) != 0 { - return fmt.Errorf("sum of IDs is incorrect") - } - - return nil -} diff --git a/test/antithesis/workload/cmd/utils_test.go b/test/antithesis/workload/cmd/utils_test.go deleted file mode 100644 index fd6190661b..0000000000 --- a/test/antithesis/workload/cmd/utils_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package cmd - -import ( - "fmt" - "math/big" - "testing" -) - -func TestIDSeq(t *testing.T) { - idSeq := NewIDSeq() - - for i := 0; i < 10; i++ { - idSeq.Register(big.NewInt(int64(i))) - } - - if err := idSeq.Check(); err != nil { - fmt.Println(idSeq.Count, idSeq.Sum) - t.Errorf("IDSeq check failed") - } -} diff --git a/test/antithesis/workload/go.mod b/test/antithesis/workload/go.mod index 5a614925e5..6acf815dd4 100644 --- a/test/antithesis/workload/go.mod +++ b/test/antithesis/workload/go.mod @@ -1,24 +1,27 @@ module github.com/formancehq/ledger/test/antithesis -go 1.21 +go 1.22.0 -toolchain go1.22.0 +toolchain go1.23.2 replace github.com/formancehq/ledger/pkg/client => ../../../pkg/client require ( github.com/alitto/pond v1.8.3 - github.com/antithesishq/antithesis-sdk-go v0.3.8 - github.com/formancehq/formance-sdk-go/v2 v2.1.3 + github.com/antithesishq/antithesis-sdk-go v0.4.2 + github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 - github.com/formancehq/stack/libs/go-libs v0.0.0-20240412081813-558ce638a33b go.uber.org/atomic v1.10.0 ) require ( + github.com/bahlo/generic-list-go v0.2.0 // indirect + github.com/buger/jsonparser v1.1.1 // indirect github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/spf13/cobra v1.8.1 // indirect - github.com/spf13/pflag v1.0.5 // indirect + github.com/invopop/jsonschema v0.12.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/test/antithesis/workload/go.sum b/test/antithesis/workload/go.sum index 8bc0368e56..0286b6e241 100644 --- a/test/antithesis/workload/go.sum +++ b/test/antithesis/workload/go.sum @@ -1,31 +1,35 @@ github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= -github.com/antithesishq/antithesis-sdk-go v0.3.8 h1:OvGoHxIcOXFJLyn9IJQ5DzByZ3YVAWNBc394ObzDRb8= -github.com/antithesishq/antithesis-sdk-go v0.3.8/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= +github.com/antithesishq/antithesis-sdk-go v0.4.2 h1:cYLNRnojCYp6rKoLKdK6M9UKi9EahFXBtF6WR1vc6V0= +github.com/antithesishq/antithesis-sdk-go v0.4.2/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= +github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= +github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= +github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= -github.com/formancehq/formance-sdk-go/v2 v2.1.3 h1:9RpF1DkkJZWsKO2sFgF6DVr0bEaCUYNdI6bC3J0Yrz0= -github.com/formancehq/formance-sdk-go/v2 v2.1.3/go.mod h1:NjU319mP7CaRRpCEAuqP4biPuCBLd+OY5hD8PYOG+JY= -github.com/formancehq/stack/libs/go-libs v0.0.0-20240412081813-558ce638a33b h1:Z1DaupQL+i5dgZjCnhdGDs2Zevzv8DuyCSddnnDWjBw= -github.com/formancehq/stack/libs/go-libs v0.0.0-20240412081813-558ce638a33b/go.mod h1:YdhBeBSjIECXCw7g5V1Ie9LxFCXCme0s15lP2D6grVU= -github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= -github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= -github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 h1:l6jieaR+sn4Ff+puBDMbTYmT2HTYC7Yt7GTxBAwC3eU= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9/go.mod h1:m0uKkey9OC/AeyWMwjMfZqhLzoWrPFBk8vuYdSSYj4Y= +github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= +github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= +github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go new file mode 100644 index 0000000000..4f0ceb21e1 --- /dev/null +++ b/test/antithesis/workload/internal/utils.go @@ -0,0 +1,50 @@ +package internal + +import ( + "fmt" + "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/antithesishq/antithesis-sdk-go/random" + "github.com/formancehq/go-libs/v2/time" + "github.com/formancehq/ledger/pkg/client" + "github.com/formancehq/ledger/pkg/client/retry" + "math/big" + "net/http" +) + +type Details map[string]any + +func RandomBigInt() *big.Int { + v := random.GetRandom() + ret := big.NewInt(0) + ret.SetString(fmt.Sprintf("%d", v), 10) + return ret +} + +func AssertAlways(condition bool, message string, details map[string]any) bool { + assert.Always(condition, message, details) + return condition +} + +func AssertAlwaysErrNil(err error, message string) bool { + return AssertAlways(err == nil, message, Details{ + "error": fmt.Sprint(err), + }) +} + +func NewClient() *client.Formance { + return client.New( + client.WithServerURL("http://gateway:8080"), + client.WithClient(&http.Client{ + Timeout: time.Minute, + }), + client.WithRetryConfig(retry.Config{ + Strategy: "backoff", + Backoff: &retry.BackoffStrategy{ + InitialInterval: 200, + Exponent: 1.5, + MaxElapsedTime: 4000, + }, + RetryConnectionErrors: true, + }), + ) +} diff --git a/test/antithesis/workload/main.go b/test/antithesis/workload/main.go deleted file mode 100644 index 3ef2e966d4..0000000000 --- a/test/antithesis/workload/main.go +++ /dev/null @@ -1,11 +0,0 @@ -/* -Copyright © 2024 NAME HERE - -*/ -package main - -import "github.com/formancehq/ledger/test/antithesis/cmd" - -func main() { - cmd.Execute() -} diff --git a/test/rolling-upgrades/go.mod b/test/rolling-upgrades/go.mod index 5d4f65e885..99d8ef9bdb 100644 --- a/test/rolling-upgrades/go.mod +++ b/test/rolling-upgrades/go.mod @@ -9,7 +9,7 @@ replace github.com/formancehq/ledger/pkg/client => ../../pkg/client replace github.com/formancehq/ledger => ../.. require ( - github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 + github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778 github.com/formancehq/ledger v0.0.0-00010101000000-000000000000 github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.12.0 github.com/pulumi/pulumi/sdk/v3 v3.117.0 diff --git a/test/rolling-upgrades/go.sum b/test/rolling-upgrades/go.sum index e9ab1cc7b6..c04f9517cd 100644 --- a/test/rolling-upgrades/go.sum +++ b/test/rolling-upgrades/go.sum @@ -56,8 +56,8 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 h1:l6jieaR+sn4Ff+puBDMbTYmT2HTYC7Yt7GTxBAwC3eU= -github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9/go.mod h1:m0uKkey9OC/AeyWMwjMfZqhLzoWrPFBk8vuYdSSYj4Y= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778 h1:k/PmHjR692rBLxCanof/lD0c1K8WLKCNYCl5y1EHJPg= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778/go.mod h1:6vkHEfWEkDSPOv/G2o1Exxra3ouuYxRiCkznwKxTMHU= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= diff --git a/tools/generator/go.mod b/tools/generator/go.mod index ae37af068f..756cb7acfa 100644 --- a/tools/generator/go.mod +++ b/tools/generator/go.mod @@ -9,7 +9,7 @@ replace github.com/formancehq/ledger => ../.. replace github.com/formancehq/ledger/pkg/client => ../../pkg/client require ( - github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 + github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778 github.com/formancehq/ledger v0.0.0-00010101000000-000000000000 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 github.com/spf13/cobra v1.8.1 diff --git a/tools/generator/go.sum b/tools/generator/go.sum index 44dc83bc19..aff71c5d7a 100644 --- a/tools/generator/go.sum +++ b/tools/generator/go.sum @@ -28,34 +28,34 @@ github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYW github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0 h1:UyjtGmO0Uwl/K+zpzPwLoXzMhcN9xmnR2nrqJoBrg3c= github.com/aws/aws-msk-iam-sasl-signer-go v1.0.0/go.mod h1:TJAXuFs2HcMib3sN5L0gUC+Q01Qvy3DemvA55WuC+iA= -github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE= -github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= -github.com/aws/aws-sdk-go-v2/config v1.28.3 h1:kL5uAptPcPKaJ4q0sDUjUIdueO18Q7JDzl64GpVwdOM= -github.com/aws/aws-sdk-go-v2/config v1.28.3/go.mod h1:SPEn1KA8YbgQnwiJ/OISU4fz7+F6Fe309Jf0QTsRCl4= -github.com/aws/aws-sdk-go-v2/credentials v1.17.44 h1:qqfs5kulLUHUEXlHEZXLJkgGoF3kkUeFUTVA585cFpU= -github.com/aws/aws-sdk-go-v2/credentials v1.17.44/go.mod h1:0Lm2YJ8etJdEdw23s+q/9wTpOeo2HhNE97XcRa7T8MA= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19 h1:woXadbf0c7enQ2UGCi8gW/WuKmE0xIzxBF/eD94jMKQ= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19/go.mod h1:zminj5ucw7w0r65bP6nhyOd3xL6veAUMc3ElGMoLVb4= +github.com/aws/aws-sdk-go-v2 v1.32.5 h1:U8vdWJuY7ruAkzaOdD7guwJjD06YSKmnKCJs7s3IkIo= +github.com/aws/aws-sdk-go-v2 v1.32.5/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U= +github.com/aws/aws-sdk-go-v2/config v1.28.5 h1:Za41twdCXbuyyWv9LndXxZZv3QhTG1DinqlFsSuvtI0= +github.com/aws/aws-sdk-go-v2/config v1.28.5/go.mod h1:4VsPbHP8JdcdUDmbTVgNL/8w9SqOkM5jyY8ljIxLO3o= +github.com/aws/aws-sdk-go-v2/credentials v1.17.46 h1:AU7RcriIo2lXjUfHFnFKYsLCwgbz1E7Mm95ieIRDNUg= +github.com/aws/aws-sdk-go-v2/credentials v1.17.46/go.mod h1:1FmYyLGL08KQXQ6mcTlifyFXfJVCNJTVGuQP4m0d/UA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20 h1:sDSXIrlsFSFJtWKLQS4PUWRvrT580rrnuLydJrCQ/yA= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.20/go.mod h1:WZ/c+w0ofps+/OUqMwWgnfrgzZH1DZO1RIkktICsqnY= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.4.23 h1:B2qK61ZXCQu8tkD6eG/gUiIt9Vw9tmWFD7Xo02JPdMY= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.4.23/go.mod h1:02rz9vMZsrOX9IwUcpoGZM4jPprFNPmtD6t9Ume9ECY= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 h1:A2w6m6Tmr+BNXjDsr7M90zkWjsu4JXHwrzPg235STs4= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23/go.mod h1:35EVp9wyeANdujZruvHiQUAo9E3vbhnIO1mTCAxMlY0= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 h1:pgYW9FCabt2M25MoHYCfMrVY2ghiiBKYWUVXfwZs+sU= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23/go.mod h1:c48kLgzO19wAu3CPkDWC28JbaJ+hfQlsdl7I2+oqIbk= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24 h1:4usbeaes3yJnCFC7kfeyhkdkPtoRYPa/hTmCqMpKpLI= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.24/go.mod h1:5CI1JemjVwde8m2WG3cz23qHKPOxbpkq0HaoreEgLIY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24 h1:N1zsICrQglfzaBnrfM0Ys00860C+QFwu6u/5+LomP+o= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.24/go.mod h1:dCn9HbJ8+K31i8IQ8EWmWj0EiIk0+vKiHNMxTTYveAg= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 h1:tHxQi/XHPK0ctd/wdOw0t7Xrc2OxcRCnVzv8lwWPu0c= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4/go.mod h1:4GQbF1vJzG60poZqWatZlhP31y8PGCCVTvIGPdaaYJ0= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 h1:HJwZwRt2Z2Tdec+m+fPjvdmkq2s9Ra+VR0hjF7V2o40= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.5/go.mod h1:wrMCEwjFPms+V86TCQQeOxQF/If4vT44FGIOFiMC2ck= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 h1:zcx9LiGWZ6i6pjdcoE9oXAB6mUdeyC36Ia/QEiIvYdg= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4/go.mod h1:Tp/ly1cTjRLGBBmNccFumbZ8oqpZlpdhFf80SrRh4is= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.4 h1:yDxvkz3/uOKfxnv8YhzOi9m+2OGIxF+on3KOISbK5IU= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.4/go.mod h1:9XEUty5v5UAsMiFOBJrNibZgwCeOma73jgGwwhgffa8= -github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= -github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5 h1:wtpJ4zcwrSbwhECWQoI/g6WM9zqCcSpHDJIWSbMLOu4= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.5/go.mod h1:qu/W9HXQbbQ4+1+JcZp0ZNPV31ym537ZJN+fiS7Ti8E= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.6 h1:3zu537oLmsPfDMyjnUS2g+F2vITgy5pB74tHI+JBNoM= +github.com/aws/aws-sdk-go-v2/service/sso v1.24.6/go.mod h1:WJSZH2ZvepM6t6jwu4w/Z45Eoi75lPN7DcydSRtJg6Y= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5 h1:K0OQAsDywb0ltlFrZm0JHPY3yZp/S9OaoLU33S7vPS8= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.5/go.mod h1:ORITg+fyuMoeiQFiVGoqB3OydVTLkClw/ljbblMq6Cc= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1 h1:6SZUVRQNvExYlMLbHdlKB48x0fLbc2iVROyaNEwBHbU= +github.com/aws/aws-sdk-go-v2/service/sts v1.33.1/go.mod h1:GqWyYCwLXnlUB1lOAXQyNSPqPLQJvmo8J0DWBzp9mtg= +github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro= +github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw= @@ -100,8 +100,8 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 h1:l6jieaR+sn4Ff+puBDMbTYmT2HTYC7Yt7GTxBAwC3eU= -github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9/go.mod h1:m0uKkey9OC/AeyWMwjMfZqhLzoWrPFBk8vuYdSSYj4Y= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778 h1:k/PmHjR692rBLxCanof/lD0c1K8WLKCNYCl5y1EHJPg= +github.com/formancehq/go-libs/v2 v2.0.1-0.20241119202934-d93d89fd8778/go.mod h1:6vkHEfWEkDSPOv/G2o1Exxra3ouuYxRiCkznwKxTMHU= github.com/formancehq/numscript v0.0.9-0.20241009144012-1150c14a1417 h1:LOd5hxnXDIBcehFrpW1OnXk+VSs0yJXeu1iAOO+Hji4= github.com/formancehq/numscript v0.0.9-0.20241009144012-1150c14a1417/go.mod h1:btuSv05cYwi9BvLRxVs5zrunU+O1vTgigG1T6UsawcY= github.com/gkampitakis/ciinfo v0.3.0 h1:gWZlOC2+RYYttL0hBqcoQhM7h1qNkVqvRCV1fOvpAv8= @@ -135,8 +135,8 @@ github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIx github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= +github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= From 24c347af4fe582359c485c6aab26f865a1028ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Fri, 21 Feb 2025 23:34:08 +0100 Subject: [PATCH 04/66] wip: bring up to date and new driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- test/antithesis/Earthfile | 11 ++-- test/antithesis/image/Earthfile | 2 +- test/antithesis/workload/Earthfile | 42 ++++------------ .../main.go | 50 ++++--------------- test/antithesis/workload/bin/init/main.go | 9 ++-- test/antithesis/workload/internal/utils.go | 42 +++++++++++++++- 6 files changed, 68 insertions(+), 88 deletions(-) rename test/antithesis/workload/bin/cmds/{singleton_driver_main => parallel_driver_transactions}/main.go (59%) diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile index ff11c9213b..36c037e3af 100644 --- a/test/antithesis/Earthfile +++ b/test/antithesis/Earthfile @@ -25,11 +25,8 @@ run: }" requirements-build: - ARG --required ANTITHESIS_REPOSITORY + ARG --required ANTITHESIS_REPOSITORY - BUILD --pass-args ./config+build - BUILD --pass-args ./image+build - BUILD --pass-args ./workload+build - -pre-commit: - BUILD ./workload+pre-commit \ No newline at end of file + BUILD --pass-args ./config+build + BUILD --pass-args ./image+build + BUILD --pass-args ./workload+build \ No newline at end of file diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index b6b9b5e071..118d292f6b 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -8,7 +8,7 @@ CACHE --sharing=shared --id go-mod-cache /go/pkg/mod CACHE --sharing=shared --id go-cache /root/.cache/go-build compile: - FROM --platform=linux/amd64 golang:1.22.2 + FROM --platform=linux/amd64 golang:1.23 CACHE --sharing=shared --id go-mod-cache /go/pkg/mod CACHE --sharing=shared --id go-cache /root/.cache/go-build diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile index fb4aa9f202..bc1f89eb00 100644 --- a/test/antithesis/workload/Earthfile +++ b/test/antithesis/workload/Earthfile @@ -4,44 +4,25 @@ FROM --platform=linux/amd64 golang:1.22.2 CACHE --sharing=shared --id go-mod-cache /go/pkg/mod CACHE --sharing=shared --id go-cache /root/.cache/go-build -CACHE --sharing=shared --id golangci-cache /root/.cache/golangci-lint sources: - COPY --dir ../../..+lint/* /src/ - COPY ../../..+tidy/* /src/ - WORKDIR /src/test/antithesis/workload COPY go.* . COPY --dir bin internal . SAVE ARTIFACT /src -tidy: - FROM +sources - - CACHE --id go-mod-cache /go/pkg/mod - CACHE --id go-cache /root/.cache/go-build - - WORKDIR /src/test/antithesis/workload - RUN go mod tidy - - SAVE ARTIFACT go.mod AS LOCAL go.mod - SAVE ARTIFACT go.sum AS LOCAL go.sum - -lint: - #todo: get config from core - FROM +tidy - - RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0 +# tidy: +# FROM +sources - CACHE --id go-mod-cache /go/pkg/mod - CACHE --id go-cache /root/.cache/go-build - CACHE --id golangci-cache /root/.cache/golangci-lint +# CACHE --id go-mod-cache /go/pkg/mod +# CACHE --id go-cache /root/.cache/go-build - RUN golangci-lint run --fix --timeout 5m +# WORKDIR /src/test/antithesis/workload +# RUN go mod tidy - SAVE ARTIFACT bin AS LOCAL bin - SAVE ARTIFACT internal AS LOCAL internal +# SAVE ARTIFACT go.mod AS LOCAL go.mod +# SAVE ARTIFACT go.sum AS LOCAL go.sum compile: CACHE --id go-mod-cache /go/pkg/mod @@ -52,6 +33,7 @@ compile: COPY +sources/src /src WORKDIR /src/test/antithesis/workload + COPY --dir ../../../pkg/client+client/client ../../../pkg/client RUN mkdir -p /workload_instrumented RUN mkdir -p /out/cmds @@ -73,8 +55,4 @@ build: ARG --required ANTITHESIS_REPOSITORY - SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest - -pre-commit: - BUILD +tidy - BUILD +lint \ No newline at end of file + SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest \ No newline at end of file diff --git a/test/antithesis/workload/bin/cmds/singleton_driver_main/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go similarity index 59% rename from test/antithesis/workload/bin/cmds/singleton_driver_main/main.go rename to test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index ca295a9a20..44b8ded27a 100644 --- a/test/antithesis/workload/bin/cmds/singleton_driver_main/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -3,24 +3,25 @@ package main import ( "context" "fmt" + "math/big" + "github.com/alitto/pond" "github.com/antithesishq/antithesis-sdk-go/assert" - "github.com/antithesishq/antithesis-sdk-go/random" "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/ledger/pkg/client" - "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/antithesis/internal" "go.uber.org/atomic" - "math" - "math/big" ) func main() { ctx := context.Background() client := internal.NewClient() - err := createLedger(ctx, client) + err := internal.CreateLedger( + ctx, + client, + fmt.Sprintf("ledger-%d", internal.RandomBigInt().Int64()), + ) if err != nil { assert.Always(err == nil, "ledger should have been created", internal.Details{ "error": err, @@ -33,14 +34,14 @@ func main() { hasError := atomic.NewBool(false) totalAmount := big.NewInt(0) - pool := pond.New(10, 10000) + pool := pond.New(10, 10e3) for i := 0; i < count; i++ { amount := internal.RandomBigInt() totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { if !internal.AssertAlwaysErrNil( - runTx(ctx, client, amount), + internal.RunTx(ctx, client, amount), "creating transaction from @world to $account always return a nil error", ) { hasError.CompareAndSwap(false, true) @@ -79,36 +80,3 @@ func main() { }, ) } - -func createLedger(ctx context.Context, client *client.Formance) error { - - _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ - Ledger: "default", - }) - - if assert.Always(err == nil, "ledger should have been created", internal.Details{ - "error": fmt.Sprintf("%+v\n", err), - }); err != nil { - return err - } - - return nil -} - -func runTx(ctx context.Context, client *client.Formance, amount *big.Int) error { - orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) - dest := fmt.Sprintf("orders:%s", orderID) - - _, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ - V2PostTransaction: components.V2PostTransaction{ - Postings: []components.V2Posting{{ - Amount: amount, - Asset: "USD/2", - Destination: dest, - Source: "world", - }}, - }, - Ledger: "default", - }) - return err -} diff --git a/test/antithesis/workload/bin/init/main.go b/test/antithesis/workload/bin/init/main.go index a469dbe5d3..e58198415d 100644 --- a/test/antithesis/workload/bin/init/main.go +++ b/test/antithesis/workload/bin/init/main.go @@ -2,12 +2,13 @@ package main import ( "context" - "github.com/antithesishq/antithesis-sdk-go/lifecycle" - "github.com/formancehq/ledger/test/antithesis/internal" "os" "os/signal" "syscall" "time" + + "github.com/antithesishq/antithesis-sdk-go/lifecycle" + "github.com/formancehq/ledger/test/antithesis/internal" ) func main() { @@ -24,9 +25,7 @@ func main() { break } - lifecycle.SetupComplete(map[string]any{ - "Ledger": "Available", - }) + lifecycle.SetupComplete(map[string]any{}) sigs := make(chan os.Signal, 1) signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 4f0ceb21e1..e550c2b86a 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -1,14 +1,19 @@ package internal import ( + "context" "fmt" + "math" + "math/big" + "net/http" + "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/antithesishq/antithesis-sdk-go/random" "github.com/formancehq/go-libs/v2/time" "github.com/formancehq/ledger/pkg/client" + "github.com/formancehq/ledger/pkg/client/models/components" + "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/pkg/client/retry" - "math/big" - "net/http" ) type Details map[string]any @@ -48,3 +53,36 @@ func NewClient() *client.Formance { }), ) } + +func CreateLedger(ctx context.Context, client *client.Formance, name string) error { + + _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ + Ledger: name, + }) + + if assert.Always(err == nil, "ledger should have been created", Details{ + "error": fmt.Sprintf("%+v\n", err), + }); err != nil { + return err + } + + return nil +} + +func RunTx(ctx context.Context, client *client.Formance, amount *big.Int) error { + orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) + dest := fmt.Sprintf("orders:%s", orderID) + + _, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ + V2PostTransaction: components.V2PostTransaction{ + Postings: []components.V2Posting{{ + Amount: amount, + Asset: "USD/2", + Destination: dest, + Source: "world", + }}, + }, + Ledger: "default", + }) + return err +} From 0addc57463fc5e65c74dbbdc54bbfd42951d826f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Thu, 13 Mar 2025 13:50:37 +0100 Subject: [PATCH 05/66] fix: test composer changes --- go.mod | 1 + go.sum | 2 + internal/controller/system/controller.go | 5 +- internal/storage/driver/driver.go | 51 ++++++++++++++++++- pkg/client/Earthfile | 8 +++ .../main.go | 3 +- .../cmds/parallel_driver_transactions/main.go | 16 +++--- test/antithesis/workload/internal/utils.go | 18 +++---- 8 files changed, 82 insertions(+), 22 deletions(-) create mode 100644 pkg/client/Earthfile diff --git a/go.mod b/go.mod index 3d8ed3380a..6dac650778 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ replace google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215 => google. require ( github.com/ThreeDotsLabs/watermill v1.4.4 github.com/alitto/pond v1.9.2 + github.com/antithesishq/antithesis-sdk-go v0.4.3 github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20241009100908-5f46f2705ca3 diff --git a/go.sum b/go.sum index b6ccf30d9e..99455cc011 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= +github.com/antithesishq/antithesis-sdk-go v0.4.3 h1:a2hGdDogClzHzFu20r1z0tzD6zwSWUipiaerAjZVP90= +github.com/antithesishq/antithesis-sdk-go v0.4.3/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= diff --git a/internal/controller/system/controller.go b/internal/controller/system/controller.go index ca2f836c0d..d94e94cc09 100644 --- a/internal/controller/system/controller.go +++ b/internal/controller/system/controller.go @@ -2,11 +2,12 @@ package system import ( "context" - "github.com/formancehq/ledger/pkg/features" - "go.opentelemetry.io/otel/attribute" "reflect" "time" + "github.com/formancehq/ledger/pkg/features" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" noopmetrics "go.opentelemetry.io/otel/metric/noop" "go.opentelemetry.io/otel/trace" diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index 519f34d0d4..87c59f66f7 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -4,7 +4,10 @@ import ( "context" "errors" "fmt" + "time" + "github.com/alitto/pond" + "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/go-libs/v2/metadata" "github.com/formancehq/go-libs/v2/migrations" "github.com/formancehq/go-libs/v2/platform/postgres" @@ -14,7 +17,6 @@ import ( noopmetrics "go.opentelemetry.io/otel/metric/noop" "go.opentelemetry.io/otel/trace" nooptracer "go.opentelemetry.io/otel/trace/noop" - "time" ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger" @@ -37,8 +39,43 @@ type Driver struct { parallelBucketMigrations int } +/* +CreateLedger creates a new ledger in the system and sets up all necessary database objects. + +The function follows these steps: + 1. Create a ledger record in the system store (_system.ledgers table) + 2. Get the bucket (database schema) for this ledger + 3. Check if the bucket is already initialized: + a. If initialized: Verify it's up to date and add ledger-specific objects to it + b. If not initialized: Create the bucket schema with all necessary tables + 4. Return a ledger store that provides an interface to interact with the ledger + +Note: This process is not atomic. If context cancellation occurs between creating +the ledger record and setting up the bucket, the system could be left in an +inconsistent state with a ledger record but no corresponding database objects. +*/ func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgerstore.Store, error) { + // Track whether we've successfully created the ledger in the system store + ledgerCreatedInSystemStore := false + bucketSetupComplete := false + + // Defer an assertion check that will run when the function exits + defer func() { + // The invariant we want to check: + // Either (1) both steps completed successfully OR (2) neither step completed + // If only the ledger was created but bucket setup failed, that's a problem + invariantMaintained := (!ledgerCreatedInSystemStore && !bucketSetupComplete) || + (ledgerCreatedInSystemStore && bucketSetupComplete) + + assert.Always(invariantMaintained, "ledger_creation_atomic", map[string]any{ + "ledger_name": l.Name, + "bucket": l.Bucket, + "ledger_created_in_system_store": ledgerCreatedInSystemStore, + "bucket_setup_complete": bucketSetupComplete, + }) + }() + // Create ledger record in system store if err := d.systemStore.CreateLedger(ctx, l); err != nil { if errors.Is(postgres.ResolveError(err), postgres.ErrConstraintsFailed{}) { return nil, systemcontroller.ErrLedgerAlreadyExists @@ -46,12 +83,18 @@ func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgersto return nil, postgres.ResolveError(err) } + // Mark that we've successfully created the ledger in the system store + ledgerCreatedInSystemStore = true + + // Get the bucket for this ledger b := d.bucketFactory.Create(l.Bucket) isInitialized, err := b.IsInitialized(ctx) if err != nil { return nil, fmt.Errorf("checking if bucket is initialized: %w", err) } + if isInitialized { + // Bucket exists - check if it's up to date upToDate, err := b.IsUpToDate(ctx) if err != nil { return nil, fmt.Errorf("checking if bucket is up to date: %w", err) @@ -61,10 +104,12 @@ func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgersto return nil, systemcontroller.ErrBucketOutdated } + // Add ledger-specific objects to the bucket if err := b.AddLedger(ctx, *l); err != nil { return nil, fmt.Errorf("adding ledger to bucket: %w", err) } } else { + // Bucket doesn't exist - create it if err := b.Migrate( ctx, migrations.WithLockRetryInterval(d.migratorLockRetryInterval), @@ -73,6 +118,10 @@ func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgersto } } + // Mark that bucket setup is complete + bucketSetupComplete = true + + // Create and return a store for interacting with the ledger return d.ledgerStoreFactory.Create(b, *l), nil } diff --git a/pkg/client/Earthfile b/pkg/client/Earthfile new file mode 100644 index 0000000000..a17835da3f --- /dev/null +++ b/pkg/client/Earthfile @@ -0,0 +1,8 @@ +VERSION 0.7 + +FROM --platform=linux/amd64 golang:1.22.2 + +client: + FROM scratch + COPY . /client + SAVE ARTIFACT /client client \ No newline at end of file diff --git a/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go b/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go index 959a32bd47..8079ed4015 100644 --- a/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go @@ -2,10 +2,11 @@ package main import ( "context" + "math/big" + "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/antithesis/internal" - "math/big" ) func main() { diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 44b8ded27a..07d8182ada 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -16,20 +16,21 @@ import ( func main() { ctx := context.Background() client := internal.NewClient() + ledger := fmt.Sprintf("ledger-%d", internal.RandomBigInt().Int64()) err := internal.CreateLedger( ctx, client, - fmt.Sprintf("ledger-%d", internal.RandomBigInt().Int64()), + ledger, ) if err != nil { - assert.Always(err == nil, "ledger should have been created", internal.Details{ + assert.Always(err == nil, "ledger should have been created properly", internal.Details{ "error": err, }) return } - const count = 1000 + const count = 100 hasError := atomic.NewBool(false) totalAmount := big.NewInt(0) @@ -41,8 +42,11 @@ func main() { totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { if !internal.AssertAlwaysErrNil( - internal.RunTx(ctx, client, amount), + internal.RunTx(ctx, client, amount, ledger), "creating transaction from @world to $account always return a nil error", + internal.Details{ + "ledger": ledger, + }, ) { hasError.CompareAndSwap(false, true) } @@ -59,10 +63,10 @@ func main() { account, err := client.Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ Address: "world", Expand: pointer.For("volumes"), - Ledger: "default", + Ledger: ledger, }) - if !internal.AssertAlwaysErrNil(err, "we should be able to query account 'world'") { + if !internal.AssertAlwaysErrNil(err, "we should be able to query account 'world'", nil) { return } diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index e550c2b86a..680f18cea0 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -30,9 +30,10 @@ func AssertAlways(condition bool, message string, details map[string]any) bool { return condition } -func AssertAlwaysErrNil(err error, message string) bool { +func AssertAlwaysErrNil(err error, message string, details map[string]any) bool { return AssertAlways(err == nil, message, Details{ - "error": fmt.Sprint(err), + "error": fmt.Sprint(err), + "details": details, }) } @@ -55,21 +56,14 @@ func NewClient() *client.Formance { } func CreateLedger(ctx context.Context, client *client.Formance, name string) error { - _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: name, }) - if assert.Always(err == nil, "ledger should have been created", Details{ - "error": fmt.Sprintf("%+v\n", err), - }); err != nil { - return err - } - - return nil + return err } -func RunTx(ctx context.Context, client *client.Formance, amount *big.Int) error { +func RunTx(ctx context.Context, client *client.Formance, amount *big.Int, ledger string) error { orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) dest := fmt.Sprintf("orders:%s", orderID) @@ -82,7 +76,7 @@ func RunTx(ctx context.Context, client *client.Formance, amount *big.Int) error Source: "world", }}, }, - Ledger: "default", + Ledger: ledger, }) return err } From d64d1ef04a34be5db2274b78581856e8c09426c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Thu, 13 Mar 2025 18:26:10 +0100 Subject: [PATCH 06/66] wip: improve assertions --- internal/storage/driver/driver.go | 64 ++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index ba966c64a2..430ad2b400 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -8,6 +8,7 @@ import ( "time" "github.com/alitto/pond" + "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/go-libs/v2/metadata" "github.com/formancehq/go-libs/v2/platform/postgres" systemcontroller "github.com/formancehq/ledger/internal/controller/system" @@ -38,51 +39,112 @@ type Driver struct { parallelBucketMigrations int } -func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgerstore.Store, error) { +/* +CreateLedger creates a new ledger in the system and sets up all necessary database objects. + +The function follows these steps: + 1. Create a ledger record in the system store (_system.ledgers table) + 2. Get the bucket (database schema) for this ledger + 3. Check if the bucket is already initialized: + a. If initialized: Verify it's up to date and add ledger-specific objects to it + b. If not initialized: Create the bucket schema with all necessary tables + 4. Return a ledger store that provides an interface to interact with the ledger +Note: This entire process is wrapped in a database transaction, ensuring atomicity. +If any step fails, the entire transaction is rolled back, preventing partial state. +*/ +func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgerstore.Store, error) { var ret *ledgerstore.Store + + // Run the entire ledger creation process in a transaction for atomicity + // This ensures that either all steps succeed or none do (preventing partial state) err := d.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { + // Create a system store that uses the current transaction systemStore := systemstore.New(tx) + // Step 1: Create the ledger record in the system store if err := systemStore.CreateLedger(ctx, l); err != nil { + // Handle the case where the ledger already exists if errors.Is(postgres.ResolveError(err), postgres.ErrConstraintsFailed{}) { return systemcontroller.ErrLedgerAlreadyExists } return err } + // Step 2: Get a bucket handler for this ledger + // The bucket is a database schema where the ledger's data will be stored b := d.bucketFactory.Create(l.Bucket, tx) + + // Step 3: Check if the bucket is already initialized in the database isInitialized, err := b.IsInitialized(ctx) if err != nil { return fmt.Errorf("checking if bucket is initialized: %w", err) } + if isInitialized { + // Step 3a: Bucket exists - check if it's up to date upToDate, err := b.IsUpToDate(ctx) if err != nil { return fmt.Errorf("checking if bucket is up to date: %w", err) } if !upToDate { + assert.AlwaysOrUnreachable( + // @todo: replace this with a proper flag detailing wether we're + // operating a new version of the binary or not. + // if we are, we are definitely expecting this to happen. + // if we're not, this should be unreachable. + false, + "Bucket is outdated", + map[string]any{ + "bucket": l.Bucket, + }, + ) + return systemcontroller.ErrBucketOutdated } + // Add ledger-specific objects to the bucket + // This creates sequences and other database objects for this ledger if err := b.AddLedger(ctx, *l); err != nil { + assert.Unreachable( + "Adding ledger to bucket should never fail", + map[string]any{ + "bucket": l.Bucket, + "error": err, + }, + ) + return fmt.Errorf("adding ledger to bucket: %w", err) } } else { + // Step 3b: Bucket doesn't exist - create it + // This creates the bucket schema and all necessary tables if err := b.Migrate(ctx); err != nil { + assert.Unreachable( + "Migrating bucket should never fail", + map[string]any{ + "bucket": l.Bucket, + "error": err, + }, + ) + return fmt.Errorf("migrating bucket: %w", err) } } + // Step 4: Create a store for interacting with the ledger ret = d.ledgerStoreFactory.Create(b, *l) return nil }) + + // If any error occurred during the transaction, resolve and return it if err != nil { return nil, postgres.ResolveError(err) } + // Return the created ledger store return ret, nil } From 32759cc4a27bc387d660b8ed12627bf28465a800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Thu, 13 Mar 2025 18:53:07 +0100 Subject: [PATCH 07/66] fix: overly ambitious assertions --- internal/storage/driver/driver.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index 430ad2b400..1ad8ee16b0 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -107,28 +107,12 @@ func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgersto // Add ledger-specific objects to the bucket // This creates sequences and other database objects for this ledger if err := b.AddLedger(ctx, *l); err != nil { - assert.Unreachable( - "Adding ledger to bucket should never fail", - map[string]any{ - "bucket": l.Bucket, - "error": err, - }, - ) - return fmt.Errorf("adding ledger to bucket: %w", err) } } else { // Step 3b: Bucket doesn't exist - create it // This creates the bucket schema and all necessary tables if err := b.Migrate(ctx); err != nil { - assert.Unreachable( - "Migrating bucket should never fail", - map[string]any{ - "bucket": l.Bucket, - "error": err, - }, - ) - return fmt.Errorf("migrating bucket: %w", err) } } From a380c0b3aa96cb5b9f23f70dbb9fe9b5307df3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Thu, 13 Mar 2025 23:13:27 +0100 Subject: [PATCH 08/66] wip: add debugger --- test/antithesis/Earthfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile index 36c037e3af..4f2e5fac0f 100644 --- a/test/antithesis/Earthfile +++ b/test/antithesis/Earthfile @@ -24,6 +24,32 @@ run: } }" +debugger: + FROM curlimages/curl + + ARG ANTITHESIS_USERNAME=formance + ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT + ARG --required VTIME + ARG --required SESSION_ID + ARG --required HASH + RUN echo "{ + \"params\": { + \"antithesis.debugging.session_id\": \"${SESSION_ID}\", + \"antithesis.debugging.input_hash\": \"${HASH}\", + \"antithesis.debugging.vtime\": \"${VTIME}\", + \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\" + } + }" > /tmp/debug_params.json + + # Display the debug parameters for verification + RUN cat /tmp/debug_params.json + + RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ + --fail \ + --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ + -X POST https://formance.antithesis.com/api/v1/launch/debugging \ + -d @/tmp/debug_params.json + requirements-build: ARG --required ANTITHESIS_REPOSITORY From 0919823644c77db3cfc11efb7b549fc99a95b654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Wed, 23 Apr 2025 15:51:47 +0200 Subject: [PATCH 09/66] feat: add antithesis ci MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .github/workflows/antithesis.yml | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/antithesis.yml diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml new file mode 100644 index 0000000000..01110774e0 --- /dev/null +++ b/.github/workflows/antithesis.yml @@ -0,0 +1,62 @@ +name: Antithesis Integration +on: + workflow_dispatch: + inputs: + run_tests: + description: 'Run Antithesis tests after pushing images' + type: boolean + default: true + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + paths: + - 'test/antithesis/**' + +jobs: + push-antithesis-images: + name: Push Images to Antithesis + runs-on: shipfox-4vcpu-ubuntu-2404 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Earthly + uses: earthly/actions-setup@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: "latest" + + - name: Setup Environment + uses: ./.github/actions/default + with: + token: ${{ secrets.NUMARY_GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Antithesis Docker Registry + uses: docker/login-action@v3 + with: + registry: ${{ secrets.ANTITHESIS_REGISTRY }} + username: ${{ secrets.ANTITHESIS_USERNAME }} + password: ${{ secrets.ANTITHESIS_PASSWORD }} + + - name: Build and Push Config Image + run: | + cd test/antithesis + earthly --push +requirements-build --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REGISTRY }} + + - name: Run Antithesis Tests + if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} + run: | + cd test/antithesis + earthly --push +run --ANTITHESIS_SLACK_REPORT_RECIPIENT="${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }}" --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REGISTRY }} + env: + ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} \ No newline at end of file From 8aa8fb7c5d213e655b1c6aeb0eda9619d6e2f1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Wed, 23 Apr 2025 17:18:39 +0200 Subject: [PATCH 10/66] fix: antithesis registry docker login --- .github/workflows/antithesis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index 01110774e0..fd85b89561 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -42,11 +42,8 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Antithesis Docker Registry - uses: docker/login-action@v3 - with: - registry: ${{ secrets.ANTITHESIS_REGISTRY }} - username: ${{ secrets.ANTITHESIS_USERNAME }} - password: ${{ secrets.ANTITHESIS_PASSWORD }} + run: | + echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key --password-stdin ${{ secrets.ANTITHESIS_REGISTRY }} - name: Build and Push Config Image run: | From 6d3747a115c7f86b9a68e6022ddbdccd69256e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Wed, 23 Apr 2025 17:27:50 +0200 Subject: [PATCH 11/66] fix: antithesis docker login MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .github/workflows/antithesis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index fd85b89561..a4bfb87a61 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -43,7 +43,7 @@ jobs: - name: Login to Antithesis Docker Registry run: | - echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key --password-stdin ${{ secrets.ANTITHESIS_REGISTRY }} + echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin - name: Build and Push Config Image run: | From 256bfb97f1bf1835d29013643b1d2d0a73664217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Wed, 23 Apr 2025 17:53:38 +0200 Subject: [PATCH 12/66] fix: antithesis github workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .github/workflows/antithesis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index a4bfb87a61..f95fe24779 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -48,12 +48,12 @@ jobs: - name: Build and Push Config Image run: | cd test/antithesis - earthly --push +requirements-build --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REGISTRY }} + earthly --push +requirements-build --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REPOSITORY }} - name: Run Antithesis Tests if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} run: | cd test/antithesis - earthly --push +run --ANTITHESIS_SLACK_REPORT_RECIPIENT="${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }}" --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REGISTRY }} - env: - ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} \ No newline at end of file + earthly +run --ANTITHESIS_SLACK_REPORT_RECIPIENT="${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }}" --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REGISTRY }} --ANTITHESIS_PASSWORD=${{ secrets.ANTITHESIS_PASSWORD }} + # env: + # ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} \ No newline at end of file From 10acc49862ff2f8f8ab7dcdab5b18a8358596e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Wed, 23 Apr 2025 18:49:19 +0200 Subject: [PATCH 13/66] fix: workload build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- test/antithesis/workload/go.mod | 4 +--- test/antithesis/workload/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/antithesis/workload/go.mod b/test/antithesis/workload/go.mod index 6acf815dd4..53f78d6112 100644 --- a/test/antithesis/workload/go.mod +++ b/test/antithesis/workload/go.mod @@ -2,8 +2,6 @@ module github.com/formancehq/ledger/test/antithesis go 1.22.0 -toolchain go1.23.2 - replace github.com/formancehq/ledger/pkg/client => ../../../pkg/client require ( @@ -12,12 +10,12 @@ require ( github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 go.uber.org/atomic v1.10.0 + golang.org/x/sync v0.9.0 // indirect; indirect, for singleflight package ) require ( github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect github.com/invopop/jsonschema v0.12.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/test/antithesis/workload/go.sum b/test/antithesis/workload/go.sum index 0286b6e241..1c3c2cf9c7 100644 --- a/test/antithesis/workload/go.sum +++ b/test/antithesis/workload/go.sum @@ -6,8 +6,6 @@ github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPn github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= @@ -29,6 +27,8 @@ github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/ github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From a2351d6c4aa3c222f4d7bd023b4d2428a532edc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Fri, 2 May 2025 13:51:06 +0200 Subject: [PATCH 14/66] feat: improve test composing sequence --- .../bin/cmds/first_default_ledger/main.go | 26 +++++++++++++++ .../cmds/parallel_drive_ledger_create/main.go | 29 +++++++++++++++++ .../cmds/parallel_driver_transactions/main.go | 13 +------- .../main.go | 28 +++++++++++++--- test/antithesis/workload/internal/utils.go | 32 +++++++++++++++++++ tools/generator/cmd/root.go | 7 ++-- 6 files changed, 116 insertions(+), 19 deletions(-) create mode 100644 test/antithesis/workload/bin/cmds/first_default_ledger/main.go create mode 100644 test/antithesis/workload/bin/cmds/parallel_drive_ledger_create/main.go rename test/antithesis/workload/bin/cmds/{eventually_aggregated_volumes_should_be_zeroed => parallel_driver_volumes}/main.go (50%) diff --git a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go new file mode 100644 index 0000000000..aa7388db9e --- /dev/null +++ b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "context" + + "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/formancehq/ledger/test/antithesis/internal" +) + +func main() { + ctx := context.Background() + client := internal.NewClient() + ledger := "default" + + err := internal.CreateLedger( + ctx, + client, + ledger, + ) + if err != nil { + assert.Always(err == nil, "ledger should have been created properly", internal.Details{ + "error": err, + }) + return + } +} diff --git a/test/antithesis/workload/bin/cmds/parallel_drive_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_drive_ledger_create/main.go new file mode 100644 index 0000000000..75255b205d --- /dev/null +++ b/test/antithesis/workload/bin/cmds/parallel_drive_ledger_create/main.go @@ -0,0 +1,29 @@ +package main + +import ( + "context" + "fmt" + "math/big" + + "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/formancehq/ledger/test/antithesis/internal" +) + +func main() { + ctx := context.Background() + client := internal.NewClient() + id := big.NewInt(0).Abs(internal.RandomBigInt()).Int64() + ledger := fmt.Sprintf("ledger-%d", id) + + err := internal.CreateLedger( + ctx, + client, + ledger, + ) + if err != nil { + assert.Always(err == nil, "ledger should have been created properly", internal.Details{ + "error": err, + }) + return + } +} diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 07d8182ada..876963a092 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -16,19 +16,8 @@ import ( func main() { ctx := context.Background() client := internal.NewClient() - ledger := fmt.Sprintf("ledger-%d", internal.RandomBigInt().Int64()) - err := internal.CreateLedger( - ctx, - client, - ledger, - ) - if err != nil { - assert.Always(err == nil, "ledger should have been created properly", internal.Details{ - "error": err, - }) - return - } + ledger := fmt.Sprintf("ledger-%d", internal.RandomBigInt().Int64()) const count = 100 diff --git a/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go similarity index 50% rename from test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go rename to test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go index 8079ed4015..a81f884d85 100644 --- a/test/antithesis/workload/bin/cmds/eventually_aggregated_volumes_should_be_zeroed/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go @@ -2,9 +2,11 @@ package main import ( "context" + "fmt" "math/big" "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -13,8 +15,22 @@ func main() { ctx := context.Background() client := internal.NewClient() + ledgers, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{}) + if err != nil { + assert.Always(err == nil, "error listing ledgers", internal.Details{ + "error": err, + }) + return + } + + for _, ledger := range ledgers.V2LedgerListResponse.Cursor.Data { + go checkVolumes(ctx, client, ledger.Name) + } +} + +func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { aggregated, err := client.Ledger.V2.GetBalancesAggregated(ctx, operations.V2GetBalancesAggregatedRequest{ - Ledger: "default", + Ledger: ledger, }) if err != nil { assert.Always(err == nil, "error getting aggregated balances", internal.Details{ @@ -24,8 +40,12 @@ func main() { } for asset, volumes := range aggregated.V2AggregateBalancesResponse.Data { - assert.Always(volumes.Cmp(new(big.Int)) == 0, "aggregated volumes for asset "+asset+" should be 0", internal.Details{ - "error": err, - }) + assert.Always( + volumes.Cmp(new(big.Int)) == 0, + fmt.Sprintf("aggregated volumes for asset %s should be 0", + asset, + ), internal.Details{ + "error": err, + }) } } diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 680f18cea0..b502436ac9 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -5,6 +5,7 @@ import ( "fmt" "math" "math/big" + "math/rand" "net/http" "github.com/antithesishq/antithesis-sdk-go/assert" @@ -63,6 +64,37 @@ func CreateLedger(ctx context.Context, client *client.Formance, name string) err return err } +func ListLedgers(ctx context.Context, client *client.Formance) ([]string, error) { + res, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{}) + if err != nil { + return nil, err + } + + ledgers := []string{} + for _, ledger := range res.V2LedgerListResponse.Cursor.Data { + ledgers = append(ledgers, ledger.Name) + } + + return ledgers, nil +} + +func GetRandomLedger(ctx context.Context, client *client.Formance) (string, error) { + ledgers, err := ListLedgers(ctx, client) + if err != nil { + return "", err + } + + if len(ledgers) == 0 { + return "", fmt.Errorf("no ledgers found") + } + + // Get a random index within the ledgers slice + randomIndex := rand.Intn(len(ledgers)) + + // Return the ledger at the random index + return ledgers[randomIndex], nil +} + func RunTx(ctx context.Context, client *client.Formance, amount *big.Int, ledger string) error { orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) dest := fmt.Sprintf("orders:%s", orderID) diff --git a/tools/generator/cmd/root.go b/tools/generator/cmd/root.go index 3825417726..7f5e00d172 100644 --- a/tools/generator/cmd/root.go +++ b/tools/generator/cmd/root.go @@ -5,6 +5,10 @@ import ( "crypto/tls" "errors" "fmt" + "net/http" + "os" + "strings" + "github.com/formancehq/go-libs/v3/logging" ledgerclient "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" @@ -14,9 +18,6 @@ import ( "github.com/spf13/cobra" "golang.org/x/oauth2" "golang.org/x/oauth2/clientcredentials" - "net/http" - "os" - "strings" ) const ( From 58524d76702e93d097f5a01ebfa04eb3d6ade506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 12:34:43 +0200 Subject: [PATCH 15/66] feat: improve test composer sequence --- test/antithesis/Earthfile | 20 +++++++++++ test/antithesis/workload/Earthfile | 12 ------- .../bin/cmds/first_default_ledger/main.go | 5 +++ .../main.go | 4 +++ .../cmds/parallel_driver_transactions/main.go | 35 +++++-------------- .../bin/cmds/parallel_driver_volumes/main.go | 9 +++-- 6 files changed, 43 insertions(+), 42 deletions(-) rename test/antithesis/workload/bin/cmds/{parallel_drive_ledger_create => parallel_driver_ledger_create}/main.go (81%) diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile index 4f2e5fac0f..0052105553 100644 --- a/test/antithesis/Earthfile +++ b/test/antithesis/Earthfile @@ -24,6 +24,26 @@ run: } }" +run-1h: + WAIT + BUILD +requirements-build + END + + FROM curlimages/curl + ARG ANTITHESIS_USERNAME=formance + ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT + RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ + --fail \ + --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ + -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance -d "{ + \"params\": { + \"custom.duration\": \"1\", + \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", + \"antithesis.config_image\": \"antithesis-config:latest\", + \"antithesis.images\": \"ledger:latest;workload:latest\" + } + }" + debugger: FROM curlimages/curl diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile index bc1f89eb00..4dfef2d51b 100644 --- a/test/antithesis/workload/Earthfile +++ b/test/antithesis/workload/Earthfile @@ -12,18 +12,6 @@ sources: SAVE ARTIFACT /src -# tidy: -# FROM +sources - -# CACHE --id go-mod-cache /go/pkg/mod -# CACHE --id go-cache /root/.cache/go-build - -# WORKDIR /src/test/antithesis/workload -# RUN go mod tidy - -# SAVE ARTIFACT go.mod AS LOCAL go.mod -# SAVE ARTIFACT go.sum AS LOCAL go.sum - compile: CACHE --id go-mod-cache /go/pkg/mod CACHE --id go-cache /root/.cache/go-build diff --git a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go index aa7388db9e..96e2046daa 100644 --- a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go +++ b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go @@ -2,12 +2,15 @@ package main import ( "context" + "log" "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/test/antithesis/internal" ) func main() { + log.Println("composer: first_default_ledger") + ctx := context.Background() client := internal.NewClient() ledger := "default" @@ -23,4 +26,6 @@ func main() { }) return } + + log.Println("composer: first_default_ledger: done") } diff --git a/test/antithesis/workload/bin/cmds/parallel_drive_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go similarity index 81% rename from test/antithesis/workload/bin/cmds/parallel_drive_ledger_create/main.go rename to test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index 75255b205d..c882a8ba42 100644 --- a/test/antithesis/workload/bin/cmds/parallel_drive_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "log" "math/big" "github.com/antithesishq/antithesis-sdk-go/assert" @@ -10,6 +11,7 @@ import ( ) func main() { + log.Println("composer: parallel_driver_ledger_create") ctx := context.Background() client := internal.NewClient() id := big.NewInt(0).Abs(internal.RandomBigInt()).Int64() @@ -26,4 +28,6 @@ func main() { }) return } + + log.Println("composer: parallel_driver_ledger_create: done") } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 876963a092..2e582189fa 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -2,22 +2,25 @@ package main import ( "context" - "fmt" + "log" "math/big" "github.com/alitto/pond" "github.com/antithesishq/antithesis-sdk-go/assert" - "github.com/formancehq/go-libs/v2/pointer" - "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/antithesis/internal" "go.uber.org/atomic" ) func main() { + log.Println("composer: parallel_driver_transactions") + ctx := context.Background() client := internal.NewClient() - ledger := fmt.Sprintf("ledger-%d", internal.RandomBigInt().Int64()) + ledger, err := internal.GetRandomLedger(ctx, client) + if err != nil { + log.Fatalf("error getting random ledger: %s", err) + } const count = 100 @@ -49,27 +52,5 @@ func main() { return } - account, err := client.Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ - Address: "world", - Expand: pointer.For("volumes"), - Ledger: ledger, - }) - - if !internal.AssertAlwaysErrNil(err, "we should be able to query account 'world'", nil) { - return - } - - output := account.V2AccountResponse.Data.Volumes["USD/2"].Output - - if !internal.AssertAlways(output != nil, "Expect output of world for USD/2 to be not empty", internal.Details{}) { - return - } - - assert.Always( - output.Cmp(totalAmount) == 0, - "output of 'world' should match", - internal.Details{ - "output": output, - }, - ) + log.Println("composer: parallel_driver_transactions: done") } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go index a81f884d85..a5d97794f7 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go @@ -33,9 +33,12 @@ func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { Ledger: ledger, }) if err != nil { - assert.Always(err == nil, "error getting aggregated balances", internal.Details{ - "error": err, - }) + assert.Always( + err == nil, + fmt.Sprintf("error getting aggregated balances for ledger %s", ledger), + internal.Details{ + "error": err, + }) return } From 4ed1eb52a13377b5000d1f748e1e979a0522a150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 13:35:47 +0200 Subject: [PATCH 16/66] fix: volumes driver --- .../bin/cmds/parallel_driver_volumes/main.go | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go index a5d97794f7..521babd128 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go @@ -3,7 +3,10 @@ package main import ( "context" "fmt" + "log" "math/big" + "os" + "sync" "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/pkg/client" @@ -12,20 +15,25 @@ import ( ) func main() { + log.Println("composer: parallel_driver_volumes") ctx := context.Background() client := internal.NewClient() ledgers, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{}) if err != nil { - assert.Always(err == nil, "error listing ledgers", internal.Details{ - "error": err, - }) - return + log.Printf("error listing ledgers: %s", err) + os.Exit(1) } + wg := sync.WaitGroup{} for _, ledger := range ledgers.V2LedgerListResponse.Cursor.Data { - go checkVolumes(ctx, client, ledger.Name) + wg.Add(1) + go func(ledger string) { + defer wg.Done() + checkVolumes(ctx, client, ledger) + }(ledger.Name) } + wg.Wait() } func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { @@ -51,4 +59,6 @@ func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { "error": err, }) } + + log.Printf("composer: parallel_driver_volumes: done for ledger %s", ledger) } From 8aaa393e9ea4820f467e7dc141d418172abcc469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 13:41:42 +0200 Subject: [PATCH 17/66] fix: don't overuse assertions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../workload/bin/cmds/first_default_ledger/main.go | 6 +----- .../workload/bin/cmds/parallel_driver_volumes/main.go | 8 +------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go index 96e2046daa..088cbaa41a 100644 --- a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go +++ b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -21,10 +20,7 @@ func main() { ledger, ) if err != nil { - assert.Always(err == nil, "ledger should have been created properly", internal.Details{ - "error": err, - }) - return + log.Fatalf("error creating ledger %s: %s", ledger, err) } log.Println("composer: first_default_ledger: done") diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go index 521babd128..34e1d39593 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go @@ -41,13 +41,7 @@ func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { Ledger: ledger, }) if err != nil { - assert.Always( - err == nil, - fmt.Sprintf("error getting aggregated balances for ledger %s", ledger), - internal.Details{ - "error": err, - }) - return + log.Fatalf("error getting aggregated balances for ledger %s: %s", ledger, err) } for asset, volumes := range aggregated.V2AggregateBalancesResponse.Data { From 3ec2e4c7b0e48219be0ec0082a3918b578be60bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 15:12:00 +0200 Subject: [PATCH 18/66] fix: ledger id --- .../workload/bin/cmds/parallel_driver_ledger_create/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index c882a8ba42..43b122d6c1 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -4,7 +4,7 @@ import ( "context" "fmt" "log" - "math/big" + "math/rand" "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/test/antithesis/internal" @@ -14,7 +14,7 @@ func main() { log.Println("composer: parallel_driver_ledger_create") ctx := context.Background() client := internal.NewClient() - id := big.NewInt(0).Abs(internal.RandomBigInt()).Int64() + id := rand.Intn(1e6) ledger := fmt.Sprintf("ledger-%d", id) err := internal.CreateLedger( From 9f22e06536e8d246ed615c61e1b8714b700d5e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 15:14:01 +0200 Subject: [PATCH 19/66] fix: bucket/ledger --- .../workload/bin/cmds/first_default_ledger/main.go | 1 + .../bin/cmds/parallel_driver_ledger_create/main.go | 1 + test/antithesis/workload/internal/utils.go | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go index 088cbaa41a..206b5f0580 100644 --- a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go +++ b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go @@ -18,6 +18,7 @@ func main() { ctx, client, ledger, + ledger, ) if err != nil { log.Fatalf("error creating ledger %s: %s", ledger, err) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index 43b122d6c1..e16b180849 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -21,6 +21,7 @@ func main() { ctx, client, ledger, + ledger, ) if err != nil { assert.Always(err == nil, "ledger should have been created properly", internal.Details{ diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index b502436ac9..67528b8348 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -49,16 +49,19 @@ func NewClient() *client.Formance { Backoff: &retry.BackoffStrategy{ InitialInterval: 200, Exponent: 1.5, - MaxElapsedTime: 4000, + MaxElapsedTime: 10_000, }, RetryConnectionErrors: true, }), ) } -func CreateLedger(ctx context.Context, client *client.Formance, name string) error { +func CreateLedger(ctx context.Context, client *client.Formance, name string, bucket string) error { _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: name, + V2CreateLedgerRequest: components.V2CreateLedgerRequest{ + Bucket: &bucket, + }, }) return err From e8b6e8231b5677b677be7ca17a9b9c45fd5f7271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 16:54:18 +0200 Subject: [PATCH 20/66] fix: remove exhaustive assertion on tx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../bin/cmds/parallel_driver_transactions/main.go | 11 ++++------- .../workload/bin/cmds/parallel_driver_volumes/main.go | 1 + 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 2e582189fa..e6d20ba799 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -24,7 +24,7 @@ func main() { const count = 100 - hasError := atomic.NewBool(false) + hasSuccess := atomic.NewBool(false) totalAmount := big.NewInt(0) pool := pond.New(10, 10e3) @@ -33,24 +33,21 @@ func main() { amount := internal.RandomBigInt() totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { - if !internal.AssertAlwaysErrNil( + if internal.AssertAlwaysErrNil( internal.RunTx(ctx, client, amount, ledger), "creating transaction from @world to $account always return a nil error", internal.Details{ "ledger": ledger, }, ) { - hasError.CompareAndSwap(false, true) + hasSuccess.CompareAndSwap(false, true) } }) } pool.StopAndWait() - cond := !hasError.Load() - if assert.Always(cond, "all transactions should have been written", internal.Details{}); !cond { - return - } + assert.Always(hasSuccess.Load(), "at least some transactions were written", internal.Details{}) log.Println("composer: parallel_driver_transactions: done") } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go index 34e1d39593..43792b9b39 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go @@ -20,6 +20,7 @@ func main() { client := internal.NewClient() ledgers, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{}) + if err != nil { log.Printf("error listing ledgers: %s", err) os.Exit(1) From 9fc1cf7efa0915f323b2e679990c1007996bb690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 17:23:11 +0200 Subject: [PATCH 21/66] fix: switch to sometimes assertions for tx commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../cmds/parallel_driver_transactions/main.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index e6d20ba799..4bffdc2e3e 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -8,7 +8,6 @@ import ( "github.com/alitto/pond" "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/test/antithesis/internal" - "go.uber.org/atomic" ) func main() { @@ -24,7 +23,6 @@ func main() { const count = 100 - hasSuccess := atomic.NewBool(false) totalAmount := big.NewInt(0) pool := pond.New(10, 10e3) @@ -33,21 +31,14 @@ func main() { amount := internal.RandomBigInt() totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { - if internal.AssertAlwaysErrNil( - internal.RunTx(ctx, client, amount, ledger), - "creating transaction from @world to $account always return a nil error", - internal.Details{ - "ledger": ledger, - }, - ) { - hasSuccess.CompareAndSwap(false, true) - } + err := internal.RunTx(ctx, client, amount, ledger) + assert.Sometimes(err == nil, "transaction was committed successfully", internal.Details{ + "ledger": ledger, + }) }) } pool.StopAndWait() - assert.Always(hasSuccess.Load(), "at least some transactions were written", internal.Details{}) - log.Println("composer: parallel_driver_transactions: done") } From e52be33421a0fc66047a9058dae7d03fd954546b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 17:27:03 +0200 Subject: [PATCH 22/66] feat: switch ledger creation to sometimes assertions as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../bin/cmds/parallel_driver_ledger_create/main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index e16b180849..797bd357ba 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -23,12 +23,9 @@ func main() { ledger, ledger, ) - if err != nil { - assert.Always(err == nil, "ledger should have been created properly", internal.Details{ - "error": err, - }) - return - } + assert.Sometimes(err == nil, "ledger should have been created properly", internal.Details{ + "error": err, + }) log.Println("composer: parallel_driver_ledger_create: done") } From 40c1a3984696da973266ad33befe4edac9da8cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 May 2025 19:32:53 +0200 Subject: [PATCH 23/66] fix: move correctness check to eventually MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../{parallel_driver_volumes => eventually_correct}/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename test/antithesis/workload/bin/cmds/{parallel_driver_volumes => eventually_correct}/main.go (91%) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go similarity index 91% rename from test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go rename to test/antithesis/workload/bin/cmds/eventually_correct/main.go index 43792b9b39..2bcbf6cce0 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_volumes/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -15,7 +15,7 @@ import ( ) func main() { - log.Println("composer: parallel_driver_volumes") + log.Println("composer: eventually_correct") ctx := context.Background() client := internal.NewClient() @@ -55,5 +55,5 @@ func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { }) } - log.Printf("composer: parallel_driver_volumes: done for ledger %s", ledger) + log.Printf("composer: eventually_correct: done for ledger %s", ledger) } From c8ab708ac79b892bc52076c2a6ffd8c46e0e0ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Tue, 6 May 2025 10:03:26 +0200 Subject: [PATCH 24/66] feat: improve error handling on eventually MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../bin/cmds/eventually_correct/main.go | 17 ++++++++++++++++- test/antithesis/workload/internal/utils.go | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 2bcbf6cce0..7a5ce3e022 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -10,6 +10,7 @@ import ( "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/pkg/client" + "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -42,7 +43,17 @@ func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { Ledger: ledger, }) if err != nil { - log.Fatalf("error getting aggregated balances for ledger %s: %s", ledger, err) + if internal.IsServerError(aggregated.GetHTTPMeta()) { + assert.Always( + false, + fmt.Sprintf("error getting aggregated balances for ledger %s: %s", ledger, err), + internal.Details{ + "error": err, + }, + ) + } else { + log.Fatalf("error getting aggregated balances for ledger %s: %s", ledger, err) + } } for asset, volumes := range aggregated.V2AggregateBalancesResponse.Data { @@ -57,3 +68,7 @@ func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { log.Printf("composer: eventually_correct: done for ledger %s", ledger) } + +func IsServerError(httpMeta components.HTTPMetadata) bool { + return httpMeta.Response.StatusCode >= 400 && httpMeta.Response.StatusCode < 600 +} diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 67528b8348..ab116b907a 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -56,6 +56,10 @@ func NewClient() *client.Formance { ) } +func IsServerError(httpMeta components.HTTPMetadata) bool { + return httpMeta.Response.StatusCode >= 400 && httpMeta.Response.StatusCode < 600 +} + func CreateLedger(ctx context.Context, client *client.Formance, name string, bucket string) error { _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: name, From 979b33a61f8c6839ffecf9bd216a10cfc329735f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Tue, 6 May 2025 17:07:33 +0200 Subject: [PATCH 25/66] fix: improve error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../bin/cmds/parallel_driver_transactions/main.go | 9 +++++++-- test/antithesis/workload/internal/utils.go | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 4bffdc2e3e..7bc15c22ed 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -18,7 +18,8 @@ func main() { ledger, err := internal.GetRandomLedger(ctx, client) if err != nil { - log.Fatalf("error getting random ledger: %s", err) + ledger = "default" + log.Printf("error getting random ledger: %s", err) } const count = 100 @@ -31,10 +32,14 @@ func main() { amount := internal.RandomBigInt() totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { - err := internal.RunTx(ctx, client, amount, ledger) + res, err := internal.RunTx(ctx, client, amount, ledger) assert.Sometimes(err == nil, "transaction was committed successfully", internal.Details{ "ledger": ledger, }) + assert.Always(!internal.IsServerError(res.GetHTTPMeta()), "no internal server error when committing transaction", internal.Details{ + "ledger": ledger, + "error": err, + }) }) } diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index ab116b907a..f51be7bdd8 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -102,11 +102,11 @@ func GetRandomLedger(ctx context.Context, client *client.Formance) (string, erro return ledgers[randomIndex], nil } -func RunTx(ctx context.Context, client *client.Formance, amount *big.Int, ledger string) error { +func RunTx(ctx context.Context, client *client.Formance, amount *big.Int, ledger string) (*operations.V2CreateTransactionResponse, error) { orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) dest := fmt.Sprintf("orders:%s", orderID) - _, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ + res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ V2PostTransaction: components.V2PostTransaction{ Postings: []components.V2Posting{{ Amount: amount, @@ -117,5 +117,6 @@ func RunTx(ctx context.Context, client *client.Formance, amount *big.Int, ledger }, Ledger: ledger, }) - return err + + return res, err } From 49b0414f433833866c7aa60126cc8b14a98b1a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Wed, 7 May 2025 15:03:23 +0200 Subject: [PATCH 26/66] wip: improve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- .../bin/cmds/anytime_version_upgrade/main.go | 8 ++++ .../bin/cmds/first_default_ledger/main.go | 3 +- .../parallel_driver_ledger_create/main.go | 11 ++++- .../cmds/parallel_driver_transactions/main.go | 46 ++++++++++++++++++- test/antithesis/workload/datagen/example.json | 3 ++ test/antithesis/workload/datagen/main.go | 17 +++++++ test/antithesis/workload/internal/utils.go | 28 ++--------- 7 files changed, 88 insertions(+), 28 deletions(-) create mode 100644 test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go create mode 100644 test/antithesis/workload/datagen/example.json create mode 100644 test/antithesis/workload/datagen/main.go diff --git a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go new file mode 100644 index 0000000000..93ed37a6f2 --- /dev/null +++ b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go @@ -0,0 +1,8 @@ +package main + +import "log" + +func main() { + // TODO: implement + log.Println("placeholder command for anytime_version_upgrade") +} diff --git a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go index 206b5f0580..b609ed331d 100644 --- a/test/antithesis/workload/bin/cmds/first_default_ledger/main.go +++ b/test/antithesis/workload/bin/cmds/first_default_ledger/main.go @@ -14,12 +14,13 @@ func main() { client := internal.NewClient() ledger := "default" - err := internal.CreateLedger( + _, err := internal.CreateLedger( ctx, client, ledger, ledger, ) + if err != nil { log.Fatalf("error creating ledger %s: %s", ledger, err) } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index 797bd357ba..4a3c649361 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -17,15 +17,24 @@ func main() { id := rand.Intn(1e6) ledger := fmt.Sprintf("ledger-%d", id) - err := internal.CreateLedger( + res, err := internal.CreateLedger( ctx, client, ledger, ledger, ) + assert.Sometimes(err == nil, "ledger should have been created properly", internal.Details{ "error": err, }) + assert.Always( + !internal.IsServerError(res.GetHTTPMeta()), + "no internal server error when creating ledger", + internal.Details{ + "error": err, + }, + ) + log.Println("composer: parallel_driver_ledger_create: done") } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 7bc15c22ed..882948a37a 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -7,6 +7,9 @@ import ( "github.com/alitto/pond" "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/formancehq/ledger/pkg/client" + "github.com/formancehq/ledger/pkg/client/models/components" + "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -32,7 +35,7 @@ func main() { amount := internal.RandomBigInt() totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { - res, err := internal.RunTx(ctx, client, amount, ledger) + res, err := RunTx(ctx, client, Transaction(), ledger) assert.Sometimes(err == nil, "transaction was committed successfully", internal.Details{ "ledger": ledger, }) @@ -47,3 +50,44 @@ func main() { log.Println("composer: parallel_driver_transactions: done") } + +type Postings []components.V2Posting + +func RunTx( + ctx context.Context, + client *client.Formance, + postings Postings, + ledger string, +) (*operations.V2CreateTransactionResponse, error) { + res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ + Ledger: ledger, + V2PostTransaction: components.V2PostTransaction{ + Postings: postings, + }, + }) + + return res, err +} + +func Transaction() []components.V2Posting { + postings := []components.V2Posting{} + + postings = append(postings, components.V2Posting{ + Amount: big.NewInt(100), + Asset: "USD/2", + Destination: "orders:1234", + Source: "world", + }) + + return postings +} + +func Sequence() []Postings { + postings := []Postings{} + + for i := 0; i < 10; i++ { + postings = append(postings, Transaction()) + } + + return postings +} diff --git a/test/antithesis/workload/datagen/example.json b/test/antithesis/workload/datagen/example.json new file mode 100644 index 0000000000..ec2649bb49 --- /dev/null +++ b/test/antithesis/workload/datagen/example.json @@ -0,0 +1,3 @@ +[ + {} +] \ No newline at end of file diff --git a/test/antithesis/workload/datagen/main.go b/test/antithesis/workload/datagen/main.go new file mode 100644 index 0000000000..a25249ac83 --- /dev/null +++ b/test/antithesis/workload/datagen/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "math/rand" +) + +type Sequence struct { +} + +func Account() string { + return fmt.Sprintf("%d", rand.Intn(10e9)) +} + +func main() { + fmt.Println(Account()) +} diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index f51be7bdd8..4bb87f8890 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -3,7 +3,6 @@ package internal import ( "context" "fmt" - "math" "math/big" "math/rand" "net/http" @@ -60,15 +59,15 @@ func IsServerError(httpMeta components.HTTPMetadata) bool { return httpMeta.Response.StatusCode >= 400 && httpMeta.Response.StatusCode < 600 } -func CreateLedger(ctx context.Context, client *client.Formance, name string, bucket string) error { - _, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ +func CreateLedger(ctx context.Context, client *client.Formance, name string, bucket string) (*operations.V2CreateLedgerResponse, error) { + res, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: name, V2CreateLedgerRequest: components.V2CreateLedgerRequest{ Bucket: &bucket, }, }) - return err + return res, err } func ListLedgers(ctx context.Context, client *client.Formance) ([]string, error) { @@ -95,28 +94,7 @@ func GetRandomLedger(ctx context.Context, client *client.Formance) (string, erro return "", fmt.Errorf("no ledgers found") } - // Get a random index within the ledgers slice randomIndex := rand.Intn(len(ledgers)) - // Return the ledger at the random index return ledgers[randomIndex], nil } - -func RunTx(ctx context.Context, client *client.Formance, amount *big.Int, ledger string) (*operations.V2CreateTransactionResponse, error) { - orderID := fmt.Sprint(int64(math.Abs(float64(random.GetRandom())))) - dest := fmt.Sprintf("orders:%s", orderID) - - res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ - V2PostTransaction: components.V2PostTransaction{ - Postings: []components.V2Posting{{ - Amount: amount, - Asset: "USD/2", - Destination: dest, - Source: "world", - }}, - }, - Ledger: ledger, - }) - - return res, err -} From 9248bd8c00b27e0649da8964753c7e8c3d3f69fa Mon Sep 17 00:00:00 2001 From: Maxence Maireaux Date: Thu, 19 Jun 2025 14:22:02 +0200 Subject: [PATCH 27/66] feat: add Kubernetes pod configuration for workload --- test/antithesis/config/kube.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/antithesis/config/kube.yaml diff --git a/test/antithesis/config/kube.yaml b/test/antithesis/config/kube.yaml new file mode 100644 index 0000000000..e6b6497229 --- /dev/null +++ b/test/antithesis/config/kube.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: workload + namespace: formance-dev + labels: + app: workload +spec: + containers: + - name: workload + image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/workload:latest + imagePullPolicy: Always \ No newline at end of file From 424b4c1b0fc41562a7304d9b9085df835e5d84df Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 13 Aug 2025 14:53:25 +0200 Subject: [PATCH 28/66] k8s test setup --- test/antithesis/Earthfile | 48 +++++++-------- test/antithesis/config/Earthfile | 7 ++- test/antithesis/config/docker-compose.yml | 2 +- test/antithesis/config/gateway/Caddyfile | 12 ---- test/antithesis/config/kube.yaml | 12 ---- test/antithesis/config/manifests/gateway.yaml | 58 +++++++++++++++++++ test/antithesis/config/manifests/ledger1.yaml | 38 ++++++++++++ test/antithesis/config/manifests/ledger2.yaml | 38 ++++++++++++ .../config/manifests/namespace.yaml | 4 ++ .../antithesis/config/manifests/postgres.yaml | 42 ++++++++++++++ .../antithesis/config/manifests/workload.yaml | 14 +++++ test/antithesis/image/Earthfile | 2 +- test/antithesis/image/entrypoint.sh | 2 +- test/antithesis/workload/Earthfile | 2 +- 14 files changed, 226 insertions(+), 55 deletions(-) delete mode 100644 test/antithesis/config/gateway/Caddyfile delete mode 100644 test/antithesis/config/kube.yaml create mode 100644 test/antithesis/config/manifests/gateway.yaml create mode 100644 test/antithesis/config/manifests/ledger1.yaml create mode 100644 test/antithesis/config/manifests/ledger2.yaml create mode 100644 test/antithesis/config/manifests/namespace.yaml create mode 100644 test/antithesis/config/manifests/postgres.yaml create mode 100644 test/antithesis/config/manifests/workload.yaml diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile index 0052105553..3d7572418e 100644 --- a/test/antithesis/Earthfile +++ b/test/antithesis/Earthfile @@ -19,8 +19,8 @@ run: \"params\": { \"custom.duration\": \"0.1\", \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", - \"antithesis.config_image\": \"antithesis-config:latest\", - \"antithesis.images\": \"ledger:latest;workload:latest\" + \"antithesis.config_image\": \"antithesis-config:k8s_test\", + \"antithesis.images\": \"ledger:k8s_test;workload:latest;ghcr.io/formancehq/gateway:v2.0.0-rc.20;docker.io/library/postgres:15-alpine\" } }" @@ -40,39 +40,39 @@ run-1h: \"custom.duration\": \"1\", \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", \"antithesis.config_image\": \"antithesis-config:latest\", - \"antithesis.images\": \"ledger:latest;workload:latest\" + \"antithesis.images\": \"ledger:k8s_test;workload:latest\" } }" debugger: - FROM curlimages/curl + FROM curlimages/curl - ARG ANTITHESIS_USERNAME=formance - ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT - ARG --required VTIME - ARG --required SESSION_ID - ARG --required HASH - RUN echo "{ - \"params\": { + ARG ANTITHESIS_USERNAME=formance + ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT + ARG --required VTIME + ARG --required SESSION_ID + ARG --required HASH + RUN echo "{ + \"params\": { \"antithesis.debugging.session_id\": \"${SESSION_ID}\", \"antithesis.debugging.input_hash\": \"${HASH}\", \"antithesis.debugging.vtime\": \"${VTIME}\", \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\" - } - }" > /tmp/debug_params.json + } + }" > /tmp/debug_params.json - # Display the debug parameters for verification - RUN cat /tmp/debug_params.json + # Display the debug parameters for verification + RUN cat /tmp/debug_params.json - RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ - --fail \ - --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ - -X POST https://formance.antithesis.com/api/v1/launch/debugging \ - -d @/tmp/debug_params.json + RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ + --fail \ + --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ + -X POST https://formance.antithesis.com/api/v1/launch/debugging \ + -d @/tmp/debug_params.json requirements-build: - ARG --required ANTITHESIS_REPOSITORY + ARG --required ANTITHESIS_REPOSITORY - BUILD --pass-args ./config+build - BUILD --pass-args ./image+build - BUILD --pass-args ./workload+build \ No newline at end of file + BUILD --pass-args ./config+build + BUILD --pass-args ./image+build + BUILD --pass-args ./workload+build diff --git a/test/antithesis/config/Earthfile b/test/antithesis/config/Earthfile index 201f9c5094..3e2565a588 100644 --- a/test/antithesis/config/Earthfile +++ b/test/antithesis/config/Earthfile @@ -5,7 +5,8 @@ IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core build: FROM --platform=linux/amd64 scratch ARG --required ANTITHESIS_REPOSITORY - COPY docker-compose.yml /docker-compose.yml - COPY --dir gateway /gateway + # COPY docker-compose.yml /docker-compose.yml + # COPY --dir gateway /gateway + COPY --dir manifests /manifests - SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/antithesis-config:latest \ No newline at end of file + SAVE IMAGE --push ${ANTITHESIS_REPOSITORY}/antithesis-config:k8s_test diff --git a/test/antithesis/config/docker-compose.yml b/test/antithesis/config/docker-compose.yml index 8de28914a9..b2bcfde187 100644 --- a/test/antithesis/config/docker-compose.yml +++ b/test/antithesis/config/docker-compose.yml @@ -85,4 +85,4 @@ services: ipv4_address: 10.0.29.20 depends_on: - ledger1 - - ledger2 \ No newline at end of file + - ledger2 diff --git a/test/antithesis/config/gateway/Caddyfile b/test/antithesis/config/gateway/Caddyfile deleted file mode 100644 index 95dd650008..0000000000 --- a/test/antithesis/config/gateway/Caddyfile +++ /dev/null @@ -1,12 +0,0 @@ -{ - # Local env dev config - auto_https off - debug -} - -:8080 { - reverse_proxy { - to ledger1:8080 ledger2:8080 - lb_policy first - } -} diff --git a/test/antithesis/config/kube.yaml b/test/antithesis/config/kube.yaml deleted file mode 100644 index e6b6497229..0000000000 --- a/test/antithesis/config/kube.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: workload - namespace: formance-dev - labels: - app: workload -spec: - containers: - - name: workload - image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/workload:latest - imagePullPolicy: Always \ No newline at end of file diff --git a/test/antithesis/config/manifests/gateway.yaml b/test/antithesis/config/manifests/gateway.yaml new file mode 100644 index 0000000000..8e339f48e1 --- /dev/null +++ b/test/antithesis/config/manifests/gateway.yaml @@ -0,0 +1,58 @@ +apiVersion: v1 +kind: Service +metadata: + name: gateway + namespace: formance-dev +spec: + selector: + app: gateway + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: gateway-config + namespace: formance-dev +data: + Caddyfile: | + { + # Local env dev config + auto_https off + debug + } + + :8080 { + reverse_proxy { + to ledger1:8080 ledger2:8080 + lb_policy first + } + } +--- +apiVersion: v1 +kind: Pod +metadata: + name: gateway + namespace: formance-dev + labels: + app: gateway + +spec: + volumes: + - name: caddyfile + configMap: + name: gateway-config + + containers: + - name: gateway + image: ghcr.io/formancehq/gateway:v2.0.0-rc.20 + imagePullPolicy: IfNotPresent + volumeMounts: + - mountPath: /etc/caddy/Caddyfile + name: caddyfile + subPath: Caddyfile + ports: + - containerPort: 8080 + hostPort: 8080 diff --git a/test/antithesis/config/manifests/ledger1.yaml b/test/antithesis/config/manifests/ledger1.yaml new file mode 100644 index 0000000000..e8b8736325 --- /dev/null +++ b/test/antithesis/config/manifests/ledger1.yaml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: Service +metadata: + name: ledger1 + namespace: formance-dev +spec: + selector: + app: ledger1 + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 +--- +apiVersion: v1 +kind: Pod +metadata: + name: ledger1 + namespace: formance-dev + labels: + app: ledger1 +spec: + containers: + - name: ledger + image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:k8s_test + imagePullPolicy: IfNotPresent + env: + - name: "POSTGRES_URI" + value: "postgresql://ledger:ledger@postgres:5432/ledger?sslmode=disable" + - name: "BIND" + value: ":8080" + - name: "POSTGRES_CONN_MAX_IDLE_TIME" + value: "1m0s" + - name: "POSTGRES_MAX_IDLE_CONNS" + value: "20" + - name: "POSTGRES_MAX_OPEN_CONNS" + value: "20" + # imagePullSecrets: + # - name: antithesis diff --git a/test/antithesis/config/manifests/ledger2.yaml b/test/antithesis/config/manifests/ledger2.yaml new file mode 100644 index 0000000000..4bcb5acad5 --- /dev/null +++ b/test/antithesis/config/manifests/ledger2.yaml @@ -0,0 +1,38 @@ +apiVersion: v1 +kind: Service +metadata: + name: ledger2 + namespace: formance-dev +spec: + selector: + app: ledger2 + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 +--- +apiVersion: v1 +kind: Pod +metadata: + name: ledger2 + namespace: formance-dev + labels: + app: ledger2 +spec: + containers: + - name: ledger + image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:k8s_test + imagePullPolicy: IfNotPresent + env: + - name: "POSTGRES_URI" + value: "postgresql://ledger:ledger@postgres:5432/ledger?sslmode=disable" + - name: "BIND" + value: ":8080" + - name: "POSTGRES_CONN_MAX_IDLE_TIME" + value: "1m0s" + - name: "POSTGRES_MAX_IDLE_CONNS" + value: "20" + - name: "POSTGRES_MAX_OPEN_CONNS" + value: "20" + # imagePullSecrets: + # - name: antithesis diff --git a/test/antithesis/config/manifests/namespace.yaml b/test/antithesis/config/manifests/namespace.yaml new file mode 100644 index 0000000000..9dd9631676 --- /dev/null +++ b/test/antithesis/config/manifests/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: formance-dev diff --git a/test/antithesis/config/manifests/postgres.yaml b/test/antithesis/config/manifests/postgres.yaml new file mode 100644 index 0000000000..05da9359e4 --- /dev/null +++ b/test/antithesis/config/manifests/postgres.yaml @@ -0,0 +1,42 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgres + namespace: formance-dev +spec: + selector: + app: postgres + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 +--- +apiVersion: v1 +kind: Pod +metadata: + name: postgres + namespace: formance-dev + labels: + app: postgres +spec: + containers: + - name: postgres + image: postgres:15-alpine + imagePullPolicy: IfNotPresent + args: ["-c", "max_connections=100"] + env: + - name: "POSTGRES_USER" + value: "ledger" + - name: "POSTGRES_PASSWORD" + value: "ledger" + - name: "POSTGRES_DB" + value: "ledger" + - name: "PGDATA" + value: /data/postgres + livenessProbe: + exec: + command: ["pg_isready", "-U ledger"] + initialDelaySeconds: 0 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 5 diff --git a/test/antithesis/config/manifests/workload.yaml b/test/antithesis/config/manifests/workload.yaml new file mode 100644 index 0000000000..3a0db42642 --- /dev/null +++ b/test/antithesis/config/manifests/workload.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: workload + namespace: formance-dev + labels: + app: workload +spec: + containers: + - name: workload + image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/workload:latest + imagePullPolicy: IfNotPresent + # imagePullSecrets: + # - name: antithesis diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index 118d292f6b..b5eedfbaa6 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -41,4 +41,4 @@ build: ARG --required ANTITHESIS_REPOSITORY - SAVE IMAGE --push --no-manifest-list "${ANTITHESIS_REPOSITORY}/ledger:latest" \ No newline at end of file + SAVE IMAGE --push --no-manifest-list "${ANTITHESIS_REPOSITORY}/ledger:k8s_test" diff --git a/test/antithesis/image/entrypoint.sh b/test/antithesis/image/entrypoint.sh index 37973d9470..3606c70e05 100644 --- a/test/antithesis/image/entrypoint.sh +++ b/test/antithesis/image/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/sh # make sure pg is ready to accept connections -until pg_isready -d ledger -h 10.0.29.16 -U ledger +until pg_isready -d ledger -h postgres -U ledger do echo "Waiting for postgres at: $POSTGRES_URI" sleep 2; diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile index 4dfef2d51b..9ec3b553c9 100644 --- a/test/antithesis/workload/Earthfile +++ b/test/antithesis/workload/Earthfile @@ -43,4 +43,4 @@ build: ARG --required ANTITHESIS_REPOSITORY - SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest \ No newline at end of file + SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest From c5dac59a2b7f3ba25052b473ebfe9a4fe8009ee3 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Mon, 18 Aug 2025 13:49:52 +0200 Subject: [PATCH 29/66] test fixes & remove docker-compose antithesis setup --- test/antithesis/Earthfile | 10 +-- test/antithesis/config/docker-compose.yml | 88 ------------------- test/antithesis/config/manifests/ledger1.yaml | 2 - test/antithesis/config/manifests/ledger2.yaml | 2 - .../antithesis/config/manifests/postgres.yaml | 2 +- .../antithesis/config/manifests/workload.yaml | 2 - test/antithesis/image/Earthfile | 4 +- .../parallel_driver_ledger_create/main.go | 16 ++-- .../cmds/parallel_driver_transactions/main.go | 1 + test/antithesis/workload/internal/utils.go | 7 +- 10 files changed, 24 insertions(+), 110 deletions(-) delete mode 100644 test/antithesis/config/docker-compose.yml diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile index 3d7572418e..3789e209c6 100644 --- a/test/antithesis/Earthfile +++ b/test/antithesis/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core +IMPORT github.com/formancehq/earthly:tags/v0.19.1 AS core FROM core+base-image @@ -15,7 +15,7 @@ run: RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ --fail \ --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ - -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance -d "{ + -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d "{ \"params\": { \"custom.duration\": \"0.1\", \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", @@ -35,12 +35,12 @@ run-1h: RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ --fail \ --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ - -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance -d "{ + -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d "{ \"params\": { \"custom.duration\": \"1\", \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", - \"antithesis.config_image\": \"antithesis-config:latest\", - \"antithesis.images\": \"ledger:k8s_test;workload:latest\" + \"antithesis.config_image\": \"antithesis-config:k8s_test\", + \"antithesis.images\": \"ledger:k8s_test;workload:latest;ghcr.io/formancehq/gateway:v2.0.0-rc.20;docker.io/library/postgres:15-alpine\" } }" diff --git a/test/antithesis/config/docker-compose.yml b/test/antithesis/config/docker-compose.yml deleted file mode 100644 index b2bcfde187..0000000000 --- a/test/antithesis/config/docker-compose.yml +++ /dev/null @@ -1,88 +0,0 @@ ---- -networks: - formance: - driver: bridge - ipam: - config: - - subnet: 10.0.29.0/24 - -services: - postgres: - image: "postgres:15-alpine" - hostname: postgres - container_name: postgres - command: - - -c - - max_connections=100 - environment: - POSTGRES_USER: "ledger" - POSTGRES_PASSWORD: "ledger" - POSTGRES_DB: "ledger" - PGDATA: /data/postgres - healthcheck: - test: [ "CMD-SHELL", "pg_isready -U ledger" ] - interval: 10s - timeout: 5s - retries: 5 - networks: - formance: - ipv4_address: 10.0.29.16 - - ledger1: - image: "us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:latest" - hostname: ledger1 - container_name: ledger1 - environment: - POSTGRES_URI: "postgresql://ledger:ledger@10.0.29.16:5432/ledger?sslmode=disable" - BIND: ":8080" - POSTGRES_CONN_MAX_IDLE_TIME: "1m0s" - POSTGRES_MAX_IDLE_CONNS: "20" - POSTGRES_MAX_OPEN_CONNS: "20" - networks: - formance: - ipv4_address: 10.0.29.17 - depends_on: - postgres: - condition: service_healthy - - ledger2: - image: "us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:latest" - hostname: ledger2 - container_name: ledger2 - environment: - POSTGRES_URI: "postgresql://ledger:ledger@10.0.29.16:5432/ledger?sslmode=disable" - POSTGRES_CONN_MAX_IDLE_TIME: "1m0s" - POSTGRES_MAX_IDLE_CONNS: "20" - POSTGRES_MAX_OPEN_CONNS: "20" - BIND: ":8080" - networks: - formance: - ipv4_address: 10.0.29.18 - depends_on: - postgres: - condition: service_healthy - - workload: - image: "us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/workload:latest" - hostname: workload - container_name: workload - networks: - formance: - ipv4_address: 10.0.29.19 - depends_on: - - gateway - - gateway: - image: "ghcr.io/formancehq/gateway:v2.0.0-rc.20" - hostname: gateway - container_name: gateway - volumes: - - ./gateway/Caddyfile:/etc/caddy/Caddyfile - ports: - - "8080:8080" - networks: - formance: - ipv4_address: 10.0.29.20 - depends_on: - - ledger1 - - ledger2 diff --git a/test/antithesis/config/manifests/ledger1.yaml b/test/antithesis/config/manifests/ledger1.yaml index e8b8736325..99f4c7e7db 100644 --- a/test/antithesis/config/manifests/ledger1.yaml +++ b/test/antithesis/config/manifests/ledger1.yaml @@ -34,5 +34,3 @@ spec: value: "20" - name: "POSTGRES_MAX_OPEN_CONNS" value: "20" - # imagePullSecrets: - # - name: antithesis diff --git a/test/antithesis/config/manifests/ledger2.yaml b/test/antithesis/config/manifests/ledger2.yaml index 4bcb5acad5..fb634b2623 100644 --- a/test/antithesis/config/manifests/ledger2.yaml +++ b/test/antithesis/config/manifests/ledger2.yaml @@ -34,5 +34,3 @@ spec: value: "20" - name: "POSTGRES_MAX_OPEN_CONNS" value: "20" - # imagePullSecrets: - # - name: antithesis diff --git a/test/antithesis/config/manifests/postgres.yaml b/test/antithesis/config/manifests/postgres.yaml index 05da9359e4..4044d2eef1 100644 --- a/test/antithesis/config/manifests/postgres.yaml +++ b/test/antithesis/config/manifests/postgres.yaml @@ -35,7 +35,7 @@ spec: value: /data/postgres livenessProbe: exec: - command: ["pg_isready", "-U ledger"] + command: ["pg_isready", "-Uledger"] initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 5 diff --git a/test/antithesis/config/manifests/workload.yaml b/test/antithesis/config/manifests/workload.yaml index 3a0db42642..acd6f63c16 100644 --- a/test/antithesis/config/manifests/workload.yaml +++ b/test/antithesis/config/manifests/workload.yaml @@ -10,5 +10,3 @@ spec: - name: workload image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/workload:latest imagePullPolicy: IfNotPresent - # imagePullSecrets: - # - name: antithesis diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index b5eedfbaa6..6803f4ce50 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core +IMPORT github.com/formancehq/earthly:tags/v0.19.1 AS core FROM core+base-image @@ -8,7 +8,7 @@ CACHE --sharing=shared --id go-mod-cache /go/pkg/mod CACHE --sharing=shared --id go-cache /root/.cache/go-build compile: - FROM --platform=linux/amd64 golang:1.23 + FROM --platform=linux/amd64 golang:1.24.6 CACHE --sharing=shared --id go-mod-cache /go/pkg/mod CACHE --sharing=shared --id go-cache /root/.cache/go-build diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index 4a3c649361..8dfc738394 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -28,13 +28,15 @@ func main() { "error": err, }) - assert.Always( - !internal.IsServerError(res.GetHTTPMeta()), - "no internal server error when creating ledger", - internal.Details{ - "error": err, - }, - ) + if err == nil { + assert.Always( + !internal.IsServerError(res.GetHTTPMeta()), + "no internal server error when creating ledger", + internal.Details{ + "error": err, + }, + ) + } log.Println("composer: parallel_driver_ledger_create: done") } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 882948a37a..60057f88b4 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -23,6 +23,7 @@ func main() { if err != nil { ledger = "default" log.Printf("error getting random ledger: %s", err) + return } const count = 100 diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 4bb87f8890..8b7c4360b9 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -6,6 +6,7 @@ import ( "math/big" "math/rand" "net/http" + "os" "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/antithesishq/antithesis-sdk-go/random" @@ -38,8 +39,12 @@ func AssertAlwaysErrNil(err error, message string, details map[string]any) bool } func NewClient() *client.Formance { + gateway := os.Getenv("GATEWAY_URL") + if gateway == "" { + gateway = "http://gateway:8080" + } return client.New( - client.WithServerURL("http://gateway:8080"), + client.WithServerURL(gateway), client.WithClient(&http.Client{ Timeout: time.Minute, }), From 7664eb6d233eafac676b984359d12191d14328ff Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 27 Aug 2025 20:35:21 +0200 Subject: [PATCH 30/66] integrate the operator --- test/antithesis/Justfile | 15 +++ test/antithesis/config/.gitignore | 1 + test/antithesis/config/Dockerfile.config | 2 + test/antithesis/config/Earthfile | 12 -- test/antithesis/config/Justfile | 16 +++ test/antithesis/config/manifests/gateway.yaml | 58 -------- test/antithesis/config/manifests/ledger.yaml | 12 ++ test/antithesis/config/manifests/ledger1.yaml | 36 ----- test/antithesis/config/manifests/ledger2.yaml | 36 ----- .../config/manifests/namespace.yaml | 2 +- .../antithesis/config/manifests/postgres.yaml | 4 +- .../antithesis/config/manifests/settings.yaml | 10 ++ test/antithesis/config/manifests/stack.yaml | 30 +++++ .../antithesis/config/manifests/workload.yaml | 2 +- .../bin/cmds/anytime_version_upgrade/main.go | 19 ++- test/antithesis/workload/go.mod | 43 +++++- test/antithesis/workload/go.sum | 125 ++++++++++++++++++ test/antithesis/workload/internal/utils.go | 2 +- 18 files changed, 275 insertions(+), 150 deletions(-) create mode 100644 test/antithesis/Justfile create mode 100644 test/antithesis/config/.gitignore create mode 100644 test/antithesis/config/Dockerfile.config delete mode 100644 test/antithesis/config/Earthfile create mode 100644 test/antithesis/config/Justfile delete mode 100644 test/antithesis/config/manifests/gateway.yaml create mode 100644 test/antithesis/config/manifests/ledger.yaml delete mode 100644 test/antithesis/config/manifests/ledger1.yaml delete mode 100644 test/antithesis/config/manifests/ledger2.yaml create mode 100644 test/antithesis/config/manifests/settings.yaml create mode 100644 test/antithesis/config/manifests/stack.yaml diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile new file mode 100644 index 0000000000..039d712a6b --- /dev/null +++ b/test/antithesis/Justfile @@ -0,0 +1,15 @@ +run-6min: requirements-build + curl --fail \ + --user "formance:$ANTITHESIS_PASSWORD" \ + -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ + "params": { \ + "custom.duration": "0.1", \ + "antithesis.report.recipients": "${ANTITHESIS_SLACK_REPORT_RECIPIENT}", \ + "antithesis.config_image": "antithesis-config:k8s_test", \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1" \ + } \ + }' + +requirements-build: + just config/ + earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" diff --git a/test/antithesis/config/.gitignore b/test/antithesis/config/.gitignore new file mode 100644 index 0000000000..a9a5aecf42 --- /dev/null +++ b/test/antithesis/config/.gitignore @@ -0,0 +1 @@ +tmp diff --git a/test/antithesis/config/Dockerfile.config b/test/antithesis/config/Dockerfile.config new file mode 100644 index 0000000000..dabb4829c6 --- /dev/null +++ b/test/antithesis/config/Dockerfile.config @@ -0,0 +1,2 @@ +FROM scratch +COPY tmp/* /manifests/ diff --git a/test/antithesis/config/Earthfile b/test/antithesis/config/Earthfile deleted file mode 100644 index 3e2565a588..0000000000 --- a/test/antithesis/config/Earthfile +++ /dev/null @@ -1,12 +0,0 @@ -VERSION 0.8 - -IMPORT github.com/formancehq/earthly:tags/v0.17.1 AS core - -build: - FROM --platform=linux/amd64 scratch - ARG --required ANTITHESIS_REPOSITORY - # COPY docker-compose.yml /docker-compose.yml - # COPY --dir gateway /gateway - COPY --dir manifests /manifests - - SAVE IMAGE --push ${ANTITHESIS_REPOSITORY}/antithesis-config:k8s_test diff --git a/test/antithesis/config/Justfile b/test/antithesis/config/Justfile new file mode 100644 index 0000000000..f4291c2378 --- /dev/null +++ b/test/antithesis/config/Justfile @@ -0,0 +1,16 @@ + +build: + rm -f -- tmp/resources.yaml + cat manifests/namespace.yaml >> tmp/resources.yaml + echo "---" >> tmp/resources.yaml + cat manifests/postgres.yaml >> tmp/resources.yaml + echo "---" >> tmp/resources.yaml + helm template regions oci://ghcr.io/formancehq/helm/regions --version 2.15.2 --namespace formance-systems >> tmp/resources.yaml + # helm template operator oci://ghcr.io/formancehq/helm/operator-crds --version v2.8.0 --namespace formance-systems >> tmp/resources.yaml + echo "---" >> tmp/resources.yaml + cat manifests/stack.yaml >> tmp/resources.yaml + echo "---" >> tmp/resources.yaml + cat manifests/workload.yaml >> tmp/resources.yaml + + docker build -f Dockerfile.config -t $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test . + docker push $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test diff --git a/test/antithesis/config/manifests/gateway.yaml b/test/antithesis/config/manifests/gateway.yaml deleted file mode 100644 index 8e339f48e1..0000000000 --- a/test/antithesis/config/manifests/gateway.yaml +++ /dev/null @@ -1,58 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: gateway - namespace: formance-dev -spec: - selector: - app: gateway - ports: - - protocol: TCP - port: 8080 - targetPort: 8080 ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: gateway-config - namespace: formance-dev -data: - Caddyfile: | - { - # Local env dev config - auto_https off - debug - } - - :8080 { - reverse_proxy { - to ledger1:8080 ledger2:8080 - lb_policy first - } - } ---- -apiVersion: v1 -kind: Pod -metadata: - name: gateway - namespace: formance-dev - labels: - app: gateway - -spec: - volumes: - - name: caddyfile - configMap: - name: gateway-config - - containers: - - name: gateway - image: ghcr.io/formancehq/gateway:v2.0.0-rc.20 - imagePullPolicy: IfNotPresent - volumeMounts: - - mountPath: /etc/caddy/Caddyfile - name: caddyfile - subPath: Caddyfile - ports: - - containerPort: 8080 - hostPort: 8080 diff --git a/test/antithesis/config/manifests/ledger.yaml b/test/antithesis/config/manifests/ledger.yaml new file mode 100644 index 0000000000..9e648eeae7 --- /dev/null +++ b/test/antithesis/config/manifests/ledger.yaml @@ -0,0 +1,12 @@ +# apiVersion: v1 +# kind: Service +# metadata: +# name: gateway +# namespace: formance-systems +# spec: +# selector: +# app: gateway +# ports: +# - protocol: TCP +# port: 8080 +# targetPort: 8080 diff --git a/test/antithesis/config/manifests/ledger1.yaml b/test/antithesis/config/manifests/ledger1.yaml deleted file mode 100644 index 99f4c7e7db..0000000000 --- a/test/antithesis/config/manifests/ledger1.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: ledger1 - namespace: formance-dev -spec: - selector: - app: ledger1 - ports: - - protocol: TCP - port: 8080 - targetPort: 8080 ---- -apiVersion: v1 -kind: Pod -metadata: - name: ledger1 - namespace: formance-dev - labels: - app: ledger1 -spec: - containers: - - name: ledger - image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:k8s_test - imagePullPolicy: IfNotPresent - env: - - name: "POSTGRES_URI" - value: "postgresql://ledger:ledger@postgres:5432/ledger?sslmode=disable" - - name: "BIND" - value: ":8080" - - name: "POSTGRES_CONN_MAX_IDLE_TIME" - value: "1m0s" - - name: "POSTGRES_MAX_IDLE_CONNS" - value: "20" - - name: "POSTGRES_MAX_OPEN_CONNS" - value: "20" diff --git a/test/antithesis/config/manifests/ledger2.yaml b/test/antithesis/config/manifests/ledger2.yaml deleted file mode 100644 index fb634b2623..0000000000 --- a/test/antithesis/config/manifests/ledger2.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: ledger2 - namespace: formance-dev -spec: - selector: - app: ledger2 - ports: - - protocol: TCP - port: 8080 - targetPort: 8080 ---- -apiVersion: v1 -kind: Pod -metadata: - name: ledger2 - namespace: formance-dev - labels: - app: ledger2 -spec: - containers: - - name: ledger - image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/ledger:k8s_test - imagePullPolicy: IfNotPresent - env: - - name: "POSTGRES_URI" - value: "postgresql://ledger:ledger@postgres:5432/ledger?sslmode=disable" - - name: "BIND" - value: ":8080" - - name: "POSTGRES_CONN_MAX_IDLE_TIME" - value: "1m0s" - - name: "POSTGRES_MAX_IDLE_CONNS" - value: "20" - - name: "POSTGRES_MAX_OPEN_CONNS" - value: "20" diff --git a/test/antithesis/config/manifests/namespace.yaml b/test/antithesis/config/manifests/namespace.yaml index 9dd9631676..b1395d2981 100644 --- a/test/antithesis/config/manifests/namespace.yaml +++ b/test/antithesis/config/manifests/namespace.yaml @@ -1,4 +1,4 @@ apiVersion: v1 kind: Namespace metadata: - name: formance-dev + name: formance-systems diff --git a/test/antithesis/config/manifests/postgres.yaml b/test/antithesis/config/manifests/postgres.yaml index 4044d2eef1..7c048b38da 100644 --- a/test/antithesis/config/manifests/postgres.yaml +++ b/test/antithesis/config/manifests/postgres.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: name: postgres - namespace: formance-dev + namespace: formance-systems spec: selector: app: postgres @@ -15,7 +15,7 @@ apiVersion: v1 kind: Pod metadata: name: postgres - namespace: formance-dev + namespace: formance-systems labels: app: postgres spec: diff --git a/test/antithesis/config/manifests/settings.yaml b/test/antithesis/config/manifests/settings.yaml new file mode 100644 index 0000000000..445624ede9 --- /dev/null +++ b/test/antithesis/config/manifests/settings.yaml @@ -0,0 +1,10 @@ +apiVersion: formance.com/v1beta1 +kind: Settings +metadata: + name: formance-settings + namespace: formance-systems +spec: + key: postgres.*.uri + stacks: + - "stack0" + value: postgresql://ledger:ledger@postgres.formance-db.svc.cluster.local:5432?sslmode=disable diff --git a/test/antithesis/config/manifests/stack.yaml b/test/antithesis/config/manifests/stack.yaml new file mode 100644 index 0000000000..6b82625097 --- /dev/null +++ b/test/antithesis/config/manifests/stack.yaml @@ -0,0 +1,30 @@ +apiVersion: formance.com/v1beta1 +kind: Settings +metadata: + name: formance-settings +spec: + key: postgres.*.uri + stacks: + - "stack0" + value: postgresql://ledger:ledger@postgres.formance-systems.svc.cluster.local:5432?disableSSLMode=true +--- +apiVersion: formance.com/v1beta1 +kind: Stack +metadata: + name: stack0 +spec: + versionsFromFile: v2.0 +--- +apiVersion: formance.com/v1beta1 +kind: Gateway +metadata: + name: stack0 +spec: + stack: stack0 +--- +apiVersion: formance.com/v1beta1 +kind: Ledger +metadata: + name: stack0 +spec: + stack: stack0 diff --git a/test/antithesis/config/manifests/workload.yaml b/test/antithesis/config/manifests/workload.yaml index acd6f63c16..9a816ec892 100644 --- a/test/antithesis/config/manifests/workload.yaml +++ b/test/antithesis/config/manifests/workload.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Pod metadata: name: workload - namespace: formance-dev + namespace: formance-systems labels: app: workload spec: diff --git a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go index 93ed37a6f2..e33d4daea9 100644 --- a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go +++ b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go @@ -1,8 +1,25 @@ package main -import "log" +import ( + "log" + + // "k8s.io/client-go/kubernetes" + // "k8s.io/client-go/tools/clientcmd" +) func main() { + // var kubeconfig *string + + // config, err := clientcmd.BuildConfigFromFlags() + // if err != nil { + // panic(err) + // } + + // clientset, err := kubernetes.NewForConfig(config) + // if err != nil { + // panic(err) + // } + // TODO: implement log.Println("placeholder command for anytime_version_upgrade") } diff --git a/test/antithesis/workload/go.mod b/test/antithesis/workload/go.mod index 53f78d6112..7a2374b7ed 100644 --- a/test/antithesis/workload/go.mod +++ b/test/antithesis/workload/go.mod @@ -1,6 +1,8 @@ module github.com/formancehq/ledger/test/antithesis -go 1.22.0 +go 1.24.0 + +toolchain go1.24.5 replace github.com/formancehq/ledger/pkg/client => ../../../pkg/client @@ -10,16 +12,53 @@ require ( github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 go.uber.org/atomic v1.10.0 - golang.org/x/sync v0.9.0 // indirect; indirect, for singleflight package + golang.org/x/sync v0.12.0 // indirect; indirect, for singleflight package ) require ( github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.23.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/gnostic-models v0.6.9 // indirect + github.com/google/go-cmp v0.7.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/invopop/jsonschema v0.12.0 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect + github.com/x448/float16 v0.8.4 // indirect + golang.org/x/net v0.38.0 // indirect + golang.org/x/oauth2 v0.27.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/term v0.30.0 // indirect + golang.org/x/text v0.23.0 // indirect + golang.org/x/time v0.9.0 // indirect + google.golang.org/protobuf v1.36.5 // indirect + gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.33.4 // indirect + k8s.io/apimachinery v0.33.4 // indirect + k8s.io/client-go v0.33.4 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect + k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect + sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) diff --git a/test/antithesis/workload/go.sum b/test/antithesis/workload/go.sum index 1c3c2cf9c7..ef82d511bc 100644 --- a/test/antithesis/workload/go.sum +++ b/test/antithesis/workload/go.sum @@ -6,30 +6,155 @@ github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPn github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 h1:l6jieaR+sn4Ff+puBDMbTYmT2HTYC7Yt7GTxBAwC3eU= github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9/go.mod h1:m0uKkey9OC/AeyWMwjMfZqhLzoWrPFBk8vuYdSSYj4Y= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= +github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M= +golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= +golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= +golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/api v0.33.4 h1:oTzrFVNPXBjMu0IlpA2eDDIU49jsuEorGHB4cvKupkk= +k8s.io/api v0.33.4/go.mod h1:VHQZ4cuxQ9sCUMESJV5+Fe8bGnqAARZ08tSTdHWfeAc= +k8s.io/apimachinery v0.33.4 h1:SOf/JW33TP0eppJMkIgQ+L6atlDiP/090oaX0y9pd9s= +k8s.io/apimachinery v0.33.4/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= +k8s.io/client-go v0.33.4 h1:TNH+CSu8EmXfitntjUPwaKVPN0AYMbc9F1bBS8/ABpw= +k8s.io/client-go v0.33.4/go.mod h1:LsA0+hBG2DPwovjd931L/AoaezMPX9CmBgyVyBZmbCY= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= +k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= +sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= +sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 8b7c4360b9..85644ccff5 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -41,7 +41,7 @@ func AssertAlwaysErrNil(err error, message string, details map[string]any) bool func NewClient() *client.Formance { gateway := os.Getenv("GATEWAY_URL") if gateway == "" { - gateway = "http://gateway:8080" + gateway = "http://gateway.stack0:8080/api/ledger" } return client.New( client.WithServerURL(gateway), From 096663766f6820c3ca0a88da212ac19c4af9e344 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 3 Sep 2025 16:31:25 +0200 Subject: [PATCH 31/66] partially fix ledger instrumentation --- test/antithesis/Justfile | 5 +++-- test/antithesis/config/Justfile | 1 + test/antithesis/config/manifests/stack.yaml | 11 +++++++++++ test/antithesis/image/Earthfile | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 039d712a6b..b47ab6fbd6 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -4,12 +4,13 @@ run-6min: requirements-build -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ "params": { \ "custom.duration": "0.1", \ - "antithesis.report.recipients": "${ANTITHESIS_SLACK_REPORT_RECIPIENT}", \ + "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:k8s_test", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ } \ }' requirements-build: just config/ + earthly --push ./image+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" diff --git a/test/antithesis/config/Justfile b/test/antithesis/config/Justfile index f4291c2378..34bde7daa3 100644 --- a/test/antithesis/config/Justfile +++ b/test/antithesis/config/Justfile @@ -1,6 +1,7 @@ build: rm -f -- tmp/resources.yaml + mkdir -p tmp cat manifests/namespace.yaml >> tmp/resources.yaml echo "---" >> tmp/resources.yaml cat manifests/postgres.yaml >> tmp/resources.yaml diff --git a/test/antithesis/config/manifests/stack.yaml b/test/antithesis/config/manifests/stack.yaml index 6b82625097..d67deee7fd 100644 --- a/test/antithesis/config/manifests/stack.yaml +++ b/test/antithesis/config/manifests/stack.yaml @@ -1,5 +1,15 @@ apiVersion: formance.com/v1beta1 kind: Settings +metadata: + name: formance-setting-ledger-image +spec: + key: registries."ghcr.io".images."formancehq/ledger".rewrite + stacks: + - "stack0" + value: "formancehq/ledger-instrumented" +--- +apiVersion: formance.com/v1beta1 +kind: Settings metadata: name: formance-settings spec: @@ -28,3 +38,4 @@ metadata: name: stack0 spec: stack: stack0 + version: k8s_test diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index 6803f4ce50..6e77ef603f 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -41,4 +41,4 @@ build: ARG --required ANTITHESIS_REPOSITORY - SAVE IMAGE --push --no-manifest-list "${ANTITHESIS_REPOSITORY}/ledger:k8s_test" + SAVE IMAGE --push ghcr.io/formancehq/ledger-instrumented:k8s_test From c1527182cd6bc2ef5c170af33e2f2c3e4124bc4a Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Mon, 8 Sep 2025 11:29:50 +0200 Subject: [PATCH 32/66] fixes, readiness probe, missing images --- test/antithesis/Justfile | 4 ++-- test/antithesis/config/Justfile | 4 ++-- test/antithesis/config/manifests/stack.yaml | 16 ++++++++-------- test/antithesis/config/manifests/workload.yaml | 8 ++++++++ test/antithesis/image/Earthfile | 2 -- test/antithesis/image/entrypoint.sh | 2 +- test/antithesis/workload/Earthfile | 2 ++ test/antithesis/workload/bin/init/main.go | 2 ++ test/antithesis/workload/internal/utils.go | 2 +- 9 files changed, 26 insertions(+), 16 deletions(-) diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index b47ab6fbd6..14866ea6c5 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -6,11 +6,11 @@ run-6min: requirements-build "custom.duration": "0.1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:k8s_test", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ } \ }' requirements-build: - just config/ + just config/push earthly --push ./image+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" diff --git a/test/antithesis/config/Justfile b/test/antithesis/config/Justfile index 34bde7daa3..542e0089fc 100644 --- a/test/antithesis/config/Justfile +++ b/test/antithesis/config/Justfile @@ -1,5 +1,4 @@ - -build: +build-manifest: rm -f -- tmp/resources.yaml mkdir -p tmp cat manifests/namespace.yaml >> tmp/resources.yaml @@ -13,5 +12,6 @@ build: echo "---" >> tmp/resources.yaml cat manifests/workload.yaml >> tmp/resources.yaml +push: build-manifest docker build -f Dockerfile.config -t $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test . docker push $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test diff --git a/test/antithesis/config/manifests/stack.yaml b/test/antithesis/config/manifests/stack.yaml index d67deee7fd..1678ba0507 100644 --- a/test/antithesis/config/manifests/stack.yaml +++ b/test/antithesis/config/manifests/stack.yaml @@ -1,22 +1,22 @@ apiVersion: formance.com/v1beta1 kind: Settings metadata: - name: formance-setting-ledger-image + name: formance-settings spec: - key: registries."ghcr.io".images."formancehq/ledger".rewrite + key: postgres.*.uri stacks: - "stack0" - value: "formancehq/ledger-instrumented" + value: postgresql://ledger:ledger@postgres.formance-systems.svc.cluster.local:5432?disableSSLMode=true --- apiVersion: formance.com/v1beta1 kind: Settings metadata: - name: formance-settings + name: formance-setting-ledger-image spec: - key: postgres.*.uri + key: registries."ghcr.io".images."formancehq/ledger".rewrite stacks: - "stack0" - value: postgresql://ledger:ledger@postgres.formance-systems.svc.cluster.local:5432?disableSSLMode=true + value: "formancehq/ledger-instrumented" --- apiVersion: formance.com/v1beta1 kind: Stack @@ -28,14 +28,14 @@ spec: apiVersion: formance.com/v1beta1 kind: Gateway metadata: - name: stack0 + name: stack0-gateway spec: stack: stack0 --- apiVersion: formance.com/v1beta1 kind: Ledger metadata: - name: stack0 + name: stack0-ledger spec: stack: stack0 version: k8s_test diff --git a/test/antithesis/config/manifests/workload.yaml b/test/antithesis/config/manifests/workload.yaml index 9a816ec892..4ee1577b83 100644 --- a/test/antithesis/config/manifests/workload.yaml +++ b/test/antithesis/config/manifests/workload.yaml @@ -10,3 +10,11 @@ spec: - name: workload image: us-central1-docker.pkg.dev/molten-verve-216720/formance-repository/workload:latest imagePullPolicy: IfNotPresent + readinessProbe: + exec: + command: + - sh + - -c + - "curl -sf http://gateway.stack0.svc.cluster.local:8080/api/ledger/v2" + initialDelaySeconds: 3 + periodSeconds: 3 diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index 6e77ef603f..7c1b4dc35f 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -39,6 +39,4 @@ build: ENTRYPOINT ["/bin/entrypoint.sh"] EXPOSE 8080 - ARG --required ANTITHESIS_REPOSITORY - SAVE IMAGE --push ghcr.io/formancehq/ledger-instrumented:k8s_test diff --git a/test/antithesis/image/entrypoint.sh b/test/antithesis/image/entrypoint.sh index 3606c70e05..9916e50581 100644 --- a/test/antithesis/image/entrypoint.sh +++ b/test/antithesis/image/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/sh # make sure pg is ready to accept connections -until pg_isready -d ledger -h postgres -U ledger +until pg_isready -d ledger -h postgres.formance-systems.svc.cluster.local -U ledger do echo "Waiting for postgres at: $POSTGRES_URI" sleep 2; diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile index 08ef6ab0c4..388e3a1460 100644 --- a/test/antithesis/workload/Earthfile +++ b/test/antithesis/workload/Earthfile @@ -39,6 +39,8 @@ build: COPY (+compile/out/init) /init ENTRYPOINT ["/init"] + RUN apt-get update && apt-get install -y curl + COPY (+compile/out/cmds/*) /opt/antithesis/test/v1/main/ ARG --required ANTITHESIS_REPOSITORY diff --git a/test/antithesis/workload/bin/init/main.go b/test/antithesis/workload/bin/init/main.go index e58198415d..592dadb565 100644 --- a/test/antithesis/workload/bin/init/main.go +++ b/test/antithesis/workload/bin/init/main.go @@ -6,6 +6,7 @@ import ( "os/signal" "syscall" "time" + "fmt" "github.com/antithesishq/antithesis-sdk-go/lifecycle" "github.com/formancehq/ledger/test/antithesis/internal" @@ -20,6 +21,7 @@ func main() { _, err := client.Ledger.GetInfo(ctx) if err != nil { + fmt.Printf("Not ready: %s\n", err) continue } break diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 85644ccff5..574df3758f 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -41,7 +41,7 @@ func AssertAlwaysErrNil(err error, message string, details map[string]any) bool func NewClient() *client.Formance { gateway := os.Getenv("GATEWAY_URL") if gateway == "" { - gateway = "http://gateway.stack0:8080/api/ledger" + gateway = "http://gateway.stack0.svc.cluster.local:8080/api/ledger" } return client.New( client.WithServerURL(gateway), From 0f879a9df39969d004f5ac2aceb0ad169d2ce6c6 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 9 Sep 2025 12:11:41 +0200 Subject: [PATCH 33/66] fix workload panic --- .../cmds/parallel_driver_transactions/main.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 60057f88b4..c7eba777c9 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "log" "math/big" @@ -10,6 +11,7 @@ import ( "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" + "github.com/formancehq/ledger/pkg/client/models/sdkerrors" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -32,18 +34,21 @@ func main() { pool := pond.New(10, 10e3) - for i := 0; i < count; i++ { + for range count { amount := internal.RandomBigInt() totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { - res, err := RunTx(ctx, client, Transaction(), ledger) + _, err := RunTx(ctx, client, Transaction(), ledger) assert.Sometimes(err == nil, "transaction was committed successfully", internal.Details{ "ledger": ledger, }) - assert.Always(!internal.IsServerError(res.GetHTTPMeta()), "no internal server error when committing transaction", internal.Details{ - "ledger": ledger, - "error": err, - }) + if err != nil { + var e *sdkerrors.V2ErrorResponse + assert.Always(!errors.As(err, &e), "no internal server error when committing transaction", internal.Details{ + "ledger": ledger, + "error": err, + }) + } }) } From c3cb880169563aa9e41f00abc85565828796c172 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 9 Sep 2025 12:12:44 +0200 Subject: [PATCH 34/66] remove main earthfile & fix workflow --- .github/workflows/antithesis.yml | 28 +++++++++--- test/antithesis/Earthfile | 78 -------------------------------- test/antithesis/Justfile | 12 +++++ 3 files changed, 34 insertions(+), 84 deletions(-) delete mode 100644 test/antithesis/Earthfile diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index f95fe24779..7952dc508e 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: inputs: run_tests: - description: 'Run Antithesis tests after pushing images' + description: "Run Antithesis tests after pushing images" type: boolean default: true push: @@ -12,12 +12,18 @@ on: pull_request: types: [opened, synchronize, reopened] paths: - - 'test/antithesis/**' + - "test/antithesis/**" + schedule: + - cron: "0 10 * * *" jobs: push-antithesis-images: name: Push Images to Antithesis runs-on: shipfox-4vcpu-ubuntu-2404 + env: + ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} + ANTITHESIS_SLACK_REPORT_RECIPIENT: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} + ANTITHESIS_REPOSITORY: ${{ secrets.ANTITHESIS_REGISTRY }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -30,6 +36,11 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} version: "latest" + - name: Setup Just + uses: extractions/setup-just@v3 + with: + just-version: "1.40.0" + - name: Setup Environment uses: ./.github/actions/default with: @@ -41,6 +52,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: "NumaryBot" + password: ${{ secrets.NUMARY_GITHUB_TOKEN }} + - name: Login to Antithesis Docker Registry run: | echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin @@ -48,12 +66,10 @@ jobs: - name: Build and Push Config Image run: | cd test/antithesis - earthly --push +requirements-build --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REPOSITORY }} + just requirements-build - name: Run Antithesis Tests if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} run: | cd test/antithesis - earthly +run --ANTITHESIS_SLACK_REPORT_RECIPIENT="${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }}" --ANTITHESIS_REPOSITORY=${{ secrets.ANTITHESIS_REGISTRY }} --ANTITHESIS_PASSWORD=${{ secrets.ANTITHESIS_PASSWORD }} - # env: - # ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} \ No newline at end of file + just run-6min diff --git a/test/antithesis/Earthfile b/test/antithesis/Earthfile deleted file mode 100644 index 3789e209c6..0000000000 --- a/test/antithesis/Earthfile +++ /dev/null @@ -1,78 +0,0 @@ -VERSION 0.8 - -IMPORT github.com/formancehq/earthly:tags/v0.19.1 AS core - -FROM core+base-image - -run: - WAIT - BUILD +requirements-build - END - - FROM curlimages/curl - ARG ANTITHESIS_USERNAME=formance - ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT - RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ - --fail \ - --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ - -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d "{ - \"params\": { - \"custom.duration\": \"0.1\", - \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", - \"antithesis.config_image\": \"antithesis-config:k8s_test\", - \"antithesis.images\": \"ledger:k8s_test;workload:latest;ghcr.io/formancehq/gateway:v2.0.0-rc.20;docker.io/library/postgres:15-alpine\" - } - }" - -run-1h: - WAIT - BUILD +requirements-build - END - - FROM curlimages/curl - ARG ANTITHESIS_USERNAME=formance - ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT - RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ - --fail \ - --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ - -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d "{ - \"params\": { - \"custom.duration\": \"1\", - \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\", - \"antithesis.config_image\": \"antithesis-config:k8s_test\", - \"antithesis.images\": \"ledger:k8s_test;workload:latest;ghcr.io/formancehq/gateway:v2.0.0-rc.20;docker.io/library/postgres:15-alpine\" - } - }" - -debugger: - FROM curlimages/curl - - ARG ANTITHESIS_USERNAME=formance - ARG --required ANTITHESIS_SLACK_REPORT_RECIPIENT - ARG --required VTIME - ARG --required SESSION_ID - ARG --required HASH - RUN echo "{ - \"params\": { - \"antithesis.debugging.session_id\": \"${SESSION_ID}\", - \"antithesis.debugging.input_hash\": \"${HASH}\", - \"antithesis.debugging.vtime\": \"${VTIME}\", - \"antithesis.report.recipients\": \"${ANTITHESIS_SLACK_REPORT_RECIPIENT}\" - } - }" > /tmp/debug_params.json - - # Display the debug parameters for verification - RUN cat /tmp/debug_params.json - - RUN --no-cache --secret ANTITHESIS_PASSWORD curl \ - --fail \ - --user "$ANTITHESIS_USERNAME:$ANTITHESIS_PASSWORD" \ - -X POST https://formance.antithesis.com/api/v1/launch/debugging \ - -d @/tmp/debug_params.json - -requirements-build: - ARG --required ANTITHESIS_REPOSITORY - - BUILD --pass-args ./config+build - BUILD --pass-args ./image+build - BUILD --pass-args ./workload+build diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 14866ea6c5..6dcdc3a780 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -10,6 +10,18 @@ run-6min: requirements-build } \ }' +run-1h: requirements-build + curl --fail \ + --user "formance:$ANTITHESIS_PASSWORD" \ + -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ + "params": { \ + "custom.duration": "1", \ + "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ + "antithesis.config_image": "antithesis-config:k8s_test", \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ + } \ + }' + requirements-build: just config/push earthly --push ./image+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" From 9db3f814c9733349143461c170d1c2aaf6482d07 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 9 Sep 2025 13:05:48 +0200 Subject: [PATCH 35/66] fix secret name --- .github/workflows/antithesis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index 7952dc508e..59c4a126aa 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -23,7 +23,7 @@ jobs: env: ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} ANTITHESIS_SLACK_REPORT_RECIPIENT: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} - ANTITHESIS_REPOSITORY: ${{ secrets.ANTITHESIS_REGISTRY }} + ANTITHESIS_REPOSITORY: ${{ secrets.ANTITHESIS_REPOSITORY }} steps: - name: Checkout code uses: actions/checkout@v4 From fddeb96cd4c972d15899403da3d29d40009d9ab0 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 9 Sep 2025 14:08:19 +0200 Subject: [PATCH 36/66] use antithesis-trigger-action --- .github/workflows/antithesis.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index 59c4a126aa..d68912f883 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -36,11 +36,6 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} version: "latest" - - name: Setup Just - uses: extractions/setup-just@v3 - with: - just-version: "1.40.0" - - name: Setup Environment uses: ./.github/actions/default with: @@ -70,6 +65,19 @@ jobs: - name: Run Antithesis Tests if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} - run: | - cd test/antithesis - just run-6min + uses: antithesishq/antithesis-trigger-action@v0.8 + with: + notebook_name: formance-k8s + tenant: formance + username: ${{ secrets.ANTITHESIS_USERNAME }} + password: ${{ secrets.ANTITHESIS_PASSWORD }} + github_token: ${{ secrets.ANTITHESIS_GH_PAT }} + images: + - "workload:latest" + - "docker.io/library/postgres:15-alpine" + - "ghcr.io/formancehq/operator:v2.10.1" + - "ghcr.io/formancehq/operator-utils:v2.0.14" + - "ghcr.io/formancehq/gateway:v2.0.24" + - "ghcr.io/formancehq/ledger-instrumented:k8s_test" + config_image: "antithesis-config:k8s_test" + email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} From fa66ba7820d8cfb7c5abf021f575cf5a30095563 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 9 Sep 2025 14:13:58 +0200 Subject: [PATCH 37/66] fix images list --- .github/workflows/antithesis.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index d68912f883..f69b84b026 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -72,12 +72,6 @@ jobs: username: ${{ secrets.ANTITHESIS_USERNAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} github_token: ${{ secrets.ANTITHESIS_GH_PAT }} - images: - - "workload:latest" - - "docker.io/library/postgres:15-alpine" - - "ghcr.io/formancehq/operator:v2.10.1" - - "ghcr.io/formancehq/operator-utils:v2.0.14" - - "ghcr.io/formancehq/gateway:v2.0.24" - - "ghcr.io/formancehq/ledger-instrumented:k8s_test" + images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" config_image: "antithesis-config:k8s_test" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} From 62309de9aacda48cc2b9d5237b34dec2c73a50c8 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 9 Sep 2025 14:30:19 +0200 Subject: [PATCH 38/66] keep just setup for now --- .github/workflows/antithesis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index f69b84b026..1d9c957763 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -36,6 +36,11 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} version: "latest" + - name: Setup Just + uses: extractions/setup-just@v3 + with: + just-version: "1.40.0" + - name: Setup Environment uses: ./.github/actions/default with: From 1ee57955ca33e3addbf372a23447346054216844 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 10 Sep 2025 14:40:30 +0200 Subject: [PATCH 39/66] version upgrades & specify tags in workflow --- .github/workflows/antithesis.yml | 23 +++-- test/antithesis/Justfile | 4 +- test/antithesis/config/Justfile | 2 + test/antithesis/config/manifests/ledger.yaml | 19 ++--- .../antithesis/config/manifests/settings.yaml | 10 --- test/antithesis/config/manifests/stack.yaml | 8 -- test/antithesis/workload/Earthfile | 4 +- .../bin/cmds/anytime_version_upgrade/main.go | 67 ++++++++++++--- test/antithesis/workload/go.mod | 37 ++++---- test/antithesis/workload/go.sum | 84 +++++++++---------- 10 files changed, 140 insertions(+), 118 deletions(-) delete mode 100644 test/antithesis/config/manifests/settings.yaml diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index 1d9c957763..ae2b21b7a9 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -6,13 +6,13 @@ on: description: "Run Antithesis tests after pushing images" type: boolean default: true - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] - paths: - - "test/antithesis/**" + # push: + # branches: + # - main + # pull_request: + # types: [opened, synchronize, reopened] + # paths: + # - "test/antithesis/**" schedule: - cron: "0 10 * * *" @@ -24,6 +24,11 @@ jobs: ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} ANTITHESIS_SLACK_REPORT_RECIPIENT: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} ANTITHESIS_REPOSITORY: ${{ secrets.ANTITHESIS_REPOSITORY }} + OPERATOR_TAG: v2.10.1 + OPERATOR_UTILS_TAG: v2.0.14 + GATEWAY_TAG: v2.0.24 + LEDGER_PREVIOUS_TAG: v2.2.47 + LEDGER_LATEST_TAG: v2.3.0-rc.2 steps: - name: Checkout code uses: actions/checkout@v4 @@ -69,7 +74,7 @@ jobs: just requirements-build - name: Run Antithesis Tests - if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} + # if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} uses: antithesishq/antithesis-trigger-action@v0.8 with: notebook_name: formance-k8s @@ -77,6 +82,6 @@ jobs: username: ${{ secrets.ANTITHESIS_USERNAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} github_token: ${{ secrets.ANTITHESIS_GH_PAT }} - images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" + images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:k8s_test" config_image: "antithesis-config:k8s_test" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 6dcdc3a780..036fb1ec03 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -24,5 +24,5 @@ run-1h: requirements-build requirements-build: just config/push - earthly --push ./image+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" - earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" + # earthly --push ./image+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" + earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" --LEDGER_LATEST_TAG="$LEDGER_LATEST_TAG" diff --git a/test/antithesis/config/Justfile b/test/antithesis/config/Justfile index 542e0089fc..2c52fa8ec7 100644 --- a/test/antithesis/config/Justfile +++ b/test/antithesis/config/Justfile @@ -10,6 +10,8 @@ build-manifest: echo "---" >> tmp/resources.yaml cat manifests/stack.yaml >> tmp/resources.yaml echo "---" >> tmp/resources.yaml + yq '.spec.version = strenv(LEDGER_PREVIOUS_TAG)' manifests/ledger.yaml >> tmp/resources.yaml + echo "---" >> tmp/resources.yaml cat manifests/workload.yaml >> tmp/resources.yaml push: build-manifest diff --git a/test/antithesis/config/manifests/ledger.yaml b/test/antithesis/config/manifests/ledger.yaml index 9e648eeae7..cca83e3495 100644 --- a/test/antithesis/config/manifests/ledger.yaml +++ b/test/antithesis/config/manifests/ledger.yaml @@ -1,12 +1,7 @@ -# apiVersion: v1 -# kind: Service -# metadata: -# name: gateway -# namespace: formance-systems -# spec: -# selector: -# app: gateway -# ports: -# - protocol: TCP -# port: 8080 -# targetPort: 8080 +apiVersion: formance.com/v1beta1 +kind: Ledger +metadata: + name: stack0-ledger +spec: + stack: stack0 + version: LEDGER_VERSION_PLACEHOLDER diff --git a/test/antithesis/config/manifests/settings.yaml b/test/antithesis/config/manifests/settings.yaml deleted file mode 100644 index 445624ede9..0000000000 --- a/test/antithesis/config/manifests/settings.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: formance.com/v1beta1 -kind: Settings -metadata: - name: formance-settings - namespace: formance-systems -spec: - key: postgres.*.uri - stacks: - - "stack0" - value: postgresql://ledger:ledger@postgres.formance-db.svc.cluster.local:5432?sslmode=disable diff --git a/test/antithesis/config/manifests/stack.yaml b/test/antithesis/config/manifests/stack.yaml index 1678ba0507..90e725bb96 100644 --- a/test/antithesis/config/manifests/stack.yaml +++ b/test/antithesis/config/manifests/stack.yaml @@ -31,11 +31,3 @@ metadata: name: stack0-gateway spec: stack: stack0 ---- -apiVersion: formance.com/v1beta1 -kind: Ledger -metadata: - name: stack0-ledger -spec: - stack: stack0 - version: k8s_test diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile index 388e3a1460..d88b10d413 100644 --- a/test/antithesis/workload/Earthfile +++ b/test/antithesis/workload/Earthfile @@ -44,6 +44,8 @@ build: COPY (+compile/out/cmds/*) /opt/antithesis/test/v1/main/ ARG --required ANTITHESIS_REPOSITORY + ARG --required LEDGER_LATEST_TAG + + RUN echo ${LEDGER_LATEST_TAG} > /ledger_latest_tag SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest - # SAVE IMAGE --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest diff --git a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go index e33d4daea9..66ced3f893 100644 --- a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go +++ b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go @@ -1,25 +1,68 @@ package main import ( + "context" "log" + "os" - // "k8s.io/client-go/kubernetes" - // "k8s.io/client-go/tools/clientcmd" + "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/formancehq/ledger/test/antithesis/internal" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/dynamic" + + "k8s.io/client-go/tools/clientcmd" ) func main() { - // var kubeconfig *string + // get latest version + latest_tag, err := os.ReadFile("/ledger_latest_tag") + if err != nil { + log.Fatal(err) + } + + // build dynamic client + config, err := clientcmd.BuildConfigFromFlags("", "") + if err != nil { + panic(err) + } + + dyn, err := dynamic.NewForConfig(config) + if err != nil { + panic(err) + } + + gvr := schema.GroupVersionResource { + Group: "formance.com", + Version: "v1beta1", + Resource: "ledgers", + } + + obj := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "formance.com/v1beta1", + "kind": "Ledger", + "metadata": map[string]interface{}{ + "name": "stack0-ledger", + }, + "spec": map[string]interface{}{ + "stack": "stack0", + "version": string(latest_tag), + }, + }, + } - // config, err := clientcmd.BuildConfigFromFlags() - // if err != nil { - // panic(err) - // } + // update Ledger custom resource to next version + res, err := dyn.Resource(gvr).Namespace("formance-systems").Update(context.Background(), obj, metav1.UpdateOptions{}) - // clientset, err := kubernetes.NewForConfig(config) - // if err != nil { - // panic(err) - // } + assert.Sometimes(err == nil, "successfully", internal.Details{ + "ledger": res, + }) + if err != nil { + panic(err) + } - // TODO: implement log.Println("placeholder command for anytime_version_upgrade") } diff --git a/test/antithesis/workload/go.mod b/test/antithesis/workload/go.mod index 7a2374b7ed..394b27a5fc 100644 --- a/test/antithesis/workload/go.mod +++ b/test/antithesis/workload/go.mod @@ -11,54 +11,47 @@ require ( github.com/antithesishq/antithesis-sdk-go v0.4.2 github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 - go.uber.org/atomic v1.10.0 golang.org/x/sync v0.12.0 // indirect; indirect, for singleflight package ) +require ( + k8s.io/apimachinery v0.34.0 + k8s.io/client-go v0.34.0 +) + require ( github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect - github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/go-logr/logr v1.4.2 // indirect - github.com/go-openapi/jsonpointer v0.21.0 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.23.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/google/gnostic-models v0.6.9 // indirect - github.com/google/go-cmp v0.7.0 // indirect - github.com/google/uuid v1.6.0 // indirect github.com/invopop/jsonschema v0.12.0 // indirect - github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/pflag v1.0.6 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/x448/float16 v0.8.4 // indirect + go.yaml.in/yaml/v2 v2.4.2 // indirect golang.org/x/net v0.38.0 // indirect golang.org/x/oauth2 v0.27.0 // indirect golang.org/x/sys v0.31.0 // indirect golang.org/x/term v0.30.0 // indirect golang.org/x/text v0.23.0 // indirect golang.org/x/time v0.9.0 // indirect - google.golang.org/protobuf v1.36.5 // indirect - gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.33.4 // indirect - k8s.io/apimachinery v0.33.4 // indirect - k8s.io/client-go v0.33.4 // indirect k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff // indirect - k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect - sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect + sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect sigs.k8s.io/randfill v1.0.0 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect - sigs.k8s.io/yaml v1.4.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect ) diff --git a/test/antithesis/workload/go.sum b/test/antithesis/workload/go.sum index ef82d511bc..80366909ee 100644 --- a/test/antithesis/workload/go.sum +++ b/test/antithesis/workload/go.sum @@ -11,29 +11,26 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= -github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU= +github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 h1:l6jieaR+sn4Ff+puBDMbTYmT2HTYC7Yt7GTxBAwC3eU= github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9/go.mod h1:m0uKkey9OC/AeyWMwjMfZqhLzoWrPFBk8vuYdSSYj4Y= -github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= -github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= +github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= -github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= +github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -48,42 +45,49 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.yaml.in/yaml/v2 v2.4.2 h1:DzmwEr2rDGHl7lsFgAHxmNz/1NlQ7xLIrlN2h5d1eGI= +go.yaml.in/yaml/v2 v2.4.2/go.mod h1:081UH+NErpNdqlCXm3TtEran0rJZGxAYx9hb/ELlsPU= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -100,8 +104,6 @@ golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -127,34 +129,32 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.33.4 h1:oTzrFVNPXBjMu0IlpA2eDDIU49jsuEorGHB4cvKupkk= -k8s.io/api v0.33.4/go.mod h1:VHQZ4cuxQ9sCUMESJV5+Fe8bGnqAARZ08tSTdHWfeAc= -k8s.io/apimachinery v0.33.4 h1:SOf/JW33TP0eppJMkIgQ+L6atlDiP/090oaX0y9pd9s= -k8s.io/apimachinery v0.33.4/go.mod h1:BHW0YOu7n22fFv/JkYOEfkUYNRN0fj0BlvMFWA7b+SM= -k8s.io/client-go v0.33.4 h1:TNH+CSu8EmXfitntjUPwaKVPN0AYMbc9F1bBS8/ABpw= -k8s.io/client-go v0.33.4/go.mod h1:LsA0+hBG2DPwovjd931L/AoaezMPX9CmBgyVyBZmbCY= +k8s.io/api v0.34.0 h1:L+JtP2wDbEYPUeNGbeSa/5GwFtIA662EmT2YSLOkAVE= +k8s.io/api v0.34.0/go.mod h1:YzgkIzOOlhl9uwWCZNqpw6RJy9L2FK4dlJeayUoydug= +k8s.io/apimachinery v0.34.0 h1:eR1WO5fo0HyoQZt1wdISpFDffnWOvFLOOeJ7MgIv4z0= +k8s.io/apimachinery v0.34.0/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +k8s.io/client-go v0.34.0 h1:YoWv5r7bsBfb0Hs2jh8SOvFbKzzxyNo0nSb0zC19KZo= +k8s.io/client-go v0.34.0/go.mod h1:ozgMnEKXkRjeMvBZdV1AijMHLTh3pbACPvK7zFR+QQY= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= -k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= -k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= -sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= -sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA= +k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts= +k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y= +k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= +sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= -sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= -sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= -sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= -sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= From 65042d538b0bcf11ac902e7920923ac7da2843bb Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 10 Sep 2025 14:55:21 +0200 Subject: [PATCH 40/66] test run --- .github/workflows/antithesis.yml | 8 ++++---- test/antithesis/image/Earthfile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index ae2b21b7a9..e3264e5bb9 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -9,10 +9,10 @@ on: # push: # branches: # - main - # pull_request: - # types: [opened, synchronize, reopened] - # paths: - # - "test/antithesis/**" + pull_request: + types: [opened, synchronize, reopened] + paths: + - "test/antithesis/**" schedule: - cron: "0 10 * * *" diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index 7c1b4dc35f..0269ce29fd 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -39,4 +39,4 @@ build: ENTRYPOINT ["/bin/entrypoint.sh"] EXPOSE 8080 - SAVE IMAGE --push ghcr.io/formancehq/ledger-instrumented:k8s_test + SAVE IMAGE --push ghcr.io/formancehq/ledger-instrumented:latest From af6956b23a61c4fd2a263822714795b82ef96899 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 10 Sep 2025 14:57:06 +0200 Subject: [PATCH 41/66] fix workflow --- .github/workflows/antithesis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index e3264e5bb9..b0404dd080 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -24,11 +24,11 @@ jobs: ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} ANTITHESIS_SLACK_REPORT_RECIPIENT: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} ANTITHESIS_REPOSITORY: ${{ secrets.ANTITHESIS_REPOSITORY }} - OPERATOR_TAG: v2.10.1 - OPERATOR_UTILS_TAG: v2.0.14 - GATEWAY_TAG: v2.0.24 - LEDGER_PREVIOUS_TAG: v2.2.47 - LEDGER_LATEST_TAG: v2.3.0-rc.2 + OPERATOR_TAG: "v2.10.1" + OPERATOR_UTILS_TAG: "v2.0.14" + GATEWAY_TAG: "v2.0.24" + LEDGER_PREVIOUS_TAG: "v2.2.47" + LEDGER_LATEST_TAG: "v2.3.0-rc.2" steps: - name: Checkout code uses: actions/checkout@v4 From 59ddcbf4e4bf61f7dd1d28034e02aa3dcee814d0 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 10 Sep 2025 15:29:20 +0200 Subject: [PATCH 42/66] fix workflow --- .github/workflows/antithesis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index b0404dd080..2440652eb3 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -82,6 +82,6 @@ jobs: username: ${{ secrets.ANTITHESIS_USERNAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} github_token: ${{ secrets.ANTITHESIS_GH_PAT }} - images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:k8s_test" + images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:k8s_test" config_image: "antithesis-config:k8s_test" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} From 3242e7115f0f7bd8afa9594dd5b19e4bd5747899 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 10 Sep 2025 15:56:59 +0200 Subject: [PATCH 43/66] fix missing images --- .github/workflows/antithesis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index 2440652eb3..25ff021bc2 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -68,10 +68,10 @@ jobs: run: | echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin - - name: Build and Push Config Image - run: | - cd test/antithesis - just requirements-build + # - name: Build and Push Config Image + # run: | + # cd test/antithesis + # just requirements-build - name: Run Antithesis Tests # if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} @@ -82,6 +82,6 @@ jobs: username: ${{ secrets.ANTITHESIS_USERNAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} github_token: ${{ secrets.ANTITHESIS_GH_PAT }} - images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:k8s_test" + images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" config_image: "antithesis-config:k8s_test" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} From 3c8a68b1d7960d2eea95021ca673ad29217e4ff9 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 10 Sep 2025 17:19:27 +0200 Subject: [PATCH 44/66] fix token --- .github/workflows/antithesis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis.yml index 25ff021bc2..83477321a9 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis.yml @@ -81,7 +81,7 @@ jobs: tenant: formance username: ${{ secrets.ANTITHESIS_USERNAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} - github_token: ${{ secrets.ANTITHESIS_GH_PAT }} + github_token: ${{ secrets.NUMARY_GITHUB_TOKEN }} images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" config_image: "antithesis-config:k8s_test" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} From d2d57b77f41c19ddfed73e4809a0d21251583c7c Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 10 Sep 2025 23:06:23 +0200 Subject: [PATCH 45/66] fix version update command & workload permissions --- .../antithesis/config/manifests/workload.yaml | 22 ++++++++++++++++ .../bin/cmds/anytime_version_upgrade/main.go | 26 +++++++------------ 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/test/antithesis/config/manifests/workload.yaml b/test/antithesis/config/manifests/workload.yaml index 4ee1577b83..57d0612ad6 100644 --- a/test/antithesis/config/manifests/workload.yaml +++ b/test/antithesis/config/manifests/workload.yaml @@ -18,3 +18,25 @@ spec: - "curl -sf http://gateway.stack0.svc.cluster.local:8080/api/ledger/v2" initialDelaySeconds: 3 periodSeconds: 3 +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: ledger-updater +rules: + - apiGroups: ["formance.com"] + resources: ["ledgers"] + verbs: ["get", "list", "watch", "update", "patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: ledger-updater-binding +subjects: + - kind: ServiceAccount + name: default + namespace: formance-systems +roleRef: + kind: ClusterRole + name: ledger-updater + apiGroup: rbac.authorization.k8s.io diff --git a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go index 66ced3f893..e231d14fe5 100644 --- a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go +++ b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go @@ -40,29 +40,21 @@ func main() { Resource: "ledgers", } - obj := &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "formance.com/v1beta1", - "kind": "Ledger", - "metadata": map[string]interface{}{ - "name": "stack0-ledger", - }, - "spec": map[string]interface{}{ - "stack": "stack0", - "version": string(latest_tag), - }, - }, + // fetch the previous Ledger resource + res, err := dyn.Resource(gvr).Get(context.Background(), "stack0-ledger", metav1.GetOptions{}) + if err != nil { + panic(err) } - // update Ledger custom resource to next version - res, err := dyn.Resource(gvr).Namespace("formance-systems").Update(context.Background(), obj, metav1.UpdateOptions{}) + // set the version to the latest tag + unstructured.SetNestedField(res.Object, string(latest_tag), "spec", "version") - assert.Sometimes(err == nil, "successfully", internal.Details{ + res, err = dyn.Resource(gvr).Update(context.Background(), res, metav1.UpdateOptions{}) + + assert.Sometimes(err == nil, "stack0-ledger should successfully be updated", internal.Details{ "ledger": res, }) if err != nil { panic(err) } - - log.Println("placeholder command for anytime_version_upgrade") } From 0484df18fad9ae5d55558a12c9e721a824ef59f3 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 23 Sep 2025 14:45:31 +0200 Subject: [PATCH 46/66] temporarily disable version update, more complex workload & checks --- .../{antithesis.yml => antithesis_daily.yml} | 18 +++-- .github/workflows/antithesis_release.yml | 53 +++++++++++++ test/antithesis/Justfile | 1 - .../bin/cmds/eventually_correct/main.go | 75 ++++++++++++++++++- .../cmds/parallel_driver_transactions/main.go | 31 ++++---- test/antithesis/workload/internal/utils.go | 8 +- 6 files changed, 160 insertions(+), 26 deletions(-) rename .github/workflows/{antithesis.yml => antithesis_daily.yml} (76%) create mode 100644 .github/workflows/antithesis_release.yml diff --git a/.github/workflows/antithesis.yml b/.github/workflows/antithesis_daily.yml similarity index 76% rename from .github/workflows/antithesis.yml rename to .github/workflows/antithesis_daily.yml index 83477321a9..80673e7d17 100644 --- a/.github/workflows/antithesis.yml +++ b/.github/workflows/antithesis_daily.yml @@ -27,8 +27,10 @@ jobs: OPERATOR_TAG: "v2.10.1" OPERATOR_UTILS_TAG: "v2.0.14" GATEWAY_TAG: "v2.0.24" - LEDGER_PREVIOUS_TAG: "v2.2.47" - LEDGER_LATEST_TAG: "v2.3.0-rc.2" + # LEDGER_PREVIOUS_TAG: "v2.2.47" + # temporary: remove this when support for multiple image versions is added + LEDGER_PREVIOUS_TAG: "v2.3.0" + LEDGER_LATEST_TAG: "v2.3.0" steps: - name: Checkout code uses: actions/checkout@v4 @@ -68,10 +70,10 @@ jobs: run: | echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin - # - name: Build and Push Config Image - # run: | - # cd test/antithesis - # just requirements-build + - name: Build and Push Config Image + run: | + cd test/antithesis + just requirements-build - name: Run Antithesis Tests # if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} @@ -82,6 +84,8 @@ jobs: username: ${{ secrets.ANTITHESIS_USERNAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} github_token: ${{ secrets.NUMARY_GITHUB_TOKEN }} - images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" + # images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" + # temporary: remove this when support for multiple image versions is added + images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" config_image: "antithesis-config:k8s_test" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} diff --git a/.github/workflows/antithesis_release.yml b/.github/workflows/antithesis_release.yml new file mode 100644 index 0000000000..7600121378 --- /dev/null +++ b/.github/workflows/antithesis_release.yml @@ -0,0 +1,53 @@ +name: Antithesis Integration +on: + push: + tags: + - "*" + +jobs: + push-antithesis-images: + name: Push Images to Antithesis + runs-on: shipfox-4vcpu-ubuntu-2404 + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Earthly + uses: earthly/actions-setup@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + version: "latest" + + - name: Setup Just + uses: extractions/setup-just@v3 + with: + just-version: "1.40.0" + + - name: Setup Environment + uses: ./.github/actions/default + with: + token: ${{ secrets.NUMARY_GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: "NumaryBot" + password: ${{ secrets.NUMARY_GITHUB_TOKEN }} + + - name: Login to Antithesis Docker Registry + run: | + echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin + + - name: Build and Push Config Image + run: | + cd test/antithesis/image + earthly --push ./image+build --ANTITHESIS_REPOSITORY="${{ secrets.ANTITHESIS_REPOSITORY }}" --LEDGER_LATEST_TAG="${{ env.GITHUB_REF_NAME }}" diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 036fb1ec03..221fab0093 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -24,5 +24,4 @@ run-1h: requirements-build requirements-build: just config/push - # earthly --push ./image+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" --LEDGER_LATEST_TAG="$LEDGER_LATEST_TAG" diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 7a5ce3e022..3cad15b225 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -32,13 +32,15 @@ func main() { wg.Add(1) go func(ledger string) { defer wg.Done() - checkVolumes(ctx, client, ledger) + checkBalanced(ctx, client, ledger) + checkAccountBalances(ctx, client, ledger) + checkSequentialTxIDs(ctx, client, ledger) }(ledger.Name) } wg.Wait() } -func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { +func checkBalanced(ctx context.Context, client *client.Formance, ledger string) { aggregated, err := client.Ledger.V2.GetBalancesAggregated(ctx, operations.V2GetBalancesAggregatedRequest{ Ledger: ledger, }) @@ -66,7 +68,74 @@ func checkVolumes(ctx context.Context, client *client.Formance, ledger string) { }) } - log.Printf("composer: eventually_correct: done for ledger %s", ledger) + log.Printf("composer: balanced: done for ledger %s", ledger) +} + +func checkAccountBalances(ctx context.Context, client *client.Formance, ledger string) { + for i := range internal.USER_ACCOUNT_COUNT { + address := fmt.Sprintf("users:%d", i) + account, err := client.Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{ + Ledger: ledger, + Address: address, + }) + assert.Sometimes(err != nil, "Client can aggregate account balances", internal.Details{ + "error": err, + }) + if err != nil { + continue + } + zero := big.NewInt(0) + for asset, volume := range account.V2AccountResponse.Data.Volumes { + balance := new(big.Int).Set(volume.Input) + balance.Sub(balance, volume.Output) + assert.Always(balance.Cmp(volume.Balance) == 0, "Reported balance and volumes should be consistent", internal.Details{ + "address": address, + "asset": asset, + "volume": volume, + }) + assert.Always(volume.Balance.Cmp(zero) != -1, "Balance should stay positive when no overdraft is allowed", internal.Details{ + "address": address, + "asset": asset, + "volume": volume, + }) + } + + } + + log.Printf("composer: account balances check: done for ledger %s", ledger) +} + +func checkSequentialTxIDs(ctx context.Context, client *client.Formance, ledger string) { + var expectedTxId *big.Int + for { + transactions, err := client.Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ + Ledger: ledger, + }) + assert.Sometimes(err != nil, "Client can list transactions", internal.Details{ + "error": err, + }) + if err != nil { + return + } + if len(transactions.V2TransactionsCursorResponse.Cursor.Data) == 0 { + return + } + if expectedTxId == nil { + expectedTxId = transactions.V2TransactionsCursorResponse.Cursor.Data[0].ID + expectedTxId.Add(expectedTxId, big.NewInt(1)) + } + for _, tx := range transactions.V2TransactionsCursorResponse.Cursor.Data { + expectedTxId.Sub(expectedTxId, big.NewInt(1)) + assert.Always(tx.ID.Cmp(expectedTxId) == 0, "txId should be sequential", internal.Details{ + "expected": expectedTxId, + "actual": tx.ID, + }) + } + if !transactions.V2TransactionsCursorResponse.Cursor.HasMore { + break + } + } + log.Printf("composer: sequential transaction id check: done for ledger %s", ledger) } func IsServerError(httpMeta components.HTTPMetadata) bool { diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index c7eba777c9..0185843136 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -4,10 +4,10 @@ import ( "context" "errors" "log" - "math/big" "github.com/alitto/pond" "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/antithesishq/antithesis-sdk-go/random" "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" @@ -30,15 +30,11 @@ func main() { const count = 100 - totalAmount := big.NewInt(0) - pool := pond.New(10, 10e3) for range count { - amount := internal.RandomBigInt() - totalAmount = totalAmount.Add(totalAmount, amount) pool.Submit(func() { - _, err := RunTx(ctx, client, Transaction(), ledger) + _, err := RunTx(ctx, client, RandomPostings(), ledger) assert.Sometimes(err == nil, "transaction was committed successfully", internal.Details{ "ledger": ledger, }) @@ -75,15 +71,22 @@ func RunTx( return res, err } -func Transaction() []components.V2Posting { +func RandomPostings() []components.V2Posting { postings := []components.V2Posting{} - postings = append(postings, components.V2Posting{ - Amount: big.NewInt(100), - Asset: "USD/2", - Destination: "orders:1234", - Source: "world", - }) + for range random.GetRandom()%20 { + source := internal.GetRandomAddress() + destination := internal.GetRandomAddress() + amount := internal.RandomBigInt() + asset := random.RandomChoice([]string{"USD/2", "EUR/2", "COIN"}) + + postings = append(postings, components.V2Posting{ + Amount: amount, + Asset: asset, + Destination: destination, + Source: source, + }) + } return postings } @@ -92,7 +95,7 @@ func Sequence() []Postings { postings := []Postings{} for i := 0; i < 10; i++ { - postings = append(postings, Transaction()) + postings = append(postings, RandomPostings()) } return postings diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 574df3758f..566afaebf1 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -17,6 +17,8 @@ import ( "github.com/formancehq/ledger/pkg/client/retry" ) +const USER_ACCOUNT_COUNT uint64 = 1000; + type Details map[string]any func RandomBigInt() *big.Int { @@ -92,7 +94,7 @@ func ListLedgers(ctx context.Context, client *client.Formance) ([]string, error) func GetRandomLedger(ctx context.Context, client *client.Formance) (string, error) { ledgers, err := ListLedgers(ctx, client) if err != nil { - return "", err + return "", fmt.Errorf("error listing ledgers: %v", err) } if len(ledgers) == 0 { @@ -103,3 +105,7 @@ func GetRandomLedger(ctx context.Context, client *client.Formance) (string, erro return ledgers[randomIndex], nil } + +func GetRandomAddress() string { + return random.RandomChoice([]string{"world", fmt.Sprintf("users:%d", random.GetRandom()%USER_ACCOUNT_COUNT)}) +} From a5e3d61baffb410208df0c39ab5583819346eea2 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 23 Sep 2025 15:42:33 +0200 Subject: [PATCH 47/66] fix instrumented ledger release workflow --- .github/workflows/antithesis_release.yml | 2 +- test/antithesis/image/Earthfile | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/antithesis_release.yml b/.github/workflows/antithesis_release.yml index 7600121378..c464bfc34b 100644 --- a/.github/workflows/antithesis_release.yml +++ b/.github/workflows/antithesis_release.yml @@ -50,4 +50,4 @@ jobs: - name: Build and Push Config Image run: | cd test/antithesis/image - earthly --push ./image+build --ANTITHESIS_REPOSITORY="${{ secrets.ANTITHESIS_REPOSITORY }}" --LEDGER_LATEST_TAG="${{ env.GITHUB_REF_NAME }}" + earthly --push ./image+build --LEDGER_TAG="${{ env.GITHUB_REF_NAME }}" diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile index 0269ce29fd..3163dbd8ad 100644 --- a/test/antithesis/image/Earthfile +++ b/test/antithesis/image/Earthfile @@ -39,4 +39,6 @@ build: ENTRYPOINT ["/bin/entrypoint.sh"] EXPOSE 8080 - SAVE IMAGE --push ghcr.io/formancehq/ledger-instrumented:latest + ARG --required LEDGER_TAG + + SAVE IMAGE --push ghcr.io/formancehq/ledger-instrumented:${LEDGER_TAG} From 6b8fd2e2e615ba94a1b8286880d26890023d8525 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 23 Sep 2025 16:20:21 +0200 Subject: [PATCH 48/66] rerun workflow & fix names --- .github/workflows/antithesis_daily.yml | 3 ++- .github/workflows/antithesis_release.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/antithesis_daily.yml b/.github/workflows/antithesis_daily.yml index 80673e7d17..0addf78b23 100644 --- a/.github/workflows/antithesis_daily.yml +++ b/.github/workflows/antithesis_daily.yml @@ -1,4 +1,4 @@ -name: Antithesis Integration +name: Antithesis Daily Run on: workflow_dispatch: inputs: @@ -13,6 +13,7 @@ on: types: [opened, synchronize, reopened] paths: - "test/antithesis/**" + - ".github/workflows/antithesis_daily.yml" schedule: - cron: "0 10 * * *" diff --git a/.github/workflows/antithesis_release.yml b/.github/workflows/antithesis_release.yml index c464bfc34b..d5c5ec91cc 100644 --- a/.github/workflows/antithesis_release.yml +++ b/.github/workflows/antithesis_release.yml @@ -1,4 +1,4 @@ -name: Antithesis Integration +name: Antithesis Instrumented Release on: push: tags: From f51e01f449f896b620abafefd8bc64e81a6a42ae Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 23 Sep 2025 17:19:40 +0200 Subject: [PATCH 49/66] workflow fixes --- .../workload/bin/cmds/anytime_version_upgrade/main.go | 3 --- .../workload/bin/cmds/eventually_correct/main.go | 7 +++++++ .../workload/bin/cmds/parallel_driver_transactions/main.go | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go index e231d14fe5..693ba71bd3 100644 --- a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go +++ b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go @@ -54,7 +54,4 @@ func main() { assert.Sometimes(err == nil, "stack0-ledger should successfully be updated", internal.Details{ "ledger": res, }) - if err != nil { - panic(err) - } } diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 3cad15b225..4cab389ffc 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -107,14 +107,17 @@ func checkAccountBalances(ctx context.Context, client *client.Formance, ledger s func checkSequentialTxIDs(ctx context.Context, client *client.Formance, ledger string) { var expectedTxId *big.Int + var next *string for { transactions, err := client.Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ Ledger: ledger, + Cursor: next, }) assert.Sometimes(err != nil, "Client can list transactions", internal.Details{ "error": err, }) if err != nil { + fmt.Printf("error listing transactions: %v", err) return } if len(transactions.V2TransactionsCursorResponse.Cursor.Data) == 0 { @@ -126,6 +129,9 @@ func checkSequentialTxIDs(ctx context.Context, client *client.Formance, ledger s } for _, tx := range transactions.V2TransactionsCursorResponse.Cursor.Data { expectedTxId.Sub(expectedTxId, big.NewInt(1)) + if tx.ID.Cmp(expectedTxId) != 0 { + panic(fmt.Sprintf("oop: expected %v and got %v", expectedTxId, tx.ID)) + } assert.Always(tx.ID.Cmp(expectedTxId) == 0, "txId should be sequential", internal.Details{ "expected": expectedTxId, "actual": tx.ID, @@ -134,6 +140,7 @@ func checkSequentialTxIDs(ctx context.Context, client *client.Formance, ledger s if !transactions.V2TransactionsCursorResponse.Cursor.HasMore { break } + next = transactions.V2TransactionsCursorResponse.Cursor.Next } log.Printf("composer: sequential transaction id check: done for ledger %s", ledger) } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 0185843136..03c0ec66bb 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -40,7 +40,7 @@ func main() { }) if err != nil { var e *sdkerrors.V2ErrorResponse - assert.Always(!errors.As(err, &e), "no internal server error when committing transaction", internal.Details{ + assert.Always(errors.As(err, &e) && e.ErrorCode == components.V2ErrorsEnumInternal, "no internal server error when committing transaction", internal.Details{ "ledger": ledger, "error": err, }) @@ -74,7 +74,7 @@ func RunTx( func RandomPostings() []components.V2Posting { postings := []components.V2Posting{} - for range random.GetRandom()%20 { + for range random.GetRandom()%20+1 { source := internal.GetRandomAddress() destination := internal.GetRandomAddress() amount := internal.RandomBigInt() From 47401f6d93509d2d999f8d87df13fedf8e7d9390 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 23 Sep 2025 17:36:56 +0200 Subject: [PATCH 50/66] workload fixes --- test/antithesis/workload/bin/cmds/eventually_correct/main.go | 5 +---- .../workload/bin/cmds/parallel_driver_transactions/main.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 4cab389ffc..8fb1419688 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -113,7 +113,7 @@ func checkSequentialTxIDs(ctx context.Context, client *client.Formance, ledger s Ledger: ledger, Cursor: next, }) - assert.Sometimes(err != nil, "Client can list transactions", internal.Details{ + assert.Sometimes(err == nil, "Client can list transactions", internal.Details{ "error": err, }) if err != nil { @@ -129,9 +129,6 @@ func checkSequentialTxIDs(ctx context.Context, client *client.Formance, ledger s } for _, tx := range transactions.V2TransactionsCursorResponse.Cursor.Data { expectedTxId.Sub(expectedTxId, big.NewInt(1)) - if tx.ID.Cmp(expectedTxId) != 0 { - panic(fmt.Sprintf("oop: expected %v and got %v", expectedTxId, tx.ID)) - } assert.Always(tx.ID.Cmp(expectedTxId) == 0, "txId should be sequential", internal.Details{ "expected": expectedTxId, "actual": tx.ID, diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 03c0ec66bb..33c27a1f32 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -40,7 +40,7 @@ func main() { }) if err != nil { var e *sdkerrors.V2ErrorResponse - assert.Always(errors.As(err, &e) && e.ErrorCode == components.V2ErrorsEnumInternal, "no internal server error when committing transaction", internal.Details{ + assert.Always(errors.As(err, &e) && e.ErrorCode == components.V2ErrorsEnumInsufficientFund, "no internal server error when committing transaction", internal.Details{ "ledger": ledger, "error": err, }) From c40afec3b445cb34aa8f5700cfbcc75aac1846c8 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 24 Sep 2025 12:43:27 +0200 Subject: [PATCH 51/66] more assertion details --- .../bin/cmds/anytime_version_upgrade/main.go | 1 + .../bin/cmds/eventually_correct/main.go | 3 ++ .../cmds/parallel_driver_transactions/main.go | 33 ++++++++++--------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go index 693ba71bd3..6a527b26d1 100644 --- a/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go +++ b/test/antithesis/workload/bin/cmds/anytime_version_upgrade/main.go @@ -53,5 +53,6 @@ func main() { assert.Sometimes(err == nil, "stack0-ledger should successfully be updated", internal.Details{ "ledger": res, + "error": err, }) } diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 8fb1419688..2a5c8e0f52 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -79,6 +79,7 @@ func checkAccountBalances(ctx context.Context, client *client.Formance, ledger s Address: address, }) assert.Sometimes(err != nil, "Client can aggregate account balances", internal.Details{ + "ledger": ledger, "error": err, }) if err != nil { @@ -89,11 +90,13 @@ func checkAccountBalances(ctx context.Context, client *client.Formance, ledger s balance := new(big.Int).Set(volume.Input) balance.Sub(balance, volume.Output) assert.Always(balance.Cmp(volume.Balance) == 0, "Reported balance and volumes should be consistent", internal.Details{ + "ledger": ledger, "address": address, "asset": asset, "volume": volume, }) assert.Always(volume.Balance.Cmp(zero) != -1, "Balance should stay positive when no overdraft is allowed", internal.Details{ + "ledger": ledger, "address": address, "asset": asset, "volume": volume, diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 33c27a1f32..6020ef8e8c 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -34,17 +34,7 @@ func main() { for range count { pool.Submit(func() { - _, err := RunTx(ctx, client, RandomPostings(), ledger) - assert.Sometimes(err == nil, "transaction was committed successfully", internal.Details{ - "ledger": ledger, - }) - if err != nil { - var e *sdkerrors.V2ErrorResponse - assert.Always(errors.As(err, &e) && e.ErrorCode == components.V2ErrorsEnumInsufficientFund, "no internal server error when committing transaction", internal.Details{ - "ledger": ledger, - "error": err, - }) - } + CreateTransaction(ctx, client, ledger) }) } @@ -55,12 +45,12 @@ func main() { type Postings []components.V2Posting -func RunTx( +func CreateTransaction( ctx context.Context, client *client.Formance, - postings Postings, ledger string, -) (*operations.V2CreateTransactionResponse, error) { +) { + postings := RandomPostings() res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: ledger, V2PostTransaction: components.V2PostTransaction{ @@ -68,7 +58,20 @@ func RunTx( }, }) - return res, err + assert.Sometimes(err == nil, "transaction was committed successfully", internal.Details{ + "ledger": ledger, + "postings": postings, + "error": err, + }) + if err != nil { + var e *sdkerrors.V2ErrorResponse + assert.Always(errors.As(err, &e) && e.ErrorCode == components.V2ErrorsEnumInsufficientFund, "no internal server error when committing transaction", internal.Details{ + "ledger": ledger, + "postings": postings, + "response": res, + "error": err, + }) + } } func RandomPostings() []components.V2Posting { From a59cf2f7c2426d05cec8b34d3f27badf81883601 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Mon, 29 Sep 2025 17:17:27 +0200 Subject: [PATCH 52/66] fix non-determinism & missing assertion --- test/antithesis/Justfile | 4 ++-- .../workload/bin/cmds/eventually_correct/main.go | 7 ++++--- .../bin/cmds/parallel_driver_ledger_create/main.go | 4 ++-- .../bin/cmds/parallel_driver_transactions/main.go | 12 +----------- test/antithesis/workload/internal/utils.go | 3 +-- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 221fab0093..fa7170e0e3 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -6,7 +6,7 @@ run-6min: requirements-build "custom.duration": "0.1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:k8s_test", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:$LEDGER_LATEST_TAG" \ } \ }' @@ -18,7 +18,7 @@ run-1h: requirements-build "custom.duration": "1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:k8s_test", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:k8s_test" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:$LEDGER_LATEST_TAG" \ } \ }' diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 2a5c8e0f52..95b93e499c 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -5,7 +5,6 @@ import ( "fmt" "log" "math/big" - "os" "sync" "github.com/antithesishq/antithesis-sdk-go/assert" @@ -22,9 +21,11 @@ func main() { ledgers, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{}) + assert.Sometimes(err == nil, "error listing ledgers", internal.Details { + "error": err, + }) if err != nil { - log.Printf("error listing ledgers: %s", err) - os.Exit(1) + return } wg := sync.WaitGroup{} diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index 8dfc738394..f3538c1cf5 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -4,9 +4,9 @@ import ( "context" "fmt" "log" - "math/rand" "github.com/antithesishq/antithesis-sdk-go/assert" + "github.com/antithesishq/antithesis-sdk-go/random" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -14,7 +14,7 @@ func main() { log.Println("composer: parallel_driver_ledger_create") ctx := context.Background() client := internal.NewClient() - id := rand.Intn(1e6) + id := random.GetRandom()%1e6 ledger := fmt.Sprintf("ledger-%d", id) res, err := internal.CreateLedger( diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 6020ef8e8c..078d64f52f 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -77,7 +77,7 @@ func CreateTransaction( func RandomPostings() []components.V2Posting { postings := []components.V2Posting{} - for range random.GetRandom()%20+1 { + for range random.GetRandom()%2+1 { source := internal.GetRandomAddress() destination := internal.GetRandomAddress() amount := internal.RandomBigInt() @@ -93,13 +93,3 @@ func RandomPostings() []components.V2Posting { return postings } - -func Sequence() []Postings { - postings := []Postings{} - - for i := 0; i < 10; i++ { - postings = append(postings, RandomPostings()) - } - - return postings -} diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 566afaebf1..44ba40e611 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "math/big" - "math/rand" "net/http" "os" @@ -101,7 +100,7 @@ func GetRandomLedger(ctx context.Context, client *client.Formance) (string, erro return "", fmt.Errorf("no ledgers found") } - randomIndex := rand.Intn(len(ledgers)) + randomIndex := random.GetRandom()%uint64(len(ledgers)) return ledgers[randomIndex], nil } From 24a0a1a26064316dd5cabfb392731351a05da127 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Wed, 1 Oct 2025 12:35:32 +0200 Subject: [PATCH 53/66] cleanup --- .github/workflows/antithesis_daily.yml | 4 ---- go.mod | 2 +- go.sum | 2 ++ internal/storage/driver/driver.go | 4 ---- test/antithesis/Justfile | 6 +++--- test/antithesis/config/Justfile | 1 - .../bin/cmds/eventually_correct/main.go | 4 +--- .../cmds/parallel_driver_transactions/main.go | 13 +------------ test/antithesis/workload/datagen/example.json | 3 --- test/antithesis/workload/datagen/main.go | 17 ----------------- test/antithesis/workload/go.mod | 2 +- test/antithesis/workload/go.sum | 2 ++ test/antithesis/workload/internal/utils.go | 2 +- 13 files changed, 12 insertions(+), 50 deletions(-) delete mode 100644 test/antithesis/workload/datagen/example.json delete mode 100644 test/antithesis/workload/datagen/main.go diff --git a/.github/workflows/antithesis_daily.yml b/.github/workflows/antithesis_daily.yml index 0addf78b23..9118a21332 100644 --- a/.github/workflows/antithesis_daily.yml +++ b/.github/workflows/antithesis_daily.yml @@ -6,9 +6,6 @@ on: description: "Run Antithesis tests after pushing images" type: boolean default: true - # push: - # branches: - # - main pull_request: types: [opened, synchronize, reopened] paths: @@ -77,7 +74,6 @@ jobs: just requirements-build - name: Run Antithesis Tests - # if: ${{ github.event_name == 'workflow_dispatch' && inputs.run_tests == true }} uses: antithesishq/antithesis-trigger-action@v0.8 with: notebook_name: formance-k8s diff --git a/go.mod b/go.mod index 85a21bedaf..b8306fffa1 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ replace google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215 => google. require ( github.com/ThreeDotsLabs/watermill v1.4.7 github.com/alitto/pond v1.9.2 - github.com/antithesishq/antithesis-sdk-go v0.4.3 + github.com/antithesishq/antithesis-sdk-go v0.5.0 github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20250630131328-58d95d85e994 diff --git a/go.sum b/go.sum index 1d7972ee24..f1f0078360 100644 --- a/go.sum +++ b/go.sum @@ -36,6 +36,8 @@ github.com/antithesishq/antithesis-sdk-go v0.4.3-default-no-op h1:+OSa/t11TFhqfr github.com/antithesishq/antithesis-sdk-go v0.4.3-default-no-op/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antithesishq/antithesis-sdk-go v0.4.3 h1:a2hGdDogClzHzFu20r1z0tzD6zwSWUipiaerAjZVP90= github.com/antithesishq/antithesis-sdk-go v0.4.3/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= +github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= +github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index ba6b882a77..18374e9a49 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -55,14 +55,10 @@ If any step fails, the entire transaction is rolled back, preventing partial sta func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgerstore.Store, error) { var ret *ledgerstore.Store - // Run the entire ledger creation process in a transaction for atomicity - // This ensures that either all steps succeed or none do (preventing partial state) err := d.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { systemStore := d.systemStoreFactory.Create(tx) - // Step 1: Create the ledger record in the system store if err := systemStore.CreateLedger(ctx, l); err != nil { - // Handle the case where the ledger already exists if errors.Is(postgres.ResolveError(err), postgres.ErrConstraintsFailed{}) { return systemstore.ErrLedgerAlreadyExists } diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index fa7170e0e3..1f75c40a1c 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -1,4 +1,4 @@ -run-6min: requirements-build +run-6min: #requirements-build curl --fail \ --user "formance:$ANTITHESIS_PASSWORD" \ -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ @@ -6,7 +6,7 @@ run-6min: requirements-build "custom.duration": "0.1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:k8s_test", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:$LEDGER_LATEST_TAG" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_LATEST_TAG"'" \ } \ }' @@ -18,7 +18,7 @@ run-1h: requirements-build "custom.duration": "1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:k8s_test", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:$LEDGER_LATEST_TAG" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:"'"$LEDGER_LATEST_TAG"'" \ } \ }' diff --git a/test/antithesis/config/Justfile b/test/antithesis/config/Justfile index 2c52fa8ec7..86fe05a5e4 100644 --- a/test/antithesis/config/Justfile +++ b/test/antithesis/config/Justfile @@ -6,7 +6,6 @@ build-manifest: cat manifests/postgres.yaml >> tmp/resources.yaml echo "---" >> tmp/resources.yaml helm template regions oci://ghcr.io/formancehq/helm/regions --version 2.15.2 --namespace formance-systems >> tmp/resources.yaml - # helm template operator oci://ghcr.io/formancehq/helm/operator-crds --version v2.8.0 --namespace formance-systems >> tmp/resources.yaml echo "---" >> tmp/resources.yaml cat manifests/stack.yaml >> tmp/resources.yaml echo "---" >> tmp/resources.yaml diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 95b93e499c..86a70bb912 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -21,9 +21,7 @@ func main() { ledgers, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{}) - assert.Sometimes(err == nil, "error listing ledgers", internal.Details { - "error": err, - }) + assert.Sometimes(err == nil, "error listing ledgers", internal.Details {}) if err != nil { return } diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index 078d64f52f..ccd892c26a 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -2,7 +2,6 @@ package main import ( "context" - "errors" "log" "github.com/alitto/pond" @@ -11,7 +10,6 @@ import ( "github.com/formancehq/ledger/pkg/client" "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" - "github.com/formancehq/ledger/pkg/client/models/sdkerrors" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -51,7 +49,7 @@ func CreateTransaction( ledger string, ) { postings := RandomPostings() - res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ + _, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{ Ledger: ledger, V2PostTransaction: components.V2PostTransaction{ Postings: postings, @@ -63,15 +61,6 @@ func CreateTransaction( "postings": postings, "error": err, }) - if err != nil { - var e *sdkerrors.V2ErrorResponse - assert.Always(errors.As(err, &e) && e.ErrorCode == components.V2ErrorsEnumInsufficientFund, "no internal server error when committing transaction", internal.Details{ - "ledger": ledger, - "postings": postings, - "response": res, - "error": err, - }) - } } func RandomPostings() []components.V2Posting { diff --git a/test/antithesis/workload/datagen/example.json b/test/antithesis/workload/datagen/example.json deleted file mode 100644 index ec2649bb49..0000000000 --- a/test/antithesis/workload/datagen/example.json +++ /dev/null @@ -1,3 +0,0 @@ -[ - {} -] \ No newline at end of file diff --git a/test/antithesis/workload/datagen/main.go b/test/antithesis/workload/datagen/main.go deleted file mode 100644 index a25249ac83..0000000000 --- a/test/antithesis/workload/datagen/main.go +++ /dev/null @@ -1,17 +0,0 @@ -package main - -import ( - "fmt" - "math/rand" -) - -type Sequence struct { -} - -func Account() string { - return fmt.Sprintf("%d", rand.Intn(10e9)) -} - -func main() { - fmt.Println(Account()) -} diff --git a/test/antithesis/workload/go.mod b/test/antithesis/workload/go.mod index 394b27a5fc..69fab7afa6 100644 --- a/test/antithesis/workload/go.mod +++ b/test/antithesis/workload/go.mod @@ -8,7 +8,7 @@ replace github.com/formancehq/ledger/pkg/client => ../../../pkg/client require ( github.com/alitto/pond v1.8.3 - github.com/antithesishq/antithesis-sdk-go v0.4.2 + github.com/antithesishq/antithesis-sdk-go v0.5.0 github.com/formancehq/go-libs/v2 v2.0.1-0.20241114125605-4a3e447246a9 github.com/formancehq/ledger/pkg/client v0.0.0-00010101000000-000000000000 golang.org/x/sync v0.12.0 // indirect; indirect, for singleflight package diff --git a/test/antithesis/workload/go.sum b/test/antithesis/workload/go.sum index 80366909ee..16bb7b7572 100644 --- a/test/antithesis/workload/go.sum +++ b/test/antithesis/workload/go.sum @@ -2,6 +2,8 @@ github.com/alitto/pond v1.8.3 h1:ydIqygCLVPqIX/USe5EaV/aSRXTRXDEI9JwuDdu+/xs= github.com/alitto/pond v1.8.3/go.mod h1:CmvIIGd5jKLasGI3D87qDkQxjzChdKMmnXMg3fG6M6Q= github.com/antithesishq/antithesis-sdk-go v0.4.2 h1:cYLNRnojCYp6rKoLKdK6M9UKi9EahFXBtF6WR1vc6V0= github.com/antithesishq/antithesis-sdk-go v0.4.2/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= +github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= +github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index 44ba40e611..e66c1c9830 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -16,7 +16,7 @@ import ( "github.com/formancehq/ledger/pkg/client/retry" ) -const USER_ACCOUNT_COUNT uint64 = 1000; +const USER_ACCOUNT_COUNT uint64 = 32; type Details map[string]any From 015ca6acf40e5accb6d7b5e54ff6bbc6b7eed194 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 2 Oct 2025 11:45:25 +0200 Subject: [PATCH 54/66] remove earthfiles --- Earthfile | 2 +- pkg/client/Earthfile | 8 --- test/antithesis/Justfile | 2 +- test/antithesis/image/Dockerfile.ledger | 12 +++++ test/antithesis/image/Earthfile | 44 ----------------- test/antithesis/image/Justfile | 17 +++++++ test/antithesis/workload/Dockerfile.workload | 5 ++ test/antithesis/workload/Earthfile | 51 -------------------- test/antithesis/workload/Justfile | 28 +++++++++++ 9 files changed, 64 insertions(+), 105 deletions(-) delete mode 100644 pkg/client/Earthfile create mode 100644 test/antithesis/image/Dockerfile.ledger delete mode 100644 test/antithesis/image/Earthfile create mode 100644 test/antithesis/image/Justfile create mode 100644 test/antithesis/workload/Dockerfile.workload delete mode 100644 test/antithesis/workload/Earthfile create mode 100644 test/antithesis/workload/Justfile diff --git a/Earthfile b/Earthfile index e8490a1dd8..0143d546b0 100644 --- a/Earthfile +++ b/Earthfile @@ -50,4 +50,4 @@ deploy: RUN kubectl patch Versions.formance.com default -p "{\"spec\":{\"ledger\": \"${tag}\"}}" --type=merge deploy-staging: - BUILD --pass-args core+deploy-staging \ No newline at end of file + BUILD --pass-args core+deploy-staging diff --git a/pkg/client/Earthfile b/pkg/client/Earthfile deleted file mode 100644 index a17835da3f..0000000000 --- a/pkg/client/Earthfile +++ /dev/null @@ -1,8 +0,0 @@ -VERSION 0.7 - -FROM --platform=linux/amd64 golang:1.22.2 - -client: - FROM scratch - COPY . /client - SAVE ARTIFACT /client client \ No newline at end of file diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 1f75c40a1c..e3522940d5 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -24,4 +24,4 @@ run-1h: requirements-build requirements-build: just config/push - earthly --push ./workload+build --ANTITHESIS_REPOSITORY="$ANTITHESIS_REPOSITORY" --LEDGER_LATEST_TAG="$LEDGER_LATEST_TAG" + just workload/push diff --git a/test/antithesis/image/Dockerfile.ledger b/test/antithesis/image/Dockerfile.ledger new file mode 100644 index 0000000000..3836dbbe00 --- /dev/null +++ b/test/antithesis/image/Dockerfile.ledger @@ -0,0 +1,12 @@ +FROM ubuntu:latest + +RUN apt-get update -y && apt-get install -y postgresql-client curl + +COPY customer/ledger /bin/ledger +COPY symbols/ /symbols +COPY entrypoint.sh /bin/entrypoint.sh + +RUN chmod 777 /bin/entrypoint.sh + +ENTRYPOINT ["/bin/entrypoint.sh"] +EXPOSE 8080 diff --git a/test/antithesis/image/Earthfile b/test/antithesis/image/Earthfile deleted file mode 100644 index 3163dbd8ad..0000000000 --- a/test/antithesis/image/Earthfile +++ /dev/null @@ -1,44 +0,0 @@ -VERSION 0.8 - -IMPORT github.com/formancehq/earthly:tags/v0.19.1 AS core - -FROM core+base-image - -CACHE --sharing=shared --id go-mod-cache /go/pkg/mod -CACHE --sharing=shared --id go-cache /root/.cache/go-build - -compile: - FROM --platform=linux/amd64 golang:1.24.6 - CACHE --sharing=shared --id go-mod-cache /go/pkg/mod - CACHE --sharing=shared --id go-cache /root/.cache/go-build - - COPY ../../..+sources/src /src - RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - WORKDIR /src - - RUN go mod download - RUN mkdir -p /ledger_instrumented - RUN /go/bin/antithesis-go-instrumentor . /ledger_instrumented - - WORKDIR /ledger_instrumented/customer - RUN go build -race -o ledger - - SAVE ARTIFACT /ledger_instrumented/customer/ledger - SAVE ARTIFACT /ledger_instrumented/symbols - -build: - FROM --platform=linux/amd64 ubuntu:latest - RUN apt-get update -y && apt-get install -y postgresql-client curl - - COPY (+compile/ledger) /bin/ledger - COPY (+compile/symbols) /symbols - COPY entrypoint.sh /bin/entrypoint.sh - - RUN chmod 777 /bin/entrypoint.sh - - ENTRYPOINT ["/bin/entrypoint.sh"] - EXPOSE 8080 - - ARG --required LEDGER_TAG - - SAVE IMAGE --push ghcr.io/formancehq/ledger-instrumented:${LEDGER_TAG} diff --git a/test/antithesis/image/Justfile b/test/antithesis/image/Justfile new file mode 100644 index 0000000000..a5f7f89c99 --- /dev/null +++ b/test/antithesis/image/Justfile @@ -0,0 +1,17 @@ +push: + #!/usr/bin/env bash + + set -euxo pipefail + tmpdir=$(mktemp -d) + trap 'rm -rf $tmpdir' EXIT + scriptdir=$(pwd) + + mkdir -p "$tmpdir/ledger_instrumented" + antithesis-go-instrumentor ../../../ "$tmpdir/ledger_instrumented" + cd "$tmpdir/ledger_instrumented/customer" + go build -race -o ledger + cd "$tmpdir/ledger_instrumented" + cp "$scriptdir/entrypoint.sh" entrypoint.sh + + docker build . -f "$scriptdir/Dockerfile.ledger" -t "ghcr.io/formancehq/ledger-instrumented:$LEDGER_TAG" + docker push "ghcr.io/formancehq/ledger-instrumented:$LEDGER_TAG" diff --git a/test/antithesis/workload/Dockerfile.workload b/test/antithesis/workload/Dockerfile.workload new file mode 100644 index 0000000000..acb39022d9 --- /dev/null +++ b/test/antithesis/workload/Dockerfile.workload @@ -0,0 +1,5 @@ +FROM ubuntu:latest + +COPY init /init +COPY cmds/* /opt/antithesis/test/v1/main/ +COPY ledger_latest_tag /ledger_latest_tag diff --git a/test/antithesis/workload/Earthfile b/test/antithesis/workload/Earthfile deleted file mode 100644 index d88b10d413..0000000000 --- a/test/antithesis/workload/Earthfile +++ /dev/null @@ -1,51 +0,0 @@ -VERSION 0.7 - -FROM --platform=linux/amd64 golang:1.24.6 - -CACHE --sharing=shared --id go-mod-cache /go/pkg/mod -CACHE --sharing=shared --id go-cache /root/.cache/go-build - -sources: - WORKDIR /src/test/antithesis/workload - COPY go.* . - COPY --dir bin internal . - - SAVE ARTIFACT /src - -compile: - CACHE --id go-mod-cache /go/pkg/mod - CACHE --id go-cache /root/.cache/go-build - - RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - - COPY +sources/src /src - - WORKDIR /src/test/antithesis/workload - COPY --dir ../../../pkg/client+client/client ../../../pkg/client - RUN mkdir -p /workload_instrumented - RUN mkdir -p /out/cmds - - RUN antithesis-go-instrumentor -assert_only . - RUN go build -o /out/init ./bin/init - - FOR file IN $(ls bin/cmds) - RUN go build -o /out/cmds/$file ./bin/cmds/$file - END - - SAVE ARTIFACT /out - -build: - FROM --platform=linux/amd64 ubuntu:latest - COPY (+compile/out/init) /init - ENTRYPOINT ["/init"] - - RUN apt-get update && apt-get install -y curl - - COPY (+compile/out/cmds/*) /opt/antithesis/test/v1/main/ - - ARG --required ANTITHESIS_REPOSITORY - ARG --required LEDGER_LATEST_TAG - - RUN echo ${LEDGER_LATEST_TAG} > /ledger_latest_tag - - SAVE IMAGE --push --no-manifest-list ${ANTITHESIS_REPOSITORY}/workload:latest diff --git a/test/antithesis/workload/Justfile b/test/antithesis/workload/Justfile new file mode 100644 index 0000000000..9a36a7af67 --- /dev/null +++ b/test/antithesis/workload/Justfile @@ -0,0 +1,28 @@ +push: + #!/usr/bin/env bash + + set -euxo pipefail + tmpdir=$(mktemp -d) + trap 'rm -rf $tmpdir' EXIT + scriptdir=$(pwd) + + mkdir -p "$tmpdir/test/antithesis/workload" + mkdir -p "$tmpdir/pkg" + + cp -r go.* bin internal "$tmpdir/test/antithesis/workload" + cp -r ../../../pkg/client "$tmpdir/pkg/" + + cd "$tmpdir/test/antithesis/workload" + + antithesis-go-instrumentor -assert_only . + + mkdir -p out + go build -o ./out/init ./bin/init + for file in $(ls ./bin/cmds/); do \ + go build -o ./out/cmds/$file ./bin/cmds/$file; \ + done + + echo "$LEDGER_LATEST_TAG" > ./out/ledger_latest_tag + + docker build ./out -f "$scriptdir/Dockerfile.workload" -t "$ANTITHESIS_REPOSITORY/workload:latest" + docker push "$ANTITHESIS_REPOSITORY/workload:latest" From 42073fa81674985652fe704fa56c1a295bd5ff2b Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 2 Oct 2025 14:12:16 +0200 Subject: [PATCH 55/66] install missing instrumentor --- .github/workflows/antithesis_release.yml | 4 +++- test/antithesis/image/Justfile | 4 +++- test/antithesis/workload/Justfile | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/antithesis_release.yml b/.github/workflows/antithesis_release.yml index d5c5ec91cc..b23fa46004 100644 --- a/.github/workflows/antithesis_release.yml +++ b/.github/workflows/antithesis_release.yml @@ -48,6 +48,8 @@ jobs: echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin - name: Build and Push Config Image + env: + LEDGER_TAG: ${{ env.GITHUB_REF_NAME }} run: | cd test/antithesis/image - earthly --push ./image+build --LEDGER_TAG="${{ env.GITHUB_REF_NAME }}" + just push diff --git a/test/antithesis/image/Justfile b/test/antithesis/image/Justfile index a5f7f89c99..510b8e5435 100644 --- a/test/antithesis/image/Justfile +++ b/test/antithesis/image/Justfile @@ -1,6 +1,8 @@ push: #!/usr/bin/env bash - + + go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + set -euxo pipefail tmpdir=$(mktemp -d) trap 'rm -rf $tmpdir' EXIT diff --git a/test/antithesis/workload/Justfile b/test/antithesis/workload/Justfile index 9a36a7af67..2d20df9687 100644 --- a/test/antithesis/workload/Justfile +++ b/test/antithesis/workload/Justfile @@ -1,6 +1,8 @@ push: #!/usr/bin/env bash - + + go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + set -euxo pipefail tmpdir=$(mktemp -d) trap 'rm -rf $tmpdir' EXIT From 2e854a9a41ef66818707ffdfecb803ffea88f9b2 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 2 Oct 2025 14:33:53 +0200 Subject: [PATCH 56/66] fix workflow --- .github/workflows/antithesis_daily.yml | 8 +++++--- .github/workflows/antithesis_release.yml | 8 +++++--- test/antithesis/Justfile | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/antithesis_daily.yml b/.github/workflows/antithesis_daily.yml index 9118a21332..1aac9eb4e3 100644 --- a/.github/workflows/antithesis_daily.yml +++ b/.github/workflows/antithesis_daily.yml @@ -69,9 +69,11 @@ jobs: echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin - name: Build and Push Config Image - run: | - cd test/antithesis - just requirements-build + run: > + /nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes" + develop --impure --command just + --justfile ./test/antithesis/image/Justfile + requirements-push - name: Run Antithesis Tests uses: antithesishq/antithesis-trigger-action@v0.8 diff --git a/.github/workflows/antithesis_release.yml b/.github/workflows/antithesis_release.yml index b23fa46004..c1b5e05f86 100644 --- a/.github/workflows/antithesis_release.yml +++ b/.github/workflows/antithesis_release.yml @@ -50,6 +50,8 @@ jobs: - name: Build and Push Config Image env: LEDGER_TAG: ${{ env.GITHUB_REF_NAME }} - run: | - cd test/antithesis/image - just push + run: > + /nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes" + develop --impure --command just + --justfile ./test/antithesis/image/Justfile + push diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index e3522940d5..3c5a725f65 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -1,4 +1,4 @@ -run-6min: #requirements-build +run-6min: requirements-push curl --fail \ --user "formance:$ANTITHESIS_PASSWORD" \ -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ @@ -10,7 +10,7 @@ run-6min: #requirements-build } \ }' -run-1h: requirements-build +run-1h: requirements-push curl --fail \ --user "formance:$ANTITHESIS_PASSWORD" \ -X POST https://formance.antithesis.com/api/v1/launch_experiment/formance-k8s -d '{ \ @@ -22,6 +22,6 @@ run-1h: requirements-build } \ }' -requirements-build: +requirements-push: just config/push just workload/push From 235e5a078ae5e7ce5f85b737e8374abdaacebbf4 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 2 Oct 2025 15:20:04 +0200 Subject: [PATCH 57/66] fix workflow --- .github/workflows/antithesis_daily.yml | 7 ++----- .github/workflows/antithesis_release.yml | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/antithesis_daily.yml b/.github/workflows/antithesis_daily.yml index 1aac9eb4e3..acb1b0c590 100644 --- a/.github/workflows/antithesis_daily.yml +++ b/.github/workflows/antithesis_daily.yml @@ -69,11 +69,8 @@ jobs: echo '${{ secrets.ANTITHESIS_JSON_KEY }}' | docker login -u _json_key https://us-central1-docker.pkg.dev --password-stdin - name: Build and Push Config Image - run: > - /nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes" - develop --impure --command just - --justfile ./test/antithesis/image/Justfile - requirements-push + run: | + nix develop --impure --command just --justfile ./test/antithesis/Justfile requirements-push - name: Run Antithesis Tests uses: antithesishq/antithesis-trigger-action@v0.8 diff --git a/.github/workflows/antithesis_release.yml b/.github/workflows/antithesis_release.yml index c1b5e05f86..4cffe0e2e0 100644 --- a/.github/workflows/antithesis_release.yml +++ b/.github/workflows/antithesis_release.yml @@ -50,8 +50,5 @@ jobs: - name: Build and Push Config Image env: LEDGER_TAG: ${{ env.GITHUB_REF_NAME }} - run: > - /nix/var/nix/profiles/default/bin/nix --extra-experimental-features "nix-command" --extra-experimental-features "flakes" - develop --impure --command just - --justfile ./test/antithesis/image/Justfile - push + run: | + nix develop --impure --command just --justfile ./test/antithesis/image/Justfile push From 1e0ff72cba0c21c292ac864991c6abe88143d2b7 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 2 Oct 2025 15:47:37 +0200 Subject: [PATCH 58/66] fix workflow --- .github/workflows/antithesis_daily.yml | 2 +- test/antithesis/Justfile | 4 ++-- test/antithesis/config/Justfile | 4 ++-- test/antithesis/image/Justfile | 5 +++-- test/antithesis/workload/Justfile | 5 +++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/antithesis_daily.yml b/.github/workflows/antithesis_daily.yml index acb1b0c590..e1cbd0eb10 100644 --- a/.github/workflows/antithesis_daily.yml +++ b/.github/workflows/antithesis_daily.yml @@ -83,5 +83,5 @@ jobs: # images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" # temporary: remove this when support for multiple image versions is added images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" - config_image: "antithesis-config:k8s_test" + config_image: "antithesis-config:daily_run" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 3c5a725f65..860b53e8e8 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -5,7 +5,7 @@ run-6min: requirements-push "params": { \ "custom.duration": "0.1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ - "antithesis.config_image": "antithesis-config:k8s_test", \ + "antithesis.config_image": "antithesis-config:daily_run", \ "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_LATEST_TAG"'" \ } \ }' @@ -17,7 +17,7 @@ run-1h: requirements-push "params": { \ "custom.duration": "1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ - "antithesis.config_image": "antithesis-config:k8s_test", \ + "antithesis.config_image": "antithesis-config:daily_run", \ "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:"'"$LEDGER_LATEST_TAG"'" \ } \ }' diff --git a/test/antithesis/config/Justfile b/test/antithesis/config/Justfile index 86fe05a5e4..586bedb288 100644 --- a/test/antithesis/config/Justfile +++ b/test/antithesis/config/Justfile @@ -14,5 +14,5 @@ build-manifest: cat manifests/workload.yaml >> tmp/resources.yaml push: build-manifest - docker build -f Dockerfile.config -t $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test . - docker push $ANTITHESIS_REPOSITORY/antithesis-config:k8s_test + docker build -f Dockerfile.config -t $ANTITHESIS_REPOSITORY/antithesis-config:daily_run . + docker push $ANTITHESIS_REPOSITORY/antithesis-config:daily_run diff --git a/test/antithesis/image/Justfile b/test/antithesis/image/Justfile index 510b8e5435..e287e8ddd2 100644 --- a/test/antithesis/image/Justfile +++ b/test/antithesis/image/Justfile @@ -1,15 +1,16 @@ push: #!/usr/bin/env bash + set -euxo pipefail + go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - set -euxo pipefail tmpdir=$(mktemp -d) trap 'rm -rf $tmpdir' EXIT scriptdir=$(pwd) mkdir -p "$tmpdir/ledger_instrumented" - antithesis-go-instrumentor ../../../ "$tmpdir/ledger_instrumented" + $GOPATH/bin/antithesis-go-instrumentor ../../../ "$tmpdir/ledger_instrumented" cd "$tmpdir/ledger_instrumented/customer" go build -race -o ledger cd "$tmpdir/ledger_instrumented" diff --git a/test/antithesis/workload/Justfile b/test/antithesis/workload/Justfile index 2d20df9687..b417038cb4 100644 --- a/test/antithesis/workload/Justfile +++ b/test/antithesis/workload/Justfile @@ -1,9 +1,10 @@ push: #!/usr/bin/env bash + + set -euxo pipefail go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - set -euxo pipefail tmpdir=$(mktemp -d) trap 'rm -rf $tmpdir' EXIT scriptdir=$(pwd) @@ -16,7 +17,7 @@ push: cd "$tmpdir/test/antithesis/workload" - antithesis-go-instrumentor -assert_only . + $GOPATH/bin/antithesis-go-instrumentor -assert_only . mkdir -p out go build -o ./out/init ./bin/init From 14785dbc219b2f66ee78057f5131331d08c71048 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 2 Oct 2025 16:54:27 +0200 Subject: [PATCH 59/66] fix workflow attempt --- .github/workflows/antithesis_daily.yml | 10 ++-------- .github/workflows/antithesis_release.yml | 10 ++-------- test/antithesis/image/Justfile | 4 ++-- test/antithesis/workload/Justfile | 6 ++---- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/.github/workflows/antithesis_daily.yml b/.github/workflows/antithesis_daily.yml index e1cbd0eb10..d28cb78a45 100644 --- a/.github/workflows/antithesis_daily.yml +++ b/.github/workflows/antithesis_daily.yml @@ -15,8 +15,8 @@ on: - cron: "0 10 * * *" jobs: - push-antithesis-images: - name: Push Images to Antithesis + trigger-daily-run: + name: Trigger daily run runs-on: shipfox-4vcpu-ubuntu-2404 env: ANTITHESIS_PASSWORD: ${{ secrets.ANTITHESIS_PASSWORD }} @@ -35,12 +35,6 @@ jobs: with: fetch-depth: 0 - - name: Setup Earthly - uses: earthly/actions-setup@v1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - version: "latest" - - name: Setup Just uses: extractions/setup-just@v3 with: diff --git a/.github/workflows/antithesis_release.yml b/.github/workflows/antithesis_release.yml index 4cffe0e2e0..bcd5575cd8 100644 --- a/.github/workflows/antithesis_release.yml +++ b/.github/workflows/antithesis_release.yml @@ -5,8 +5,8 @@ on: - "*" jobs: - push-antithesis-images: - name: Push Images to Antithesis + push-instrumented-ledger: + name: Push instrumented ledger runs-on: shipfox-4vcpu-ubuntu-2404 steps: - name: Checkout code @@ -14,12 +14,6 @@ jobs: with: fetch-depth: 0 - - name: Setup Earthly - uses: earthly/actions-setup@v1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - version: "latest" - - name: Setup Just uses: extractions/setup-just@v3 with: diff --git a/test/antithesis/image/Justfile b/test/antithesis/image/Justfile index e287e8ddd2..c0a267e8e5 100644 --- a/test/antithesis/image/Justfile +++ b/test/antithesis/image/Justfile @@ -3,14 +3,14 @@ push: set -euxo pipefail - go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest tmpdir=$(mktemp -d) trap 'rm -rf $tmpdir' EXIT scriptdir=$(pwd) mkdir -p "$tmpdir/ledger_instrumented" - $GOPATH/bin/antithesis-go-instrumentor ../../../ "$tmpdir/ledger_instrumented" + GOBIN=$(pwd) go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + ./antithesis-go-instrumentor ../../../ "$tmpdir/ledger_instrumented" cd "$tmpdir/ledger_instrumented/customer" go build -race -o ledger cd "$tmpdir/ledger_instrumented" diff --git a/test/antithesis/workload/Justfile b/test/antithesis/workload/Justfile index b417038cb4..bcf0060c15 100644 --- a/test/antithesis/workload/Justfile +++ b/test/antithesis/workload/Justfile @@ -2,9 +2,6 @@ push: #!/usr/bin/env bash set -euxo pipefail - - go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - tmpdir=$(mktemp -d) trap 'rm -rf $tmpdir' EXIT scriptdir=$(pwd) @@ -17,7 +14,8 @@ push: cd "$tmpdir/test/antithesis/workload" - $GOPATH/bin/antithesis-go-instrumentor -assert_only . + GOBIN=$(pwd) go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + ./antithesis-go-instrumentor -assert_only . mkdir -p out go build -o ./out/init ./bin/init From 16c0cdef5ec3f36c51ee9703420ce8db7b899fc3 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 2 Oct 2025 18:42:17 +0200 Subject: [PATCH 60/66] fix workload container --- test/antithesis/image/Justfile | 6 ++---- test/antithesis/workload/Dockerfile.workload | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/antithesis/image/Justfile b/test/antithesis/image/Justfile index c0a267e8e5..831be6596d 100644 --- a/test/antithesis/image/Justfile +++ b/test/antithesis/image/Justfile @@ -2,15 +2,13 @@ push: #!/usr/bin/env bash set -euxo pipefail - - tmpdir=$(mktemp -d) trap 'rm -rf $tmpdir' EXIT scriptdir=$(pwd) mkdir -p "$tmpdir/ledger_instrumented" - GOBIN=$(pwd) go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - ./antithesis-go-instrumentor ../../../ "$tmpdir/ledger_instrumented" + GOBIN="$tmpdir" go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + "$tmpdir/antithesis-go-instrumentor" ../../../ "$tmpdir/ledger_instrumented" cd "$tmpdir/ledger_instrumented/customer" go build -race -o ledger cd "$tmpdir/ledger_instrumented" diff --git a/test/antithesis/workload/Dockerfile.workload b/test/antithesis/workload/Dockerfile.workload index acb39022d9..2dff76e305 100644 --- a/test/antithesis/workload/Dockerfile.workload +++ b/test/antithesis/workload/Dockerfile.workload @@ -1,5 +1,11 @@ FROM ubuntu:latest + +RUN apt-get update && apt-get install -y curl + COPY init /init +ENTRYPOINT ["/init"] + COPY cmds/* /opt/antithesis/test/v1/main/ + COPY ledger_latest_tag /ledger_latest_tag From 160b453910f8cfd370be2bd1f480fd8b5c89b7ff Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Fri, 3 Oct 2025 13:43:58 +0200 Subject: [PATCH 61/66] fix workload/ledger builders --- internal/storage/driver/driver.go | 3 -- test/antithesis/image/Dockerfile | 35 ++++++++++++++++++++ test/antithesis/image/Dockerfile.ledger | 12 ------- test/antithesis/image/Justfile | 17 +--------- test/antithesis/workload/Dockerfile | 32 ++++++++++++++++++ test/antithesis/workload/Dockerfile.workload | 11 ------ test/antithesis/workload/Justfile | 28 +--------------- 7 files changed, 69 insertions(+), 69 deletions(-) create mode 100644 test/antithesis/image/Dockerfile delete mode 100644 test/antithesis/image/Dockerfile.ledger create mode 100644 test/antithesis/workload/Dockerfile delete mode 100644 test/antithesis/workload/Dockerfile.workload diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index 18374e9a49..af7c4f0c0f 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -101,18 +101,15 @@ func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgersto } } - // Step 4: Create a store for interacting with the ledger ret = d.ledgerStoreFactory.Create(b, *l) return nil }) - // If any error occurred during the transaction, resolve and return it if err != nil { return nil, postgres.ResolveError(err) } - // Return the created ledger store return ret, nil } diff --git a/test/antithesis/image/Dockerfile b/test/antithesis/image/Dockerfile new file mode 100644 index 0000000000..cdf0c76b9b --- /dev/null +++ b/test/antithesis/image/Dockerfile @@ -0,0 +1,35 @@ +# Compiler +FROM golang:1.24-trixie AS compiler + +RUN apt-get update && apt-get install -y bash git gcc + +WORKDIR /src/pkg/client +COPY pkg/client/go.mod pkg/client/go.sum ./ +RUN go mod download + +WORKDIR /src +COPY go.mod go.sum main.go ./ +COPY internal internal +COPY pkg pkg +COPY cmd cmd + +RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + +RUN mkdir /instrumented +RUN antithesis-go-instrumentor . /instrumented +WORKDIR /instrumented/customer +RUN go build -race -o ledger + +# Runner +FROM debian:trixie + +RUN apt-get update && apt-get install -y postgresql-client curl + +COPY --from=compiler /instrumented/customer/ledger /bin/ledger +COPY --from=compiler /instrumented/symbols/ /symbols +COPY test/antithesis/image/entrypoint.sh /bin/entrypoint.sh + +RUN chmod 777 /bin/entrypoint.sh + +ENTRYPOINT ["/bin/entrypoint.sh"] +EXPOSE 8080 diff --git a/test/antithesis/image/Dockerfile.ledger b/test/antithesis/image/Dockerfile.ledger deleted file mode 100644 index 3836dbbe00..0000000000 --- a/test/antithesis/image/Dockerfile.ledger +++ /dev/null @@ -1,12 +0,0 @@ -FROM ubuntu:latest - -RUN apt-get update -y && apt-get install -y postgresql-client curl - -COPY customer/ledger /bin/ledger -COPY symbols/ /symbols -COPY entrypoint.sh /bin/entrypoint.sh - -RUN chmod 777 /bin/entrypoint.sh - -ENTRYPOINT ["/bin/entrypoint.sh"] -EXPOSE 8080 diff --git a/test/antithesis/image/Justfile b/test/antithesis/image/Justfile index 831be6596d..ecaea46489 100644 --- a/test/antithesis/image/Justfile +++ b/test/antithesis/image/Justfile @@ -1,18 +1,3 @@ push: - #!/usr/bin/env bash - - set -euxo pipefail - tmpdir=$(mktemp -d) - trap 'rm -rf $tmpdir' EXIT - scriptdir=$(pwd) - - mkdir -p "$tmpdir/ledger_instrumented" - GOBIN="$tmpdir" go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - "$tmpdir/antithesis-go-instrumentor" ../../../ "$tmpdir/ledger_instrumented" - cd "$tmpdir/ledger_instrumented/customer" - go build -race -o ledger - cd "$tmpdir/ledger_instrumented" - cp "$scriptdir/entrypoint.sh" entrypoint.sh - - docker build . -f "$scriptdir/Dockerfile.ledger" -t "ghcr.io/formancehq/ledger-instrumented:$LEDGER_TAG" + docker build -f Dockerfile -t "ghcr.io/formancehq/ledger-instrumented:$LEDGER_TAG" ../../../ docker push "ghcr.io/formancehq/ledger-instrumented:$LEDGER_TAG" diff --git a/test/antithesis/workload/Dockerfile b/test/antithesis/workload/Dockerfile new file mode 100644 index 0000000000..1a76735729 --- /dev/null +++ b/test/antithesis/workload/Dockerfile @@ -0,0 +1,32 @@ +# Compiler +FROM golang:1.24-alpine3.22 AS compiler + +RUN go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest + +WORKDIR /src/test/antithesis/workload + +COPY test/antithesis/workload/go.* . +COPY test/antithesis/workload/bin ./bin +COPY test/antithesis/workload/internal ./internal +COPY pkg/client /src/pkg/client + +RUN antithesis-go-instrumentor -assert_only . + +RUN go build -o /init ./bin/init +RUN for file in $(ls ./bin/cmds/); do go build -o /cmds/$file ./bin/cmds/$file; done + +RUN antithesis-go-instrumentor -assert_only . + +# Runner +FROM alpine:3.22 + +RUN apk update && apk add --no-cache curl + +ARG LEDGER_LATEST_TAG + +COPY --from=compiler /init /init +ENTRYPOINT ["/init"] + +COPY --from=compiler cmds/* /opt/antithesis/test/v1/main/ + +RUN echo ${LEDGER_LATEST_TAG} /ledger_latest_tag diff --git a/test/antithesis/workload/Dockerfile.workload b/test/antithesis/workload/Dockerfile.workload deleted file mode 100644 index 2dff76e305..0000000000 --- a/test/antithesis/workload/Dockerfile.workload +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:latest - - -RUN apt-get update && apt-get install -y curl - -COPY init /init -ENTRYPOINT ["/init"] - -COPY cmds/* /opt/antithesis/test/v1/main/ - -COPY ledger_latest_tag /ledger_latest_tag diff --git a/test/antithesis/workload/Justfile b/test/antithesis/workload/Justfile index bcf0060c15..a04a8b0085 100644 --- a/test/antithesis/workload/Justfile +++ b/test/antithesis/workload/Justfile @@ -1,29 +1,3 @@ push: - #!/usr/bin/env bash - - set -euxo pipefail - tmpdir=$(mktemp -d) - trap 'rm -rf $tmpdir' EXIT - scriptdir=$(pwd) - - mkdir -p "$tmpdir/test/antithesis/workload" - mkdir -p "$tmpdir/pkg" - - cp -r go.* bin internal "$tmpdir/test/antithesis/workload" - cp -r ../../../pkg/client "$tmpdir/pkg/" - - cd "$tmpdir/test/antithesis/workload" - - GOBIN=$(pwd) go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@latest - ./antithesis-go-instrumentor -assert_only . - - mkdir -p out - go build -o ./out/init ./bin/init - for file in $(ls ./bin/cmds/); do \ - go build -o ./out/cmds/$file ./bin/cmds/$file; \ - done - - echo "$LEDGER_LATEST_TAG" > ./out/ledger_latest_tag - - docker build ./out -f "$scriptdir/Dockerfile.workload" -t "$ANTITHESIS_REPOSITORY/workload:latest" + docker build --build-arg LEDGER_LATEST_TAG="$LEDGER_LATEST_TAG" -f Dockerfile -t "$ANTITHESIS_REPOSITORY/workload:latest" ../../../ docker push "$ANTITHESIS_REPOSITORY/workload:latest" From e559f0c9382062b1116d00b320b2d9ebd7c480e4 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Fri, 3 Oct 2025 15:10:36 +0200 Subject: [PATCH 62/66] dockerfile typo --- test/antithesis/workload/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/antithesis/workload/Dockerfile b/test/antithesis/workload/Dockerfile index 1a76735729..896fa20a58 100644 --- a/test/antithesis/workload/Dockerfile +++ b/test/antithesis/workload/Dockerfile @@ -29,4 +29,4 @@ ENTRYPOINT ["/init"] COPY --from=compiler cmds/* /opt/antithesis/test/v1/main/ -RUN echo ${LEDGER_LATEST_TAG} /ledger_latest_tag +RUN echo ${LEDGER_LATEST_TAG} > /ledger_latest_tag From e7f711036783c341be532a32a77674cb7507dd1e Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Fri, 3 Oct 2025 17:13:19 +0200 Subject: [PATCH 63/66] fix eventually_correct panic --- .../bin/cmds/eventually_correct/main.go | 67 ++++--------------- .../parallel_driver_ledger_create/main.go | 12 +--- test/antithesis/workload/internal/utils.go | 4 -- 3 files changed, 13 insertions(+), 70 deletions(-) diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 86a70bb912..6ea012a67f 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -9,7 +9,6 @@ import ( "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/pkg/client" - "github.com/formancehq/ledger/pkg/client/models/components" "github.com/formancehq/ledger/pkg/client/models/operations" "github.com/formancehq/ledger/test/antithesis/internal" ) @@ -21,7 +20,9 @@ func main() { ledgers, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{}) - assert.Sometimes(err == nil, "error listing ledgers", internal.Details {}) + assert.Sometimes(err == nil, "error listing ledgers", internal.Details { + "error": err, + }) if err != nil { return } @@ -33,7 +34,6 @@ func main() { defer wg.Done() checkBalanced(ctx, client, ledger) checkAccountBalances(ctx, client, ledger) - checkSequentialTxIDs(ctx, client, ledger) }(ledger.Name) } wg.Wait() @@ -43,18 +43,16 @@ func checkBalanced(ctx context.Context, client *client.Formance, ledger string) aggregated, err := client.Ledger.V2.GetBalancesAggregated(ctx, operations.V2GetBalancesAggregatedRequest{ Ledger: ledger, }) + assert.Sometimes( + err == nil, + "Client can aggregate balances", + internal.Details{ + "ledger": ledger, + "error": err, + }, + ) if err != nil { - if internal.IsServerError(aggregated.GetHTTPMeta()) { - assert.Always( - false, - fmt.Sprintf("error getting aggregated balances for ledger %s: %s", ledger, err), - internal.Details{ - "error": err, - }, - ) - } else { - log.Fatalf("error getting aggregated balances for ledger %s: %s", ledger, err) - } + return } for asset, volumes := range aggregated.V2AggregateBalancesResponse.Data { @@ -106,44 +104,3 @@ func checkAccountBalances(ctx context.Context, client *client.Formance, ledger s log.Printf("composer: account balances check: done for ledger %s", ledger) } - -func checkSequentialTxIDs(ctx context.Context, client *client.Formance, ledger string) { - var expectedTxId *big.Int - var next *string - for { - transactions, err := client.Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{ - Ledger: ledger, - Cursor: next, - }) - assert.Sometimes(err == nil, "Client can list transactions", internal.Details{ - "error": err, - }) - if err != nil { - fmt.Printf("error listing transactions: %v", err) - return - } - if len(transactions.V2TransactionsCursorResponse.Cursor.Data) == 0 { - return - } - if expectedTxId == nil { - expectedTxId = transactions.V2TransactionsCursorResponse.Cursor.Data[0].ID - expectedTxId.Add(expectedTxId, big.NewInt(1)) - } - for _, tx := range transactions.V2TransactionsCursorResponse.Cursor.Data { - expectedTxId.Sub(expectedTxId, big.NewInt(1)) - assert.Always(tx.ID.Cmp(expectedTxId) == 0, "txId should be sequential", internal.Details{ - "expected": expectedTxId, - "actual": tx.ID, - }) - } - if !transactions.V2TransactionsCursorResponse.Cursor.HasMore { - break - } - next = transactions.V2TransactionsCursorResponse.Cursor.Next - } - log.Printf("composer: sequential transaction id check: done for ledger %s", ledger) -} - -func IsServerError(httpMeta components.HTTPMetadata) bool { - return httpMeta.Response.StatusCode >= 400 && httpMeta.Response.StatusCode < 600 -} diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go index f3538c1cf5..64c8c84466 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_ledger_create/main.go @@ -17,7 +17,7 @@ func main() { id := random.GetRandom()%1e6 ledger := fmt.Sprintf("ledger-%d", id) - res, err := internal.CreateLedger( + _, err := internal.CreateLedger( ctx, client, ledger, @@ -28,15 +28,5 @@ func main() { "error": err, }) - if err == nil { - assert.Always( - !internal.IsServerError(res.GetHTTPMeta()), - "no internal server error when creating ledger", - internal.Details{ - "error": err, - }, - ) - } - log.Println("composer: parallel_driver_ledger_create: done") } diff --git a/test/antithesis/workload/internal/utils.go b/test/antithesis/workload/internal/utils.go index e66c1c9830..b4f0f9da81 100644 --- a/test/antithesis/workload/internal/utils.go +++ b/test/antithesis/workload/internal/utils.go @@ -61,10 +61,6 @@ func NewClient() *client.Formance { ) } -func IsServerError(httpMeta components.HTTPMetadata) bool { - return httpMeta.Response.StatusCode >= 400 && httpMeta.Response.StatusCode < 600 -} - func CreateLedger(ctx context.Context, client *client.Formance, name string, bucket string) (*operations.V2CreateLedgerResponse, error) { res, err := client.Ledger.V2.CreateLedger(ctx, operations.V2CreateLedgerRequest{ Ledger: name, From ea4e906fecacf109ce00b3e72ab5b5abbd18a6b1 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Fri, 17 Oct 2025 18:47:10 +0200 Subject: [PATCH 64/66] restore version upgrade test --- .github/workflows/antithesis_daily.yml | 8 ++------ Earthfile | 2 +- go.sum | 4 ---- internal/storage/driver/driver.go | 4 ++-- test/antithesis/Justfile | 4 ++-- test/antithesis/workload/Dockerfile | 3 ++- .../workload/bin/cmds/eventually_correct/main.go | 6 ++++-- .../bin/cmds/parallel_driver_transactions/main.go | 5 +++-- tools/generator/cmd/root.go | 8 ++++---- tools/generator/go.mod | 1 + tools/generator/go.sum | 2 ++ tools/provisioner/go.mod | 1 + tools/provisioner/go.sum | 2 ++ 13 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.github/workflows/antithesis_daily.yml b/.github/workflows/antithesis_daily.yml index d28cb78a45..d343703280 100644 --- a/.github/workflows/antithesis_daily.yml +++ b/.github/workflows/antithesis_daily.yml @@ -25,9 +25,7 @@ jobs: OPERATOR_TAG: "v2.10.1" OPERATOR_UTILS_TAG: "v2.0.14" GATEWAY_TAG: "v2.0.24" - # LEDGER_PREVIOUS_TAG: "v2.2.47" - # temporary: remove this when support for multiple image versions is added - LEDGER_PREVIOUS_TAG: "v2.3.0" + LEDGER_PREVIOUS_TAG: "v2.2.47" LEDGER_LATEST_TAG: "v2.3.0" steps: - name: Checkout code @@ -74,8 +72,6 @@ jobs: username: ${{ secrets.ANTITHESIS_USERNAME }} password: ${{ secrets.ANTITHESIS_PASSWORD }} github_token: ${{ secrets.NUMARY_GITHUB_TOKEN }} - # images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" - # temporary: remove this when support for multiple image versions is added - images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" + images: "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:${{ env.OPERATOR_TAG }};ghcr.io/formancehq/operator-utils:${{ env.OPERATOR_UTILS_TAG }};ghcr.io/formancehq/gateway:${{ env.GATEWAY_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_PREVIOUS_TAG }};ghcr.io/formancehq/ledger-instrumented:${{ env.LEDGER_LATEST_TAG }}" config_image: "antithesis-config:daily_run" email_recipients: ${{ secrets.ANTITHESIS_SLACK_REPORT_RECIPIENT }} diff --git a/Earthfile b/Earthfile index 0143d546b0..e8490a1dd8 100644 --- a/Earthfile +++ b/Earthfile @@ -50,4 +50,4 @@ deploy: RUN kubectl patch Versions.formance.com default -p "{\"spec\":{\"ledger\": \"${tag}\"}}" --type=merge deploy-staging: - BUILD --pass-args core+deploy-staging + BUILD --pass-args core+deploy-staging \ No newline at end of file diff --git a/go.sum b/go.sum index f1f0078360..1027c3f847 100644 --- a/go.sum +++ b/go.sum @@ -32,10 +32,6 @@ github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= -github.com/antithesishq/antithesis-sdk-go v0.4.3-default-no-op h1:+OSa/t11TFhqfrX0EOSqQBDJ0YlpmK0rDSiB19dg9M0= -github.com/antithesishq/antithesis-sdk-go v0.4.3-default-no-op/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= -github.com/antithesishq/antithesis-sdk-go v0.4.3 h1:a2hGdDogClzHzFu20r1z0tzD6zwSWUipiaerAjZVP90= -github.com/antithesishq/antithesis-sdk-go v0.4.3/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index af7c4f0c0f..b6fdbc9c8a 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -4,8 +4,6 @@ import ( "context" "errors" "fmt" - "sync" - "time" "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/internal/storage/common" @@ -13,6 +11,8 @@ import ( "github.com/formancehq/ledger/internal/tracing" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/noop" + "sync" + "time" "github.com/alitto/pond" "github.com/formancehq/go-libs/v3/bun/bunpaginate" diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 860b53e8e8..378bf2db4f 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -6,7 +6,7 @@ run-6min: requirements-push "custom.duration": "0.1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:daily_run", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_LATEST_TAG"'" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_PREVIOUS_TAG"';ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_LATEST_TAG"'" \ } \ }' @@ -18,7 +18,7 @@ run-1h: requirements-push "custom.duration": "1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:daily_run", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:"'"$LEDGER_LATEST_TAG"'" \ + "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_PREVIOUS_TAG"';ghcr.io/formancehq/ledger-instrumented:"'"$LEDGER_LATEST_TAG"'" \ } \ }' diff --git a/test/antithesis/workload/Dockerfile b/test/antithesis/workload/Dockerfile index 896fa20a58..a24eef890f 100644 --- a/test/antithesis/workload/Dockerfile +++ b/test/antithesis/workload/Dockerfile @@ -13,6 +13,7 @@ COPY pkg/client /src/pkg/client RUN antithesis-go-instrumentor -assert_only . RUN go build -o /init ./bin/init +RUN mkdir -p /cmds RUN for file in $(ls ./bin/cmds/); do go build -o /cmds/$file ./bin/cmds/$file; done RUN antithesis-go-instrumentor -assert_only . @@ -27,6 +28,6 @@ ARG LEDGER_LATEST_TAG COPY --from=compiler /init /init ENTRYPOINT ["/init"] -COPY --from=compiler cmds/* /opt/antithesis/test/v1/main/ +COPY --from=compiler /cmds/* /opt/antithesis/test/v1/main/ RUN echo ${LEDGER_LATEST_TAG} > /ledger_latest_tag diff --git a/test/antithesis/workload/bin/cmds/eventually_correct/main.go b/test/antithesis/workload/bin/cmds/eventually_correct/main.go index 6ea012a67f..48d571f55c 100644 --- a/test/antithesis/workload/bin/cmds/eventually_correct/main.go +++ b/test/antithesis/workload/bin/cmds/eventually_correct/main.go @@ -61,7 +61,8 @@ func checkBalanced(ctx context.Context, client *client.Formance, ledger string) fmt.Sprintf("aggregated volumes for asset %s should be 0", asset, ), internal.Details{ - "error": err, + "asset": asset, + "volumes": volumes, }) } @@ -75,8 +76,9 @@ func checkAccountBalances(ctx context.Context, client *client.Formance, ledger s Ledger: ledger, Address: address, }) - assert.Sometimes(err != nil, "Client can aggregate account balances", internal.Details{ + assert.Sometimes(err == nil, "Client can aggregate account balances", internal.Details{ "ledger": ledger, + "address": address, "error": err, }) if err != nil { diff --git a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go index ccd892c26a..407dd3659c 100644 --- a/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go +++ b/test/antithesis/workload/bin/cmds/parallel_driver_transactions/main.go @@ -20,9 +20,10 @@ func main() { client := internal.NewClient() ledger, err := internal.GetRandomLedger(ctx, client) + assert.Sometimes(err == nil, "should be able to get a random ledger", internal.Details{ + "error": err, + }) if err != nil { - ledger = "default" - log.Printf("error getting random ledger: %s", err) return } diff --git a/tools/generator/cmd/root.go b/tools/generator/cmd/root.go index ed538fc826..7234194512 100644 --- a/tools/generator/cmd/root.go +++ b/tools/generator/cmd/root.go @@ -5,10 +5,7 @@ import ( "crypto/tls" "errors" "fmt" - "net/http" - "os" - "strings" - + "github.com/formancehq/go-libs/v3/logging" "github.com/formancehq/go-libs/v3/service" ledgerclient "github.com/formancehq/ledger/pkg/client" @@ -19,6 +16,9 @@ import ( "github.com/spf13/cobra" "golang.org/x/oauth2" "golang.org/x/oauth2/clientcredentials" + "net/http" + "os" + "strings" ) const ( diff --git a/tools/generator/go.mod b/tools/generator/go.mod index 09d0e7b5a5..117f7a3694 100644 --- a/tools/generator/go.mod +++ b/tools/generator/go.mod @@ -21,6 +21,7 @@ require ( dario.cat/mergo v1.0.2 // indirect github.com/ThreeDotsLabs/watermill v1.4.7 // indirect github.com/alitto/pond v1.9.2 // indirect + github.com/antithesishq/antithesis-sdk-go v0.5.0 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect diff --git a/tools/generator/go.sum b/tools/generator/go.sum index 773cf6f4af..9fb187c661 100644 --- a/tools/generator/go.sum +++ b/tools/generator/go.sum @@ -32,6 +32,8 @@ github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= +github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= +github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= diff --git a/tools/provisioner/go.mod b/tools/provisioner/go.mod index 0a12e0723e..53a15fa940 100644 --- a/tools/provisioner/go.mod +++ b/tools/provisioner/go.mod @@ -38,6 +38,7 @@ require ( github.com/ajg/form v1.5.1 // indirect github.com/alitto/pond v1.9.2 // indirect github.com/andybalholm/brotli v1.1.1 // indirect + github.com/antithesishq/antithesis-sdk-go v0.5.0 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/aws/aws-msk-iam-sasl-signer-go v1.0.4 // indirect diff --git a/tools/provisioner/go.sum b/tools/provisioner/go.sum index 8d04bf4f4f..3a413f179b 100644 --- a/tools/provisioner/go.sum +++ b/tools/provisioner/go.sum @@ -30,6 +30,8 @@ github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= +github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= +github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= From 12c399d1875e6b3cae5541705716b315c2c22bd7 Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 21 Oct 2025 12:16:59 +0200 Subject: [PATCH 65/66] justfile typo --- test/antithesis/Justfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/antithesis/Justfile b/test/antithesis/Justfile index 378bf2db4f..a28536e1e4 100644 --- a/test/antithesis/Justfile +++ b/test/antithesis/Justfile @@ -6,7 +6,7 @@ run-6min: requirements-push "custom.duration": "0.1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:daily_run", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_PREVIOUS_TAG"';ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_LATEST_TAG"'" \ + "antithesis.images": "'"workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:$LEDGER_PREVIOUS_TAG;ghcr.io/formancehq/ledger-instrumented:$LEDGER_LATEST_TAG"'" \ } \ }' @@ -18,7 +18,7 @@ run-1h: requirements-push "custom.duration": "1", \ "antithesis.report.recipients": "'"$ANTITHESIS_SLACK_REPORT_RECIPIENT"'", \ "antithesis.config_image": "antithesis-config:daily_run", \ - "antithesis.images": "workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:'"$LEDGER_PREVIOUS_TAG"';ghcr.io/formancehq/ledger-instrumented:"'"$LEDGER_LATEST_TAG"'" \ + "antithesis.images": "'"workload:latest;docker.io/library/postgres:15-alpine;ghcr.io/formancehq/operator:v2.10.1;ghcr.io/formancehq/operator-utils:v2.0.14;ghcr.io/formancehq/gateway:v2.0.24;ghcr.io/formancehq/ledger-instrumented:$LEDGER_PREVIOUS_TAG;ghcr.io/formancehq/ledger-instrumented:$LEDGER_LATEST_TAG"'" \ } \ }' From 3dc65d46f94332c71a98e93fbad665f185b3462f Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Tue, 21 Oct 2025 13:39:39 +0200 Subject: [PATCH 66/66] remove bucket version assertion for now --- go.mod | 1 - go.sum | 4 ++-- internal/storage/driver/driver.go | 12 ------------ tools/generator/go.mod | 1 - tools/generator/go.sum | 2 -- tools/provisioner/go.mod | 1 - tools/provisioner/go.sum | 2 -- 7 files changed, 2 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 59d130c5fc..d11eb87ece 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,6 @@ replace google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215 => google. require ( github.com/ThreeDotsLabs/watermill v1.5.1 github.com/alitto/pond v1.9.2 - github.com/antithesishq/antithesis-sdk-go v0.5.0 github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 github.com/bluele/gcache v0.0.2 github.com/dop251/goja v0.0.0-20250630131328-58d95d85e994 diff --git a/go.sum b/go.sum index 71fae42584..16e8b278aa 100644 --- a/go.sum +++ b/go.sum @@ -32,8 +32,8 @@ github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= -github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= -github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= +github.com/antithesishq/antithesis-sdk-go v0.4.3-default-no-op h1:+OSa/t11TFhqfrX0EOSqQBDJ0YlpmK0rDSiB19dg9M0= +github.com/antithesishq/antithesis-sdk-go v0.4.3-default-no-op/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= diff --git a/internal/storage/driver/driver.go b/internal/storage/driver/driver.go index b6fdbc9c8a..fe20628be9 100644 --- a/internal/storage/driver/driver.go +++ b/internal/storage/driver/driver.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" - "github.com/antithesishq/antithesis-sdk-go/assert" "github.com/formancehq/ledger/internal/storage/common" systemstore "github.com/formancehq/ledger/internal/storage/system" "github.com/formancehq/ledger/internal/tracing" @@ -78,17 +77,6 @@ func (d *Driver) CreateLedger(ctx context.Context, l *ledger.Ledger) (*ledgersto } if !upToDate { - assert.AlwaysOrUnreachable( - // @todo: replace this with a proper flag detailing wether we're - // operating a new version of the binary or not. - // if we are, we are definitely expecting this to happen. - // if we're not, this should be unreachable. - false, - "Bucket is outdated", - map[string]any{ - "bucket": l.Bucket, - }, - ) return ErrBucketOutdated } diff --git a/tools/generator/go.mod b/tools/generator/go.mod index c58ad4d85b..7f989fda54 100644 --- a/tools/generator/go.mod +++ b/tools/generator/go.mod @@ -21,7 +21,6 @@ require ( dario.cat/mergo v1.0.2 // indirect github.com/ThreeDotsLabs/watermill v1.5.1 // indirect github.com/alitto/pond v1.9.2 // indirect - github.com/antithesishq/antithesis-sdk-go v0.5.0 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect diff --git a/tools/generator/go.sum b/tools/generator/go.sum index d7d7f3beab..97c6e90a14 100644 --- a/tools/generator/go.sum +++ b/tools/generator/go.sum @@ -32,8 +32,6 @@ github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= -github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= -github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= diff --git a/tools/provisioner/go.mod b/tools/provisioner/go.mod index 54582750ad..caed23062a 100644 --- a/tools/provisioner/go.mod +++ b/tools/provisioner/go.mod @@ -40,7 +40,6 @@ require ( github.com/ajg/form v1.5.1 // indirect github.com/alitto/pond v1.9.2 // indirect github.com/andybalholm/brotli v1.1.1 // indirect - github.com/antithesishq/antithesis-sdk-go v0.5.0 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/aws/aws-msk-iam-sasl-signer-go v1.0.4 // indirect diff --git a/tools/provisioner/go.sum b/tools/provisioner/go.sum index 5c19369096..12040c04f5 100644 --- a/tools/provisioner/go.sum +++ b/tools/provisioner/go.sum @@ -30,8 +30,6 @@ github.com/alitto/pond v1.9.2 h1:9Qb75z/scEZVCoSU+osVmQ0I0JOeLfdTDafrbcJ8CLs= github.com/alitto/pond v1.9.2/go.mod h1:xQn3P/sHTYcU/1BR3i86IGIrilcrGC2LiS+E2+CJWsI= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= -github.com/antithesishq/antithesis-sdk-go v0.5.0 h1:cudCFF83pDDANcXFzkQPUHHedfnnIbUO3JMr9fqwFJs= -github.com/antithesishq/antithesis-sdk-go v0.5.0/go.mod h1:IUpT2DPAKh6i/YhSbt6Gl3v2yvUZjmKncl7U91fup7E= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=