diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1c25011..e0fcf72 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,8 +4,8 @@ on: workflow_call: inputs: version: - default: "" - required: true + default: "dev" + required: false type: string workflow_dispatch: inputs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9febbda..54ca2d8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.23' + go-version: '1.23.3' # Needed for ARM64 Docker builds - name: Set up QEMU @@ -42,7 +42,7 @@ jobs: uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser - version: "v2.3.1" + version: "v2.4.5" args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 97f5c95..a8d923f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ cmd/gemini/dist/ /gemini .idea -.vscode bin/ coverage.txt dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml index 894db27..9fa06a6 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,28 +1,25 @@ version: 2 -env: - - GO111MODULE=on - # ARM crypto extension for RANDOM Number generation - - GOARM64=v8.0,crypto - - CFLAGS="-O3" - - CXXFLAGS="-O3" - -before: - hooks: - - go mod download +report_sizes: true builds: - - env: - - CGO_ENABLED=0 + - id: gemini goos: - linux - ldflags: -s -w + binary: gemini + no_unique_dist_dir: false + env: + - CGO_ENABLED=0 + - CFLAGS="-O3" + - CXXFLAGS="-O3" goarch: - amd64 - arm64 main: ./cmd/gemini goamd64: - v3 # v3 Enables AMD64 SIMD (SSE4.x,AVX2) optimizations + goarm64: + - v8.3 # ARM crypto extension for RANDOM Number generation archives: - name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' @@ -86,3 +83,4 @@ release: make_latest: true prerelease: auto skip_upload: false + include_meta: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0543611 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,36 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - repo: https://github.com/scop/pre-commit-shfmt + rev: v3.9.0-1 + hooks: + - id: shfmt + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 + hooks: + - id: gitlint + - repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.10.0 + hooks: + - id: shellcheck + - repo: https://github.com/tekwizely/pre-commit-golang + rev: v1.0.0-rc.1 + hooks: + - id: go-build-repo-mod + - id: go-mod-tidy-repo + - id: go-vet-repo-mod + - id: go-sec-repo-mod + - id: go-fumpt-repo + - id: golangci-lint-repo-mod + args: ['--fix'] + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.18.0 + hooks: + - id: commitlint + stages: [commit-msg] + additional_dependencies: ['@commitlint/config-conventional'] diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..9473798 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,25 @@ +{ + "recommendations": [ + "ms-vscode-remote.remote-containers", + "ms-azuretools.vscode-docker", + "p1c2u.docker-compose", + "usernamehw.errorlens", + "github.vscode-github-actions", + "eamodio.gitlens", + "golang.go", + "mongodb.mongodb-vscode", + "christian-kohler.path-intellisense", + "foxundermoon.shell-format", + "timonwong.shellcheck", + "JordanHury.sqltools-cassandra", + "wayou.vscode-todo-highlight", + "tooltitudeteam.tooltitude", + "pflannery.vscode-versionlens", + "redhat.vscode-yaml", + "ms-vscode.test-adapter-converter", + "GitHub.vscode-pull-request-github", + "ms-vscode.remote-repositories", + "ms-vsliveshare.vsliveshare", + "aaron-bond.better-comments", + ], +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..5a10430 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,59 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Gemini", + "type": "go", + "buildFlags": [ + "-gcflags=all=\"-N -l\"" + ], + "request": "launch", + "mode": "exec", + "program": "${workspaceFolder}/bin/gemini", + "cwd": "${workspaceFolder}/bin", + "backend": "lldb", + "apiVersion": 2, + "args": [ + "--consistency=LOCAL_QUORUM", + "--test-host-selection-policy=token-aware", + "--oracle-host-selection-policy=token-aware", + "--test-cluster=192.168.100.3", + "--oracle-cluster=192.168.100.2", + "--dataset-size=large", + "--seed=60", + "--schema-seed=60", + "--cql-features=all", + "--duration=5m", + "--warmup=10s", + "--drop-schema=true", + "--fail-fast", + "--level=info", + "--materialized-views=true", + "--outfile=${workspaceFolder}/results/gemini_result.log", + "--mode=mixed", + "--non-interactive", + "--request-timeout=180s", + "--connect-timeout=120s", + "--consistency=LOCAL_QUORUM", + "--use-server-timestamps=false", + "--async-objects-stabilization-attempts=10", + "--async-objects-stabilization-backoff=1000ms", + "--replication-strategy=\"{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}\"", + "--oracle-replication-strategy=\"{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}\"", + "--max-mutation-retries=5", + "--max-mutation-retries-backoff=1000ms", + "--concurrency=4", + "--tracing-outfile=${workspaceFolder}/results/gemini_tracing.log", + ], + "logOutput": "debugger", + "suppressMultipleSessionWarning": true, + "coreFilePath": "${workspaceFolder}", + "output": "${workspaceFolder}/bin/gemini", + "showLog": true, + "showGlobalVariables": true, + "showRegisters": true, + "hideSystemGoroutines": true, + "internalConsoleOptions": "openOnFirstSessionStart", + }, + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f7a5b69 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,195 @@ +{ + "editor.formatOnSave": true, + "editor.quickSuggestions": { + "comments": true, + "strings": true, + "other": true + }, + "[yaml]": { + "editor.defaultFormatter": "redhat.vscode-yaml" + }, + "[dockerfile]": { + "editor.defaultFormatter": "ms-azuretools.vscode-docker" + }, + "git.allowForcePush": true, + "git.alwaysSignOff": true, + "git.autofetch": true, + "git.ignoreLimitWarning": true, + "github.gitProtocol": "ssh", + "makefile.configureOnOpen": false, + "go.diagnostic.vulncheck": "Imports", + "go.disableConcurrentTests": false, + "go.coverOnSave": true, + "go.coverOnSingleTest": true, + "go.coverOnSingleTestFile": true, + "go.inlayHints.compositeLiteralTypes": false, + "go.inlayHints.parameterNames": true, + "go.useLanguageServer": true, + "go.inferGopath": true, + "go.vetOnSave": "workspace", + "go.coverMode": "default", + "go.addTags": { + "tags": "json,bson,yaml", + "promptForTags": true + }, + "go.coverageDecorator": { + "type": "gutter", + "coveredHighlightColor": "rgba(64,128,128,0.5)", + "uncoveredHighlightColor": "rgba(128,64,64,0.25)", + "coveredGutterStyle": "blockgreen", + "uncoveredGutterStyle": "blockred" + }, + "go.formatTool": "gofumpt", + "go.coverShowCounts": true, + "go.enableCodeLens": { + "runtest": true, + }, + "gopls": { + "ui.codelenses": { + "gc_details": true, + "upgrade_dependency": true, + "generate": true, + "regenerate_cgo": true, + "test": true, + "tidy": true, + "run_govulncheck": true, + "vendor": true + }, + "ui.diagnostic.analyses": { + "asmdecl": true, + "nilness": true, + "assign": true, + "atomic": true, + "atomicalign": true, + "bools": true, + "buildtags": true, + "cgocall": true, + "composites": true, + "copylocks": true, + "buildtag": true, + "errorsas": true, + "fieldalignment": true, + "deepequalerrors": true, + "fillreturns": true, + "fillstruct": true, + "nilfunc": true, + "ifaceassert": true, + "httpresponse": true, + "infertypeargs": true, + "lostcancel": true, + "loopclosure": true, + "printf": true, + "simplifycompositelit": true, + "stdmethods": true, + "shadow": true, + "structtag": true, + "timeformat": true, + "unmarshal": true, + "unreachable": true, + "unusedwrite": true, + "unusedvariable": true, + "unsafeptr": true, + "unusedresult": true, + "embed": true, + "nonewvars": true, + "noresultvalues": true, + "shift": true, + "simplifyrange": true, + "simplifyslice": true, + "sortslice": true, + "stringintconv": true, + "stubmethods": true, + "testinggoroutine": true, + "tests": true, + "undeclaredname": true, + "unusedparams": false + }, + "ui.semanticTokens": true, + "ui.completion.experimentalPostfixCompletions": true, + "ui.completion.usePlaceholders": false, + "ui.completion.matcher": "Fuzzy", + "ui.diagnostic.staticcheck": true, + "ui.diagnostic.annotations": { + "bounds": true, + "escape": true, + "inline": true, + "nil": true + }, + "ui.navigation.importShortcut": "Both", + "ui.noSemanticNumber": true, + "ui.navigation.symbolStyle": "Full", + "ui.noSemanticString": true, + "ui.documentation.linksInHover": false, + "ui.navigation.symbolMatcher": "FastFuzzy", + "ui.documentation.hoverKind": "FullDocumentation", + "ui.documentation.linkTarget": "pkg.go.dev", + "ui.completion.completionBudget": "500ms", + "ui.navigation.symbolScope": "all", + "ui.diagnostic.diagnosticsDelay": "600ms", + "gofumpt": true, + }, + "go.lintTool": "golangci-lint", + "go.lintFlags": [ + "--verbose" + ], + "go.toolsManagement.autoUpdate": true, + "go.coverageOptions": "showCoveredCodeOnly", + "go.inlayHints.compositeLiteralFields": true, + "go.lintOnSave": "workspace", + "go.inlayHints.constantValues": true, + "go.inlayHints.assignVariableTypes": true, + "go.coverOnTestPackage": true, + "go.toolsManagement.go": "1.23", + "go.generateTestsFlags": [ + "-v" + ], + "go.delveConfig": { + "apiVersion": 2, + "debugAdapter": "dlv-dap", + "showLog": true, + "hideSystemGoroutines": true, + "showGlobalVariables": true, + "dlvLoadConfig": { + "followPointers": true, + "maxVariableRecurse": 1, + "maxStringLen": 256, + "maxArrayValues": 256, + "maxStructFields": -1, + }, + "dlvFlags": [ + "--accept-multiclient", + "--listen=0.0.0.0:2345", + "--allow-non-terminal-interactive" + ], + "logOutput": "debugger", + "showRegisters": true + }, + "go.editorContextMenuCommands": { + "removeTags": true, + "fillStruct": true, + "testFile": true, + "testPackage": true, + "generateTestForFile": true, + "generateTestForPackage": true, + "benchmarkAtCursor": true, + "addImport": true, + "addTags": true, + "testCoverage": true, + "generateTestForFunction": true, + }, + "go.inlayHints.functionTypeParameters": true, + "go.inlayHints.rangeVariableTypes": true, + "go.installDependenciesWhenBuilding": true, + "go.testExplorer.showOutput": true, + "go.testExplorer.packageDisplayMode": "nested", + "go.testExplorer.showDynamicSubtestsInEditor": true, + "go.terminal.activateEnvironment": true, + "go.testTimeout": "5m", + "go.testExplorer.enable": true, + "go.testExplorer.concatenateMessages": true, + "go.removeTags": { + "tags": "", + "options": "", + "promptForTags": true + }, +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..22a392b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,80 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build Debug", + "type": "process", + "command": "make", + "args": [ + "debug-build" + ], + "group": { + "kind": "build", + "isDefault": true + }, + }, + { + "label": "Build", + "type": "shell", + "command": "make", + "args": [ + "build" + ], + "group": { + "kind": "build", + "isDefault": false + }, + }, + { + "label": "Tests", + "type": "shell", + "command": "make", + "args": [ + "test" + ], + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "label": "Integration Tests", + "type": "shell", + "command": "make", + "args": [ + "integration-test" + ], + "group": { + "kind": "test", + "isDefault": true + } + }, + { + "label": "Scylla Setup", + "type": "shell", + "command": "make", + "args": [ + "scylla-setup" + ], + "isBackground": true, + }, + { + "label": "Scylla Shutdown", + "type": "shell", + "command": "make", + "args": [ + "scylla-shutdown" + ], + "isBackground": true, + }, + { + "label": "Format", + "type": "shell", + "command": "make", + "args": [ + "fmt" + ], + "isBackground": true, + }, + ] +} diff --git a/Dockerfile b/Dockerfile index 52f840c..9c11c89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ FROM golang:1.23-bookworm AS build ENV GO111MODULE=on -ENV CGO_ENABLED=0 ENV GOAMD64=v3 -ENV GOARM64=v8.0,crypto +ENV GOARM64=v8.3,crypto ENV CFLAGS="-O3" ENV CXXFLAGS="-O3" @@ -12,26 +11,26 @@ WORKDIR /gemini COPY . . RUN apt-get update \ - && apt-get install -y build-essential ca-certificates \ + && apt-get upgrade -y \ + && apt-get install -y build-essential ca-certificates libc-dev \ && make build FROM busybox AS production -WORKDIR /gemini +WORKDIR / -COPY --from=build /gemini/bin/gemini . +COPY --from=build /gemini/bin/gemini /usr/local/bin/gemini -ENV PATH="/gemini:${PATH}" +ENV PATH="/usr/local/bin:${PATH}" ENTRYPOINT ["gemini"] +FROM busybox AS production-goreleaser -FROM busybox AS production-goreleaser - -WORKDIR /gemini +WORKDIR / -COPY gemini . +COPY gemini /usr/local/bin/gemini -ENV PATH="/gemini:${PATH}" +ENV PATH="/usr/local/bin:${PATH}" ENTRYPOINT ["gemini"] diff --git a/Makefile b/Makefile index ec11010..1677851 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ define dl_tgz fi endef -$(GOBIN)/golangci-lint: GOLANGCI_VERSION = 1.60.3 +$(GOBIN)/golangci-lint: GOLANGCI_VERSION = 1.62.0 $(GOBIN)/golangci-lint: Makefile $(call dl_tgz,golangci-lint,https://github.com/golangci/golangci-lint/releases/download/v$(GOLANGCI_VERSION)/golangci-lint-$(GOLANGCI_VERSION)-$(GOOS)-amd64.tar.gz) @@ -48,6 +48,10 @@ debug-build: build-docker: @docker build --target production -t scylladb/gemini:$(DOCKER_VERSION) --compress . +.PHONY: setup +setup: $(GOBIN)/golangci-lint scylla-setup debug-build + @pre-commit install + .PHONY: scylla-setup scylla-setup: @docker compose -f docker/docker-compose-$(DOCKER_COMPOSE_TESTING).yml up -d @@ -63,49 +67,105 @@ scylla-shutdown: test: @go test -covermode=atomic -race -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | gotestfmt -showteststatus -CQL_FEATURES ?= normal -CONCURRENCY ?= 16 -DURATION ?= 1m +CQL_FEATURES ?= all +CONCURRENCY ?= 50 +DURATION ?= 10m WARMUP ?= 1m DATASET_SIZE ?= large -SEED ?= $(shell date +%s | tee ./results/gemini_seed) +SEED ?= $(shell date +%s) +GEMINI_BINARY ?= $(PWD)/bin/gemini +GEMINI_TEST_CLUSTER ?= $(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-test) +GEMINI_ORACLE_CLUSTER ?= $(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-oracle) +GEMINI_DOCKER_NETWORK ?= gemini +GEMINI_FLAGS = --fail-fast \ + --level=info \ + --non-interactive \ + --materialized-views=false \ + --consistency=LOCAL_QUORUM \ + --test-host-selection-policy=token-aware \ + --oracle-host-selection-policy=token-aware \ + --mode=mixed \ + --non-interactive \ + --request-timeout=5s \ + --connect-timeout=15s \ + --use-server-timestamps=false \ + --async-objects-stabilization-attempts=10 \ + --max-mutation-retries=10 \ + --async-objects-stabilization-backoff=1000ms \ + --max-mutation-retries-backoff=1000ms \ + --replication-strategy="{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ + --oracle-replication-strategy="{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ + --concurrency=$(CONCURRENCY) \ + --use-lwt=true \ + --dataset-size=$(DATASET_SIZE) \ + --seed=$(SEED) \ + --schema-seed=$(SEED) \ + --cql-features=$(CQL_FEATURES) \ + --duration=$(DURATION) \ + --warmup=$(WARMUP) \ + --profiling-port=6060 \ + --drop-schema=true + +.PHONY: pprof-profile +pprof-profile: + go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/profile + +.PHONY: pprof-heap +pprof-heap: + go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/heap + +.PHONY: pprof-goroutine +pprof-goroutine: + go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/goroutine + +.PHONY: pprof-block +pprof-block: + go tool pprof -http=:8080 -intel_syntax -call_tree -seconds 60 http://localhost:6060/debug/pprof/block + +.PHONY: docker-integration-test +docker-integration-test: + @mkdir -p $(PWD)/results + @touch $(PWD)/results/gemini_seed + @echo $(GEMINI_SEED) > $(PWD)/results/gemini_seed + docker run \ + -it \ + --rm \ + -p 6060:6060 \ + --name gemini \ + --network $(GEMINI_DOCKER_NETWORK) \ + -v $(PWD)/results:/results \ + -w / \ + scylladb/gemini:$(DOCKER_VERSION) \ + --test-cluster=gemini-test \ + --oracle-cluster=gemini-oracle \ + --outfile=/results/gemini_result.log \ + --tracing-outfile=/results/gemini_tracing.log \ + --test-statement-log-file=/results/gemini_test_statement.log \ + --oracle-statement-log-file=/results/gemini_oracle_statement.log \ + $(GEMINI_FLAGS) .PHONY: integration-test -integration-test: debug-build +integration-test: @mkdir -p $(PWD)/results @touch $(PWD)/results/gemini_seed - @./bin/gemini \ - --dataset-size=$(DATASET_SIZE) \ - --seed=$(SEED) \ - --schema-seed=$(SEED) \ - --cql-features $(CQL_FEATURES) \ - --duration $(DURATION) \ - --warmup $(WARMUP) \ - --drop-schema true \ - --fail-fast \ - --level info \ - --non-interactive \ - --materialized-views false \ - --consistency LOCAL_QUORUM \ - --outfile $(PWD)/results/gemini.log \ - --test-statement-log-file $(PWD)/results/gemini_test_statements.log \ - --oracle-statement-log-file $(PWD)/results/gemini_oracle_statements.log \ - --test-host-selection-policy token-aware \ - --oracle-host-selection-policy token-aware \ - --test-cluster=$(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-test) \ - --oracle-cluster=$(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-oracle) \ - --outfile $(PWD)/results/gemini_result.log \ - --mode mixed \ - --non-interactive \ - --request-timeout 180s \ - --connect-timeout 120s \ - --consistency LOCAL_QUORUM \ - --use-server-timestamps false \ - --async-objects-stabilization-attempts 10 \ - --async-objects-stabilization-backoff 100ms \ - --replication-strategy "{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ - --oracle-replication-strategy "{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ - --max-mutation-retries 5 \ - --max-mutation-retries-backoff 1000ms \ - --concurrency $(CONCURRENCY) \ - --tracing-outfile $(PWD)/results/gemini_tracing.log + @echo $(GEMINI_SEED) > $(PWD)/results/gemini_seed + @$(GEMINI_BINARY) \ + --test-cluster=$(GEMINI_TEST_CLUSTER) \ + --oracle-cluster=$(GEMINI_ORACLE_CLUSTER) \ + --outfile=$(PWD)/results/gemini_result.log \ + --tracing-outfile=$(PWD)/results/gemini_tracing.log \ + --test-statement-log-file=$(PWD)/results/gemini_test_statement.log \ + --oracle-statement-log-file=$(PWD)/results/gemini_oracle_statement.log \ + $(GEMINI_FLAGS) + +.PHONY: clean +clean: clean-bin clean-results + +.PHONY: clean-bin +clean-bin: + @rm -rf bin + +.PHONY: clean-results +clean-results: + @sudo rm -rf results/*.log + @sudo rm -rf results/gemini_seed diff --git a/cmd/gemini/root.go b/cmd/gemini/root.go index 0b13d7a..ed4d4e2 100644 --- a/cmd/gemini/root.go +++ b/cmd/gemini/root.go @@ -487,7 +487,7 @@ func init() { "Specify the desired replication strategy of the oracle cluster as either the coded short hand simple|network to get the default for each "+ "type or provide the entire specification in the form {'class':'....'}") rootCmd.Flags().StringArrayVarP(&tableOptions, "table-options", "", []string{}, "Repeatable argument to set table options to be added to the created tables") - rootCmd.Flags().StringVarP(&consistency, "consistency", "", "QUORUM", "Specify the desired consistency as ANY|ONE|TWO|THREE|QUORUM|LOCAL_QUORUM|EACH_QUORUM|LOCAL_ONE") + rootCmd.Flags().StringVarP(&consistency, "consistency", "", "LOCAL_QUORUM", "Specify the desired consistency as ANY|ONE|TWO|THREE|QUORUM|LOCAL_QUORUM|EACH_QUORUM|LOCAL_ONE") rootCmd.Flags().IntVarP(&maxTables, "max-tables", "", 1, "Maximum number of generated tables") rootCmd.Flags().IntVarP(&maxPartitionKeys, "max-partition-keys", "", 6, "Maximum number of generated partition keys") rootCmd.Flags().IntVarP(&minPartitionKeys, "min-partition-keys", "", 2, "Minimum number of generated partition keys") @@ -522,10 +522,10 @@ func init() { "Duration between attempts to validate result sets from MV and SI for example 10ms or 1s") rootCmd.Flags().BoolVarP(&useLWT, "use-lwt", "", false, "Emit LWT based updates") rootCmd.Flags().StringVarP( - &oracleClusterHostSelectionPolicy, "oracle-host-selection-policy", "", "round-robin", + &oracleClusterHostSelectionPolicy, "oracle-host-selection-policy", "", "token-aware", "Host selection policy used by the driver for the oracle cluster: round-robin|host-pool|token-aware") rootCmd.Flags().StringVarP( - &testClusterHostSelectionPolicy, "test-host-selection-policy", "", "round-robin", + &testClusterHostSelectionPolicy, "test-host-selection-policy", "", "token-aware", "Host selection policy used by the driver for the test cluster: round-robin|host-pool|token-aware") rootCmd.Flags().BoolVarP(&useServerSideTimestamps, "use-server-timestamps", "", false, "Use server-side generated timestamps for writes") rootCmd.Flags().DurationVarP(&requestTimeout, "request-timeout", "", 30*time.Second, "Duration of waiting request execution") diff --git a/commitlint.config.mjs b/commitlint.config.mjs new file mode 100644 index 0000000..8d99c60 --- /dev/null +++ b/commitlint.config.mjs @@ -0,0 +1,23 @@ +export default { + parserPreset: 'conventional-changelog-atom', + formatter: '@commitlint/format', + rules: { + "header-max-length": [2, "always", 120], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'subject-max-length': [2, 'always', 120], + 'subject-min-length': [2, 'always', 10], + 'type-enum': [2, 'always', ['ci', 'docs', 'feature', 'fix', 'improvement', 'perf', 'refactor', 'revert', 'style', 'test', 'unit-test', 'build']], + 'type-empty': [2, 'never'], + 'scope-empty': [2, 'never'], + 'scope-min-length': [2, 'always', 3], + 'body-min-length': [2, 'always', 15], + 'body-max-line-length': [2, 'always', 120], + 'body-leading-blank': [2, 'always'], + }, + parserPreset: { + parserOpts: { + noteKeywords: ['\\[\\d+\\]'] + } + } +}; diff --git a/docker/docker-compose-scylla.yml b/docker/docker-compose-scylla.yml index 34d8e45..d9e266f 100644 --- a/docker/docker-compose-scylla.yml +++ b/docker/docker-compose-scylla.yml @@ -9,15 +9,19 @@ networks: services: gemini-oracle: - image: scylladb/scylla:${SCYLLA_ORACLE_VERSION:-6.1.1} + image: scylladb/scylla:${SCYLLA_ORACLE_VERSION:-6.2} container_name: gemini-oracle - command: --smp 1 --memory 512M --api-address 0.0.0.0 + restart: unless-stopped + command: --smp 1 --memory 1024M --api-address 0.0.0.0 networks: gemini: + ipv4_address: 192.168.100.2 gemini-test: - image: scylladb/scylla:${SCYLLA_TEST_VERSION:-6.1.1} + image: scylladb/scylla:${SCYLLA_TEST_VERSION:-6.2} container_name: gemini-test - command: --smp 1 --memory 512M --api-address 0.0.0.0 + restart: unless-stopped + command: --smp 2 --memory 1024M --api-address 0.0.0.0 networks: gemini: + ipv4_address: 192.168.100.3 diff --git a/go.mod b/go.mod index 5862877..4b5efca 100644 --- a/go.mod +++ b/go.mod @@ -15,9 +15,9 @@ require ( github.com/spf13/cobra v1.8.1 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 - golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c - golang.org/x/net v0.30.0 - golang.org/x/sync v0.8.0 + golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f + golang.org/x/net v0.31.0 + golang.org/x/sync v0.9.0 gonum.org/v1/gonum v0.15.1 gopkg.in/inf.v0 v0.9.1 ) @@ -37,9 +37,9 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/scylladb/go-reflectx v1.0.1 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/term v0.25.0 // indirect - google.golang.org/protobuf v1.35.1 // indirect + golang.org/x/sys v0.27.0 // indirect + golang.org/x/term v0.26.0 // indirect + google.golang.org/protobuf v1.35.2 // indirect ) replace github.com/gocql/gocql => github.com/scylladb/gocql v1.14.3 diff --git a/go.sum b/go.sum index 1bf37a7..8a28967 100644 --- a/go.sum +++ b/go.sum @@ -4,19 +4,14 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYE github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/briandowns/spinner v1.23.0 h1:alDF2guRWqa/FOZZYWjlMIx2L6H0wyewPxo/CH4Pt2A= -github.com/briandowns/spinner v1.23.0/go.mod h1:rPG4gmXeN3wQV/TsAY4w8lPdIM6RX3yqeBQJSrbXjuE= github.com/briandowns/spinner v1.23.1 h1:t5fDPmScwUjozhDj4FA46p5acZWIPXYE30qW2Ptu650= github.com/briandowns/spinner v1.23.1/go.mod h1:LaZeM4wm2Ywy6vO571mvhQNRcWfRUnXOs0RcKV0wYKM= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= 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/fatih/set v0.2.1 h1:nn2CaJyknWE/6txyUDGwysr3G5QC6xWB/PtVjPBbeaA= @@ -31,8 +26,6 @@ github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -42,6 +35,8 @@ 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/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -55,18 +50,10 @@ 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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= -github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= -github.com/prometheus/client_golang v1.20.0 h1:jBzTZ7B099Rg24tny+qngoynol8LtVYlA2bqx3vEloI= -github.com/prometheus/client_golang v1.20.0/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8= -github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= @@ -82,69 +69,43 @@ github.com/scylladb/gocql v1.14.3 h1:f6ZFxM9plyAk0h7NZcXfZ1aJu3cGk0Mjy/X293gqIFA github.com/scylladb/gocql v1.14.3/go.mod h1:ZLEJ0EVE5JhmtxIW2stgHq/v1P4fWap0qyyXSKyV8K0= github.com/scylladb/gocqlx/v2 v2.8.0 h1:f/oIgoEPjKDKd+RIoeHqexsIQVIbalVmT+axwvUqQUg= github.com/scylladb/gocqlx/v2 v2.8.0/go.mod h1:4/+cga34PVqjhgSoo5Nr2fX1MQIqZB5eCE5DK4xeDig= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= 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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/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= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM= -golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI= -golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa h1:ELnwvuAXPNtPk1TJRuGkI9fDTwym6AYBu0qzT8AcHdI= -golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= -golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= +golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo= +golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ= -gonum.org/v1/gonum v0.15.0/go.mod h1:xzZVBJBtS+Mz4q0Yl2LJTk+OxOg4jiXZ7qBoM0uISGo= gonum.org/v1/gonum v0.15.1 h1:FNy7N6OUZVUaWG9pTiD+jlhdQ3lMP+/LcTpJ6+a8sQ0= gonum.org/v1/gonum v0.15.1/go.mod h1:eZTZuRFrzu5pcyjN5wJhcIhnUdNijYxX1T2IcrOGY0o= -google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= -google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= diff --git a/pkg/typedef/typedef_test.go b/pkg/typedef/typedef_test.go index daecb3c..d12037b 100644 --- a/pkg/typedef/typedef_test.go +++ b/pkg/typedef/typedef_test.go @@ -19,7 +19,6 @@ import ( "fmt" "math/big" "net" - "strings" "testing" "time" @@ -121,64 +120,17 @@ func TestPrettyCQL(t *testing.T) { } } -func prettyCQLOld(query string, values Values, types Types) string { - if len(values) == 0 { - return query - } - - k := 0 - out := make([]string, 0, len(values)*2) - queryChunks := strings.Split(query, "?") - out = append(out, queryChunks[0]) - qID := 1 - builder := bytes.NewBuffer(nil) - for _, typ := range types { - builder.Reset() - tupleType, ok := typ.(*TupleType) - if !ok { - _ = typ.CQLPretty(builder, values[k]) - out = append(out, builder.String()) - out = append(out, queryChunks[qID]) - qID++ - k++ - continue - } - for _, t := range tupleType.ValueTypes { - builder.Reset() - _ = t.CQLPretty(builder, values[k]) - out = append(out, builder.String()) - out = append(out, queryChunks[qID]) - qID++ - k++ - } - } - out = append(out, queryChunks[qID:]...) - return strings.Join(out, "") -} - -func BenchmarkPrettyCQLOLD(b *testing.B) { - b.Run("New", func(b *testing.B) { - b.ReportAllocs() - b.ResetTimer() +func BenchmarkPrettyCQL(b *testing.B) { + b.ReportAllocs() + b.ResetTimer() - for i := 0; i < b.N; i++ { - query, _ := stmt.Query.ToCql() - values := stmt.Values.Copy() - builder := bytes.NewBuffer(nil) + for i := 0; i < b.N; i++ { + query, _ := stmt.Query.ToCql() + values := stmt.Values.Copy() + builder := bytes.NewBuffer(nil) - if err := prettyCQL(builder, query, values, stmt.Types); err != nil { - b.Error(err) - } + if err := prettyCQL(builder, query, values, stmt.Types); err != nil { + b.Error(err) } - }) - - b.Run("Old", func(b *testing.B) { - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - query, _ := stmt.Query.ToCql() - values := stmt.Values.Copy() - prettyCQLOld(query, values, stmt.Types) - } - }) + } }