mirror of https://github.com/Squidex/squidex.git
4 changed files with 100 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||||
|
version: '3.4' |
||||
|
|
||||
|
networks: |
||||
|
grafana: |
||||
|
|
||||
|
services: |
||||
|
influxdb: |
||||
|
image: influxdb:latest |
||||
|
networks: |
||||
|
- grafana |
||||
|
ports: |
||||
|
- "8086:8086" |
||||
|
environment: |
||||
|
- INFLUXDB_DB=k6 |
||||
|
|
||||
|
grafana: |
||||
|
image: grafana/grafana:latest |
||||
|
networks: |
||||
|
- grafana |
||||
|
ports: |
||||
|
- "4000:3000" |
||||
|
environment: |
||||
|
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin |
||||
|
- GF_AUTH_ANONYMOUS_ENABLED=true |
||||
|
- GF_AUTH_BASIC_ENABLED=false |
||||
@ -0,0 +1,35 @@ |
|||||
|
import { check } from 'k6'; |
||||
|
import http from 'k6/http'; |
||||
|
import { variables, getBearerToken } from './shared.js'; |
||||
|
|
||||
|
export let options = { |
||||
|
stages: [ |
||||
|
{ duration: "2m", target: 200 }, |
||||
|
{ duration: "2m", target: 200 }, |
||||
|
{ duration: "2m", target: 0 }, |
||||
|
], |
||||
|
thresholds: { |
||||
|
'http_req_duration': ['p(99)<1500'], // 99% of requests must complete below 1.5s
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
export function setup() { |
||||
|
const token = getBearerToken(); |
||||
|
|
||||
|
return { token }; |
||||
|
} |
||||
|
|
||||
|
export default function (data) { |
||||
|
const url = `${variables.serverUrl}/api/apps/${variables.appName}/clients`; |
||||
|
|
||||
|
const response = http.get(url, { |
||||
|
headers: { |
||||
|
Authorization: `Bearer ${data.token}` |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
check(response, { |
||||
|
'is status 200': (r) => r.status === 200, |
||||
|
}); |
||||
|
} |
||||
@ -0,0 +1,35 @@ |
|||||
|
import http from 'k6/http'; |
||||
|
|
||||
|
export const variables = { |
||||
|
appName: getValue('APP__NAME', 'integration-tests'), |
||||
|
clientId: getValue('CLIENT__ID', 'root'), |
||||
|
clientSecret: getValue('CLIENT__SECRET', 'xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0='), |
||||
|
serverUrl: getValue('SERVER__URL', 'https://localhost:5001') |
||||
|
}; |
||||
|
|
||||
|
let bearerToken = null; |
||||
|
|
||||
|
export function getBearerToken() { |
||||
|
if (!bearerToken) { |
||||
|
const url = `${variables.serverUrl}/identity-server/connect/token`; |
||||
|
|
||||
|
const response = http.post(url, { |
||||
|
grant_type: 'client_credentials', |
||||
|
client_id: variables.clientId, |
||||
|
client_secret: variables.clientSecret, |
||||
|
scope: 'squidex-api' |
||||
|
}); |
||||
|
|
||||
|
const json = JSON.parse(response.body); |
||||
|
|
||||
|
bearerToken = json.access_token; |
||||
|
} |
||||
|
|
||||
|
return bearerToken; |
||||
|
} |
||||
|
|
||||
|
function getValue(key, fallback) { |
||||
|
const result = __ENV[key] || fallback; |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
Loading…
Reference in new issue