Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Dec 12, 2023
1 parent a28ca3d commit 022a207
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 28 deletions.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions k6/load-tests/graphql/components.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { sleep } from "k6";
import http from "k6/http";

import { DISTRIBUTION, PROJECT_ID } from "../utils.js";

import { getHeaders, getUrl } from "./utils.js";
import { getHeaders, getUrl } from "../../graphql-utils.js";
import { DISTRIBUTION, PROJECT_ID } from "../../k6-utils.js";

const query = `query Components(
$iri: String!
Expand Down
5 changes: 2 additions & 3 deletions k6/load-tests/graphql/observations.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { sleep } from "k6";
import http from "k6/http";

import { DISTRIBUTION, PROJECT_ID } from "../utils.js";

import { getHeaders, getUrl } from "./utils.js";
import { getHeaders, getUrl } from "../../graphql-utils.js";
import { DISTRIBUTION, PROJECT_ID } from "../../k6-utils.js";

const query = `query DataCubeObservations(
$iri: String!
Expand Down
2 changes: 1 addition & 1 deletion k6/load-tests/har/int/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { group, sleep } from "k6";
import http from "k6/http";

import { DISTRIBUTION, PROJECT_ID } from "../../utils.js";
import { DISTRIBUTION, PROJECT_ID } from "../../../k6-utils.js";

const enableCache = __ENV.ENABLE_GQL_SERVER_SIDE_CACHE === "true";
const cache = enableCache ? "cache" : "no-cache";
Expand Down
2 changes: 1 addition & 1 deletion k6/load-tests/har/prod/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { group, sleep } from "k6";
import http from "k6/http";

import { DISTRIBUTION, PROJECT_ID } from "../../utils.js";
import { DISTRIBUTION, PROJECT_ID } from "../../../k6-utils.js";

const enableCache = __ENV.ENABLE_GQL_SERVER_SIDE_CACHE === "true";
const cache = enableCache ? "cache" : "no-cache";
Expand Down
2 changes: 1 addition & 1 deletion k6/load-tests/har/test/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { group, sleep } from "k6";
import http from "k6/http";

import { DISTRIBUTION, PROJECT_ID } from "../../utils.js";
import { DISTRIBUTION, PROJECT_ID } from "../../../k6-utils.js";

const enableCache = __ENV.ENABLE_GQL_SERVER_SIDE_CACHE === "true";
const cache = enableCache ? "cache" : "no-cache";
Expand Down
41 changes: 22 additions & 19 deletions k6/performance-tests/graphql/metadata.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { sleep } from "k6";
import exec from "k6/execution";
import http from "k6/http";

import { DISTRIBUTION } from "../utils.js";

import { getHeaders, getUrl } from "./utils.js";

const query = `query DataCubeMetadata(
$sourceType: String!
$sourceUrl: String!
Expand All @@ -20,36 +16,43 @@ const query = `query DataCubeMetadata(
}`;

const variables = {
iri: "https://environment.ld.admin.ch/foen/ubd003701/2",
locale: "en",
sourceType: "sparql",
sourceUrl: "https://lindas.admin.ch/query",
locale: "en",
componentIris: [
"https://environment.ld.admin.ch/foen/ubd003701/beurteilung",
"https://environment.ld.admin.ch/foen/ubd003701/gemeindetype",
"https://environment.ld.admin.ch/foen/ubd003701/laermbelasteteeinheit",
],
cubeFilter: {
iri: "https://culture.ld.admin.ch/sfa/StateAccounts_Office/4/",
},
};

const env = __ENV.ENV;
const env = __ENV.ENV || "prod";
const enableCache = __ENV.ENABLE_GQL_SERVER_SIDE_CACHE === "true";

/** @type {import("k6/options").Options} */
export const options = {
iterations: 1,
ext: {
loadimpact: {
name: `GraphQL - Components (${env.toUpperCase()}, GQL ${
name: `GraphQL - DataCubeMetadata (${env.toUpperCase()}, GQL ${
enableCache ? "cache" : "no-cache"
})`,
distribution: DISTRIBUTION,
},
},
};

export default function Components() {
http.post(getUrl(env), JSON.stringify({ query, variables }), {
headers: getHeaders(enableCache),
});
sleep(1);
// Set tags for metrics
exec.vu.metrics.tags.env = "int";
exec.vu.metrics.tags.cube = "StateAccounts_Office/4/";

http.post(
"https://int.visualize.admin.ch/api/graphql",
JSON.stringify({ query, variables }),
{
headers: {
"Content-Type": "application/json",
},
}
);
}

// docker run --rm -e K6_PROMETHEUS_RW_USERNAME=thanos-receive -e K6_PROMETHEUS_RW_PASSWORD=owOwbyeHubry -e K6_PROMETHEUS_RW_SERVER_URL=https://thanos-receive.cluster.ldbar.ch/api/v1/receive -i grafana/k6 run -o experimental-prometheus-rw --tag testid=DataCubeMetadata_StateAccountsOffice4 - <k6/performance-tests/graphql/metadata.js

0 comments on commit 022a207

Please sign in to comment.