|
| 1 | +import http from 'k6/http'; |
| 2 | + |
| 3 | +const CORE_API_TOKEN = "UID2-O-L-999-dp9Dt0.JVoGpynN4J8nMA7FxmzsavxJa8B9H74y9xdEE="; // Mock token for E2E tests |
| 4 | +const CORE_BASE_URL = 'http://localhost:8088'; |
| 5 | + |
| 6 | +const AUTH_HEADERS = { headers: { 'Authorization': `Bearer ${CORE_API_TOKEN}` }}; |
| 7 | +const HEADERS = { headers: { ...AUTH_HEADERS.headers, 'X-UID2-AppVersion': 'uid2-operator=0.0.0-local-load-test' }}; |
| 8 | + |
| 9 | +const DURATION = '1m'; |
| 10 | +const RATE_MULTIPLIER = 10; |
| 11 | + |
| 12 | +export const options = { |
| 13 | + scenarios: { |
| 14 | + ops_healthcheck: { |
| 15 | + executor: 'constant-arrival-rate', |
| 16 | + exec: 'opsHealthcheck', |
| 17 | + duration: DURATION, |
| 18 | + rate: 4 * RATE_MULTIPLIER, |
| 19 | + timeUnit: '1s', |
| 20 | + preAllocatedVUs: 1000, |
| 21 | + maxVUs: 1000, |
| 22 | + }, |
| 23 | + |
| 24 | + attest: { |
| 25 | + executor: 'constant-arrival-rate', |
| 26 | + exec: 'attest', |
| 27 | + duration: DURATION, |
| 28 | + rate: 1 * RATE_MULTIPLIER, |
| 29 | + timeUnit: '1s', |
| 30 | + preAllocatedVUs: 1000, |
| 31 | + maxVUs: 1000, |
| 32 | + }, |
| 33 | + |
| 34 | + clients_refresh: { |
| 35 | + executor: 'constant-arrival-rate', |
| 36 | + exec: 'clientsRefresh', |
| 37 | + duration: DURATION, |
| 38 | + rate: 16 * RATE_MULTIPLIER, |
| 39 | + timeUnit: '1s', |
| 40 | + preAllocatedVUs: 1000, |
| 41 | + maxVUs: 1000, |
| 42 | + }, |
| 43 | + keysets_refresh: { |
| 44 | + executor: 'constant-arrival-rate', |
| 45 | + exec: 'keysetRefresh', |
| 46 | + duration: DURATION, |
| 47 | + rate: 16 * RATE_MULTIPLIER, |
| 48 | + timeUnit: '1s', |
| 49 | + preAllocatedVUs: 1000, |
| 50 | + maxVUs: 1000, |
| 51 | + }, |
| 52 | + keyset_keys_refresh: { |
| 53 | + executor: 'constant-arrival-rate', |
| 54 | + exec: 'keysetKeysRefresh', |
| 55 | + duration: DURATION, |
| 56 | + rate: 16 * RATE_MULTIPLIER, |
| 57 | + timeUnit: '1s', |
| 58 | + preAllocatedVUs: 1000, |
| 59 | + maxVUs: 1000, |
| 60 | + }, |
| 61 | + salt_refresh: { |
| 62 | + executor: 'constant-arrival-rate', |
| 63 | + exec: 'saltRefresh', |
| 64 | + duration: DURATION, |
| 65 | + rate: 16 * RATE_MULTIPLIER, |
| 66 | + timeUnit: '1s', |
| 67 | + preAllocatedVUs: 1000, |
| 68 | + maxVUs: 1000, |
| 69 | + }, |
| 70 | + |
| 71 | + sites_refresh: { |
| 72 | + executor: 'constant-arrival-rate', |
| 73 | + exec: 'sitesRefresh', |
| 74 | + duration: DURATION, |
| 75 | + rate: 9 * RATE_MULTIPLIER, |
| 76 | + timeUnit: '1s', |
| 77 | + preAllocatedVUs: 1000, |
| 78 | + maxVUs: 1000, |
| 79 | + }, |
| 80 | + cstg_refresh: { |
| 81 | + executor: 'constant-arrival-rate', |
| 82 | + exec: 'clientSideKeypairsRefresh', |
| 83 | + duration: DURATION, |
| 84 | + rate: 9 * RATE_MULTIPLIER, |
| 85 | + timeUnit: '1s', |
| 86 | + preAllocatedVUs: 1000, |
| 87 | + maxVUs: 1000, |
| 88 | + }, |
| 89 | + services_refresh: { |
| 90 | + executor: 'constant-arrival-rate', |
| 91 | + exec: 'servicesRefresh', |
| 92 | + duration: DURATION, |
| 93 | + rate: 9 * RATE_MULTIPLIER, |
| 94 | + timeUnit: '1s', |
| 95 | + preAllocatedVUs: 1000, |
| 96 | + maxVUs: 1000, |
| 97 | + }, |
| 98 | + service_links_refresh: { |
| 99 | + executor: 'constant-arrival-rate', |
| 100 | + exec: 'serviceLinksRefresh', |
| 101 | + duration: DURATION, |
| 102 | + rate: 9 * RATE_MULTIPLIER, |
| 103 | + timeUnit: '1s', |
| 104 | + preAllocatedVUs: 1000, |
| 105 | + maxVUs: 1000, |
| 106 | + }, |
| 107 | + }, |
| 108 | +}; |
| 109 | + |
| 110 | +// Scenarios |
| 111 | +export async function opsHealthcheck(data) { |
| 112 | + http.get(`${CORE_BASE_URL}/ops/healthcheck`); |
| 113 | +} |
| 114 | + |
| 115 | +export async function attest(data) { |
| 116 | + const validTrustedAttestationRequest = '{"attestation_request":"AA==","public_key":"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl7kXK1wf15V9HgkQhbMK2nfJGbudmdXNrX7MZjFm07z6eEjaQsuqMteQumLRwn+RxEcXKVaxBAE3RQTFL9XsZc2OtRKOU+oMIQep8tmPFMgh83BzjLs5O5HZf510geFJO6qRqc3UHJT3ACxE7IkmRx1JIKFKPzTrthHdb2+D7bdJBPsVbwk7y+a36f5jvELGGzMC89LAvd7JpOmGsCAj6jwiEAKmmLId9bfe0YeLuebl95VfSzrQVdz82oGGQKXuJgKZtc/Xp1omZ9spm+zzVFJzsimxDdGdnaWMnas43VoTE04JDt+pucJTTbftIvu05frwkbZh3sQ2yBu5gBP7YwIDAQAB","application_name":"uid2-operator","application_version":"5.27.10-3f25586306","components":{"uid2-attestation-api":"2.0.0-f968aec0e3","uid2-shared":"7.2.4-SNAPSHOT"}}'; |
| 117 | + http.post(`${CORE_BASE_URL}/attest`, validTrustedAttestationRequest, AUTH_HEADERS); |
| 118 | +} |
| 119 | + |
| 120 | +export async function clientsRefresh(data) { |
| 121 | + http.get(`${CORE_BASE_URL}/clients/refresh`, HEADERS); |
| 122 | +} |
| 123 | + |
| 124 | +export async function keysetRefresh(data) { |
| 125 | + http.get(`${CORE_BASE_URL}/key/keyset/refresh`, HEADERS); |
| 126 | +} |
| 127 | + |
| 128 | +export async function keysetKeysRefresh(data) { |
| 129 | + http.get(`${CORE_BASE_URL}/key/keyset-keys/refresh`, HEADERS); |
| 130 | +} |
| 131 | + |
| 132 | +export async function saltRefresh(data) { |
| 133 | + http.get(`${CORE_BASE_URL}/salt/refresh`, HEADERS); |
| 134 | +} |
| 135 | + |
| 136 | +export async function sitesRefresh(data) { |
| 137 | + http.get(`${CORE_BASE_URL}/sites/refresh`, HEADERS); |
| 138 | +} |
| 139 | + |
| 140 | +export async function clientSideKeypairsRefresh(data) { |
| 141 | + http.get(`${CORE_BASE_URL}/client_side_keypairs/refresh`, HEADERS); |
| 142 | +} |
| 143 | + |
| 144 | +export async function servicesRefresh(data) { |
| 145 | + http.get(`${CORE_BASE_URL}/services/refresh`, HEADERS); |
| 146 | +} |
| 147 | + |
| 148 | +export async function serviceLinksRefresh(data) { |
| 149 | + http.get(`${CORE_BASE_URL}/service_links/refresh`, HEADERS); |
| 150 | +} |
0 commit comments