-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add insert scenario * fix github action
- Loading branch information
Showing
8 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from nebula_bench.scenarios import go | ||
from nebula_bench.scenarios import find_path | ||
from nebula_bench.scenarios import insert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# -*- encoding: utf-8 -*- | ||
from nebula_bench.common.base import BaseScenario | ||
|
||
|
||
class InsertPersonScenario(BaseScenario): | ||
is_insert_scenario = True | ||
nGQL = "INSERT VERTEX Person(firstName, lastName, gender, birthday, creationDate, locationIP, browserUsed) VALUES " | ||
abstract = False | ||
csv_path = "social_network/dynamic/person.csv" | ||
csv_index = [1, 2, 3, 4, 5, 6, 7] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import nebulaPool from 'k6/x/nebulagraph'; | ||
import { check } from 'k6'; | ||
import { Trend } from 'k6/metrics'; | ||
import { sleep } from 'k6'; | ||
|
||
var lantencyTrend = new Trend('latency'); | ||
var responseTrend = new Trend('responseTime'); | ||
// initial nebula connect pool | ||
var pool = nebulaPool.initWithSize("{{ address }}", 2000, 4000); | ||
|
||
// set csv strategy, 1 means each vu has a separate csv reader. | ||
pool.configCsvStrategy(1) | ||
|
||
// initial session for every vu | ||
var session = pool.getSession("{{ user }}", "{{ password }}") | ||
session.execute("USE {{ space }}") | ||
|
||
|
||
export function setup() { | ||
// config csv file | ||
pool.configCSV("{{ csv_path }}", "|", false) | ||
// config output file, save every query information | ||
pool.configOutput("{{ output_path }}") | ||
sleep(1) | ||
} | ||
|
||
export default function (data) { | ||
let ngql = '{{ nGQL }}' | ||
let batches = [] | ||
let batchSize = 100 | ||
// batch size 100 | ||
for (let i = 0; i < batchSize; i++) { | ||
let d = session.getData(); | ||
let values = [] | ||
let arr = [{{ csv_index }}] | ||
arr.forEach(function(e){ | ||
let value = '"' + d[e] + '"' | ||
values.push(value) | ||
}) | ||
|
||
let batch = d[0] + ":(" + values.join(",") + ")" | ||
batches.push(batch) | ||
} | ||
ngql = ngql + batches.join(',') | ||
let response = session.execute(ngql) | ||
check(response, { | ||
"IsSucceed": (r) => r.isSucceed() === true | ||
}); | ||
// add trend | ||
lantencyTrend.add(response.getLatency()); | ||
responseTrend.add(response.getResponseTime()); | ||
}; | ||
|
||
export function teardown() { | ||
pool.close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters