-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21d6f87
commit 24976b6
Showing
11 changed files
with
115 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import * as request from '../utils/request'; | ||
import { K6Interceptor } from '../utils/request'; | ||
import { sleep } from 'k6'; | ||
import { AuthRequest, AuthResponse } from '../types/user.type'; | ||
import * as request from '../utils/request' | ||
import { K6Interceptor } from '../utils/request' | ||
import { sleep } from 'k6' | ||
import { AuthRequest, AuthResponse } from '../types/user.type' | ||
|
||
const AUTH_ENDPOINT = 'auth/token/login/'; | ||
const AUTH_ENDPOINT = 'auth/token/login/' | ||
|
||
export function login( | ||
authUser: AuthRequest, | ||
interceptor?: K6Interceptor | ||
): void { | ||
const headers = request.headers(); | ||
request.post(AUTH_ENDPOINT, authUser, headers, interceptor); | ||
sleep(0.3); | ||
const headers = request.headers() | ||
request.post(AUTH_ENDPOINT, authUser, headers, interceptor) | ||
sleep(0.3) | ||
} | ||
|
||
export function getAuth({ | ||
username, | ||
password | ||
}: { | ||
username: string; | ||
password: string; | ||
username: string | ||
password: string | ||
}): string { | ||
const headers = request.headers(); | ||
const headers = request.headers() | ||
return request.post<AuthResponse>( | ||
AUTH_ENDPOINT, | ||
{ username, password }, | ||
headers | ||
).access; | ||
).access | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { sleep } from 'k6'; | ||
import * as request from '../utils/request'; | ||
import { K6Interceptor } from '../utils/request'; | ||
import { User } from '../types/user.type'; | ||
import { sleep } from 'k6' | ||
import * as request from '../utils/request' | ||
import { K6Interceptor } from '../utils/request' | ||
import { User } from '../types/user.type' | ||
|
||
const REGISTER_ENDPOINT = 'user/register/'; | ||
const REGISTER_ENDPOINT = 'user/register/' | ||
|
||
export function register(user: User, interceptor?: K6Interceptor): void { | ||
const headers = request.headers(); | ||
request.post(REGISTER_ENDPOINT, user, headers, interceptor); | ||
sleep(0.3); | ||
const headers = request.headers() | ||
request.post(REGISTER_ENDPOINT, user, headers, interceptor) | ||
sleep(0.3) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export interface Crocodile { | ||
id?: number; | ||
name: string; | ||
sex: string; | ||
date_of_birth: string; | ||
age?: number; | ||
id?: number | ||
name: string | ||
sex: string | ||
date_of_birth: string | ||
age?: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
export interface User { | ||
username: string; | ||
first_name: string; | ||
last_name: string; | ||
email: string; | ||
password: string; | ||
username: string | ||
first_name: string | ||
last_name: string | ||
email: string | ||
password: string | ||
} | ||
|
||
export interface AuthRequest { | ||
username: string; | ||
password: string; | ||
username: string | ||
password: string | ||
} | ||
|
||
export interface AuthResponse { | ||
refresh: string; | ||
access: string; | ||
refresh: string | ||
access: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import { Rate } from 'k6/metrics'; | ||
import { RefinedResponse } from 'k6/http'; | ||
import { Rate } from 'k6/metrics' | ||
import { RefinedResponse } from 'k6/http' | ||
|
||
const P80 = new Rate('p80_within_1sec'); | ||
const ERRORS_RATE = new Rate('errors_rate'); | ||
const P80 = new Rate('p80_within_1sec') | ||
const ERRORS_RATE = new Rate('errors_rate') | ||
|
||
export function p80_within_1sec(response: RefinedResponse<any>): void { | ||
P80.add(response.timings.duration < 1000); | ||
P80.add(response.timings.duration < 1000) | ||
} | ||
|
||
export function errors(response: RefinedResponse<any>, status: number): void { | ||
ERRORS_RATE.add(response.status !== status); | ||
ERRORS_RATE.add(response.status !== status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
const reporter = require('k6-html-reporter'); | ||
const fs = require('fs'); | ||
const reporter = require('k6-html-reporter') | ||
const fs = require('fs') | ||
|
||
const REPORT_FOLDER = './dist/reports'; | ||
const SOURCE_FOLDER = './dist/source'; | ||
const REPORT_FOLDER = './dist/reports' | ||
const SOURCE_FOLDER = './dist/source' | ||
|
||
fs.readdirSync(SOURCE_FOLDER).forEach(file => { | ||
const name = file.replace('.json', ''); | ||
const name = file.replace('.json', '') | ||
const options = { | ||
jsonFile: `${SOURCE_FOLDER}/${file}`, | ||
output: REPORT_FOLDER | ||
}; | ||
} | ||
|
||
reporter.generateSummaryReport(options); | ||
reporter.generateSummaryReport(options) | ||
|
||
fs.renameSync(`${REPORT_FOLDER}/report.html`, `${REPORT_FOLDER}/${name}.html`); | ||
}); | ||
fs.renameSync(`${REPORT_FOLDER}/report.html`, `${REPORT_FOLDER}/${name}.html`) | ||
}) |
Oops, something went wrong.