Skip to content

Commit

Permalink
Merge pull request #58 from samof76/add-clickhouse-support
Browse files Browse the repository at this point in the history
Adding clickhouse support in k6.
  • Loading branch information
pablochacin authored Apr 15, 2024
2 parents 7e9df88 + 308d9dc commit fe5fbf5
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 22 deletions.
27 changes: 27 additions & 0 deletions examples/clickhouse_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sql from 'k6/x/sql';

const db = sql.open("clickhouse", "clickhouse://127.0.0.1:19000");

export function setup() {
db.exec(`CREATE TABLE IF NOT EXISTS hits_by_user_url
(
UserID UInt32,
URL String,
EventTime DateTime
)
ENGINE = MergeTree
PRIMARY KEY (UserID, URL)
ORDER BY (UserID, URL, EventTime)
SETTINGS index_granularity = 8192, index_granularity_bytes = 0;`);
}

export function teardown() {
db.close();
}

export default function () {
db.exec(`INSERT INTO hits_by_user_url
(UserID, URL, EventTime)
SELECT * FROM generateRandom('UserID UInt32, URL String, EventTime DateTime')
LIMIT 100;`);
}
23 changes: 18 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ require (
github.com/lib/pq v1.10.9
github.com/mattn/go-sqlite3 v1.14.18
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
go.k6.io/k6 v0.47.0
)

require (
github.com/ClickHouse/clickhouse-go/v2 v2.22.0
github.com/dop251/goja v0.0.0-20231027120936-b396bb4c349d
github.com/microsoft/go-mssqldb v1.6.0
github.com/spf13/afero v1.11.0
Expand All @@ -22,29 +23,41 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 // indirect
github.com/ClickHouse/ch-go v0.61.5 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-sourcemap/sourcemap v2.1.4-0.20211119122758-180fcef48034+incompatible // indirect
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/google/pprof v0.0.0-20231127191134-f3a68a39ae15 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mstoykov/atlas v0.0.0-20220811071828-388f114305dd // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/onsi/gomega v1.27.6 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/serenize/snaker v0.0.0-20201027110005-a7ad2135616e // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
gopkg.in/guregu/null.v3 v3.5.0 // indirect
Expand Down
Loading

0 comments on commit fe5fbf5

Please sign in to comment.