Skip to content

Commit

Permalink
Adds basic performance tests for other supported endpoints in v1, 2 a…
Browse files Browse the repository at this point in the history
…nd 3
  • Loading branch information
cshnimble committed Jan 23, 2024
1 parent ba16216 commit 8e91419
Show file tree
Hide file tree
Showing 7 changed files with 263 additions and 83 deletions.
37 changes: 37 additions & 0 deletions Dfe.Academies.Performance/scripts/v1/keyStagePerformance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import http from 'k6/http'
import { check, sleep } from 'k6'

export const options = {
vus: 20,
duration: '30s'
}

const baseUrl = 'https://localhost:5001'

export default function () {

getEducationPerformanceByUrn('100000')

sleep(1)
}

function getEducationPerformanceByUrn(urn) {
const res = http.get(`${baseUrl}/educationPerformance/${urn}`, {
headers: getHeaders()
})

isStatus200(res)
}

function isStatus200(res) {
check(res, {
'status is 200': (r) => r.status === 200,
})
}

function getHeaders() {
return {
'ApiKey': 'app-key',
'Content-Type': 'application/json'
}
}
38 changes: 38 additions & 0 deletions Dfe.Academies.Performance/scripts/v2/baselineTracker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import http from 'k6/http'
import { check, sleep } from 'k6'

export const options = {
vus: 20,
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v2'

export default function () {

getBaselineTrackers()

sleep(1)
}

function getBaselineTrackers() {
// TODO change url endpoint when spelling mistake resolved
const res = http.get(`${baseUrl}/basline-tracker?page=1&count=50`, {
headers: getHeaders()
})

isStatus200(res)
}

function isStatus200(res) {
check(res, {
'status is 200': (r) => r.status === 200,
})
}

function getHeaders() {
return {
'ApiKey': 'app-key',
'Content-Type': 'application/json'
}
}
37 changes: 37 additions & 0 deletions Dfe.Academies.Performance/scripts/v2/fssProjects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import http from 'k6/http'
import { check, sleep } from 'k6'

export const options = {
vus: 20,
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v2'

export default function () {

getFreeSchoolProjects()

sleep(1)
}

function getFreeSchoolProjects() {
const res = http.get(`${baseUrl}/fss/projects`, {
headers: getHeaders()
})

isStatus200(res)
}

function isStatus200(res) {
check(res, {
'status is 200': (r) => r.status === 200,
})
}

function getHeaders() {
return {
'ApiKey': 'app-key',
'Content-Type': 'application/json'
}
}
57 changes: 57 additions & 0 deletions Dfe.Academies.Performance/scripts/v3/trusts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import http from 'k6/http'
import { check, sleep } from 'k6'

export const options = {
vus: 20,
duration: '30s'
}

const baseUrl = 'https://localhost:5001/v3'

export default function () {

getTrustByUkPrn('10067112')

searchTrustByName('SOUTH YORK MULTI ACADEMY TRUST')

searchTrustByUkPrn('10067112')

sleep(1)
}

function getTrustByUkPrn(ukprn) {
const res = http.get(`${baseUrl}/trust/${ukprn}`, {
headers: getHeaders()
})

isStatus200(res)
}

function searchTrustByName(name) {
const res = http.get(`${baseUrl}/trusts?groupName=${name}&page=1&count=10`, {
headers: getHeaders()
})

isStatus200(res);
}

function searchTrustByUkPrn(ukprn) {
const res = http.get(`${baseUrl}/trusts?ukPrn=${ukprn}&page=1&count=10`, {
headers: getHeaders()
})

isStatus200(res)
}

function isStatus200(res) {
check(res, {
'status is 200': (r) => r.status === 200,
})
}

function getHeaders() {
return {
'ApiKey': 'app-key',
'Content-Type': 'application/json'
}
}
58 changes: 58 additions & 0 deletions Dfe.Academies.Performance/scripts/v4/establishments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import http from 'k6/http'
import { check, sleep } from 'k6'

export const options = {
vus: 20,
duration: '30s',
// httpDebug: 'full',
}

const baseUrl = 'https://localhost:5001/v4'

export default function () {

getEstablishmentByUkPrn('10079319')

getEstablishmentByUrn('100000')

getEstablishmentsForTrust('10067112')

sleep(1)
}

function getEstablishmentByUkPrn(ukprn) {
const res = http.get(`${baseUrl}/establishment/${ukprn}`, {
headers: getHeaders()
})

isStatus200(res)
}

function getEstablishmentByUrn(urn) {
const res = http.get(`${baseUrl}/establishment/urn/${urn}`, {
headers: getHeaders()
})

isStatus200(res)
}

function getEstablishmentsForTrust(ukprn) {
const res = http.get(`${baseUrl}/establishments/trust?trustUkPrn=${ukprn}`, {
headers: getHeaders()
})

isStatus200(res)
}

function isStatus200(res) {
check(res, {
'status is 200': (r) => r.status === 200,
})
}

function getHeaders() {
return {
'ApiKey': 'app-key',
'Content-Type': 'application/json'
}
}
47 changes: 0 additions & 47 deletions Dfe.Academies.Performance/scripts/v4/get-establishment.js

This file was deleted.

Loading

0 comments on commit 8e91419

Please sign in to comment.