Skip to content

Commit

Permalink
Remove test enable auth option from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zalbiraw committed Jun 3, 2024
1 parent 12b2e50 commit 0af1603
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 18 deletions.
4 changes: 3 additions & 1 deletion modules/deployments/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ const addTestInfoMetrics = ({ duration, rate, virtual_users }, key_count) => {
virtualUsersGauge.add(virtual_users);
};
export { getScenarios, addTestInfoMetrics };
const getAuth = () => ${var.auth.enabled};
export { getAuth, getScenarios, addTestInfoMetrics };
EOF
}
Expand Down
6 changes: 3 additions & 3 deletions modules/tests/httpbin/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "kubernetes_config_map" "httpbin-configmap" {
data = {
"httpbin.js" = <<EOF
import http from 'k6/http';
import { getScenarios, addTestInfoMetrics } from "/helpers/tests.js";
import { getAuth, getScenarios, addTestInfoMetrics } from "/helpers/tests.js";
import { generateKeys } from "/helpers/auth.js";
const { SCENARIO } = __ENV;
Expand All @@ -27,15 +27,15 @@ export const options = {
export function setup() {
addTestInfoMetrics(${jsonencode(var.config)}, ${var.config.auth.key_count});
if (${var.config.auth.enabled}) {
if (getAuth()) {
return generateKeys("httpbin", ${var.config.auth.key_count})
}
return {};
}
export default function (keys) {
let headers = {};
if (${var.config.auth.enabled}) {
if (getAuth()) {
const i = Math.floor(Math.random() * keys.length);
headers = { "Authorization": keys[i] }
}
Expand Down
1 change: 0 additions & 1 deletion modules/tests/httpbin/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ variable "config" {
parallelism = number

auth = object({
enabled = bool
key_count = number
})
})
Expand Down
6 changes: 3 additions & 3 deletions modules/tests/timestamp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "kubernetes_config_map" "timestamp-configmap" {
data = {
"timestamp.js" = <<EOF
import http from 'k6/http';
import { getScenarios, addTestInfoMetrics } from "/helpers/tests.js";
import { getAuth, getScenarios, addTestInfoMetrics } from "/helpers/tests.js";
import { generateKeys } from "/helpers/auth.js";
const { SCENARIO } = __ENV;
Expand All @@ -27,15 +27,15 @@ export const options = {
export function setup() {
addTestInfoMetrics(${jsonencode(var.config)}, ${var.config.auth.key_count});
if (${var.config.auth.enabled}) {
if (getAuth()) {
return generateKeys("timestamp", ${var.config.auth.key_count})
}
return {};
}
export default function (keys) {
let headers = {};
if (${var.config.auth.enabled}) {
if (getAuth()) {
const i = Math.floor(Math.random() * keys.length);
headers = { "Authorization": keys[i] }
}
Expand Down
1 change: 0 additions & 1 deletion modules/tests/timestamp/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ variable "config" {
parallelism = number

auth = object({
enabled = bool
key_count = number
})
})
Expand Down
1 change: 0 additions & 1 deletion modules/tests/vars.tests.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ variable "tests" {
parallelism = number

auth = object({
enabled = bool
key_count = number
})
})
Expand Down
1 change: 0 additions & 1 deletion tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module "tests" {
parallelism = var.tests_config_parallelism

auth = {
enabled = var.tests_config_auth_enabled
key_count = var.tests_config_auth_key_count
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/main.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ tests_timestamp_enabled = true
tests_httpbin_enabled = false

tests_config_executor = "constant-arrival-rate"
tests_config_auth_enabled = false
tests_config_auth_key_count = 100
tests_config_ramping_steps = 10
tests_config_duration = 15
Expand Down
6 changes: 0 additions & 6 deletions tests/vars.tests.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ variable "tests_config_executor" {
description = "Choose the executor for the test. Options are: 'constant-vus', 'ramping-vus', 'constant-arrival-rate', 'ramping-arrival-rate'."
}

variable "tests_config_auth_enabled" {
type = bool
default = false
description = "Enable Token Authentication."
}

variable "tests_config_auth_key_count" {
type = number
default = 100
Expand Down

0 comments on commit 0af1603

Please sign in to comment.