Skip to content

Commit

Permalink
Make the load test path through the S11 bouncer
Browse files Browse the repository at this point in the history
  • Loading branch information
Footur committed Jan 13, 2025
1 parent 841f2d1 commit 85da1af
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions operations/k6/load-testing-with-k6.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ const READ_TENANT_ID = __ENV.K6_READ_TENANT_ID || '';
*/
const PROJECT_ID = __ENV.K6_PROJECT_ID || '';

/**
* SysEleven API Key
*
*/
const S11_BEARER_TOKEN = __ENV.K6_S11_BEARER_TOKEN || '';

const FGA_ORG_ID = __ENV.K6_FGA_ORG_ID || '';
const FGA_PROJECT_ID = __ENV.K6_FGA_PROJECT_ID || '';

const remote_write_url = get_remote_write_url();
console.debug("Remote write URL:", remote_write_url)

Expand All @@ -133,7 +142,7 @@ get_read_authentication_headers().forEach((value, key) => {
})

const query_client = new Httpx({
baseURL: `${SCHEME}://${READ_HOSTNAME}/prometheus/api/v1`,
baseURL: `${SCHEME}://${READ_HOSTNAME}/${FGA_ORG_ID}/${FGA_PROJECT_ID}/prometheus/api/v1`,
headers: query_client_headers,
timeout: 120e3 // 120s timeout.
});
Expand Down Expand Up @@ -511,7 +520,7 @@ function align_timestamp_to_step(ts, step) {
* @returns {string}
*/
function get_remote_write_url() {
return `${SCHEME}://${WRITE_HOSTNAME}/api/v1/push`;
return `${SCHEME}://${WRITE_HOSTNAME}/${FGA_ORG_ID}/${FGA_PROJECT_ID}/api/v1/push`;
}

/**
Expand All @@ -521,6 +530,8 @@ function get_remote_write_url() {
function get_read_authentication_headers() {
let auth_headers = new Map();

auth_headers.set('Authorization', `Bearer ${S11_BEARER_TOKEN}`)

if (READ_USERNAME !== '' || READ_TOKEN !== '') {
auth_headers.set('Authorization', `Basic ${encoding.b64encode(`${READ_USERNAME}:${READ_TOKEN}`)}`)
}
Expand All @@ -539,6 +550,8 @@ function get_read_authentication_headers() {
function get_write_authentication_headers() {
let auth_headers = new Map();

auth_headers.set('Authorization', `Bearer ${S11_BEARER_TOKEN}`)

if (WRITE_USERNAME !== '' || WRITE_TOKEN !== '') {
auth_headers.set('Authorization', `Basic ${encoding.b64encode(`${WRITE_USERNAME}:${WRITE_TOKEN}`)}`)
}
Expand Down

0 comments on commit 85da1af

Please sign in to comment.