Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
bc3a7181
Unverified
Commit
bc3a7181
authored
May 24, 2019
by
Marcus Efraimsson
Committed by
GitHub
May 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
devenv: adds auth proxy load test (#17271)
parent
2a52dbfb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
2 deletions
+72
-2
devenv/docker/loadtest/README.md
+10
-0
devenv/docker/loadtest/auth_proxy_test.js
+56
-0
devenv/docker/loadtest/run.sh
+6
-2
No files found.
devenv/docker/loadtest/README.md
View file @
bc3a7181
...
...
@@ -6,6 +6,9 @@ Runs load tests and checks using [k6](https://k6.io/).
Docker
To run the auth proxy test you'll need to setup nginx proxy from docker block and
enable auth proxy together with configuring Grafana for auth proxy.
## Run
Run load test for 15 minutes using 2 virtual users and targeting http://localhost:3000.
...
...
@@ -32,6 +35,13 @@ Run load test for 10 virtual users:
$
./run.sh
-v
10
```
Run auth proxy test:
```
bash
$
./run.sh
-c
auth_proxy_test
```
Example output:
```
bash
...
...
devenv/docker/loadtest/auth_proxy_test.js
0 → 100644
View file @
bc3a7181
import
{
sleep
,
check
,
group
}
from
'k6'
;
import
{
createBasicAuthClient
}
from
'./modules/client.js'
;
export
let
options
=
{
noCookiesReset
:
true
};
let
endpoint
=
__ENV
.
URL
||
'http://localhost:10080/grafana'
;
const
client
=
createBasicAuthClient
(
endpoint
,
'user1'
,
'grafana'
);
client
.
withOrgId
(
1
);
export
const
setup
=
()
=>
{
const
adminClient
=
createBasicAuthClient
(
endpoint
,
'admin'
,
'admin'
);
let
res
=
adminClient
.
datasources
.
getByName
(
'gdev-prometheus'
);
if
(
res
.
status
!==
200
)
{
throw
new
Error
(
'Expected 200 response status when creating datasource'
);
}
return
{
datasourceId
:
res
.
json
().
id
,
};
}
export
default
(
data
)
=>
{
group
(
"auth proxy test"
,
()
=>
{
group
(
"batch proxy requests"
,
()
=>
{
const
d
=
new
Date
();
const
batchCount
=
300
;
const
requests
=
[];
const
query
=
encodeURI
(
'topk(5, max(scrape_duration_seconds) by (job))'
);
const
start
=
(
d
.
getTime
()
/
1000
)
-
3600
;
const
end
=
(
d
.
getTime
()
/
1000
);
const
step
=
20
;
requests
.
push
({
method
:
'GET'
,
url
:
'/api/annotations?dashboardId=8&from=1558670300607&to=1558691900607'
});
for
(
let
n
=
0
;
n
<
batchCount
;
n
++
)
{
requests
.
push
({
method
:
'GET'
,
url
:
`/api/datasources/proxy/
${
data
.
datasourceId
}
/api/v1/query_range?query=
${
query
}
&start=
${
start
}
&end=
${
end
}
&step=
${
step
}
`
,
});
}
let
responses
=
client
.
batch
(
requests
);
for
(
let
n
=
0
;
n
<
batchCount
;
n
++
)
{
check
(
responses
[
n
],
{
'response status is 200'
:
(
r
)
=>
r
.
status
===
200
,
});
}
});
});
sleep
(
5
)
}
export
const
teardown
=
(
data
)
=>
{}
devenv/docker/loadtest/run.sh
View file @
bc3a7181
...
...
@@ -6,8 +6,9 @@ run() {
duration
=
'15m'
url
=
'http://localhost:3000'
vus
=
'2'
testcase
=
'auth_token_test'
while
getopts
":d:u:v:"
o
;
do
while
getopts
":d:u:v:
c:
"
o
;
do
case
"
${
o
}
"
in
d
)
duration
=
${
OPTARG
}
...
...
@@ -18,11 +19,14 @@ run() {
v
)
vus
=
${
OPTARG
}
;;
c
)
testcase
=
${
OPTARG
}
;;
esac
done
shift
$((
OPTIND-1
))
docker run
-t
--network
=
host
-v
$PWD
:/src
-e
URL
=
$url
--rm
-i
loadimpact/k6:master run
--vus
$vus
--duration
$duration
src/
auth_token_test
.js
docker run
-t
--network
=
host
-v
$PWD
:/src
-e
URL
=
$url
--rm
-i
loadimpact/k6:master run
--vus
$vus
--duration
$duration
src/
$testcase
.js
}
run
"
$@
"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment