vesoft-inc / k6-plugin

Apache License 2.0
9 stars 9 forks source link

support http2 and ssl #43

Closed HarrisChu closed 1 year ago

HarrisChu commented 1 year ago

support http2 and ssl

PLEASE NOTE:

as nebula-go uses a replaced mod, should build with several complicated steps:

  1. export XK6_SKIP_CLEANUP=1 && make build-dev
  2. cd the build directory, and then add replace in go.mod, github.com/facebook/fbthrift => github.com/vesoft-inc/fbthrift v0.0.0-20230214024353-fa2f34755b28
  3. go mod, and then build with command. e.g. go build -o k6 -ldflags "-w -s" -trimpath

Usage:

import nebulaPool from 'k6/x/nebulagraph';
import { check } from 'k6';
import { Trend } from 'k6/metrics';
import { sleep } from 'k6';

var latencyTrend = new Trend('latency');
var responseTrend = new Trend('responseTime');

# enable http2
nebulaPool.enableHttp2()

# communicate service with SSL connection
nebulaPool.setSSLConfig("ca.pem", "client.pem", "client.key")

// initial nebula connect pool
var pool = nebulaPool.init("192.168.15.32:10030", 400);

// initial session for every vu
var session = pool.getSession("root", "nebula")
session.execute("USE sf0_1")
...(as before)