Skip to content

Commit d63b3c1

Browse files
committed
More tests and cleanup
1 parent a2bdba0 commit d63b3c1

9 files changed

Lines changed: 251 additions & 242 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ repos:
104104
language: node
105105
types_or: [javascript, jsx, ts, tsx]
106106
args: []
107-
exclude: "(node_modules/|.yarn/)"
107+
exclude: "(node_modules/|.yarn/|load_testing/)"
108108
require_serial: false
109109
additional_dependencies:
110110
- eslint@8

load_testing/backend/client/v0/api.schemas.ts

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,6 +4179,29 @@ export type TestimonialsListParams = {
41794179
}
41804180

41814181
export type VectorContentFilesSearchRetrieveParams = {
4182+
/**
4183+
* aggregations for facet counts
4184+
4185+
* `key` - Key
4186+
* `course_number` - Course Number
4187+
* `platform` - Platform
4188+
* `offered_by` - Offered By
4189+
* `file_extension` - File Extension
4190+
* `content_feature_type` - Content Feature Type
4191+
* `run_readable_id` - Run Readable Id
4192+
* `resource_readable_id` - Resource Readable Id
4193+
* `run_title` - Run Title
4194+
* `edx_module_id` - Edx Module Id
4195+
* `content_type` - Content Type
4196+
* `description` - Description
4197+
* `title` - Title
4198+
* `url` - Url
4199+
* `file_type` - File Type
4200+
* `summary` - Summary
4201+
* `flashcards` - Flashcards
4202+
* `checksum` - Checksum
4203+
*/
4204+
aggregations?: VectorContentFilesSearchRetrieveAggregationsItem[]
41824205
/**
41834206
* Manually specify the name of the Qdrant collection to query
41844207
* @minLength 1
@@ -4256,6 +4279,51 @@ export type VectorContentFilesSearchRetrieveParams = {
42564279
url__isnull?: boolean | null
42574280
}
42584281

4282+
/**
4283+
* * `key` - Key
4284+
* `course_number` - Course Number
4285+
* `platform` - Platform
4286+
* `offered_by` - Offered By
4287+
* `file_extension` - File Extension
4288+
* `content_feature_type` - Content Feature Type
4289+
* `run_readable_id` - Run Readable Id
4290+
* `resource_readable_id` - Resource Readable Id
4291+
* `run_title` - Run Title
4292+
* `edx_module_id` - Edx Module Id
4293+
* `content_type` - Content Type
4294+
* `description` - Description
4295+
* `title` - Title
4296+
* `url` - Url
4297+
* `file_type` - File Type
4298+
* `summary` - Summary
4299+
* `flashcards` - Flashcards
4300+
* `checksum` - Checksum
4301+
*/
4302+
export type VectorContentFilesSearchRetrieveAggregationsItem =
4303+
(typeof VectorContentFilesSearchRetrieveAggregationsItem)[keyof typeof VectorContentFilesSearchRetrieveAggregationsItem]
4304+
4305+
// eslint-disable-next-line @typescript-eslint/no-redeclare
4306+
export const VectorContentFilesSearchRetrieveAggregationsItem = {
4307+
key: "key",
4308+
course_number: "course_number",
4309+
platform: "platform",
4310+
offered_by: "offered_by",
4311+
file_extension: "file_extension",
4312+
content_feature_type: "content_feature_type",
4313+
run_readable_id: "run_readable_id",
4314+
resource_readable_id: "resource_readable_id",
4315+
run_title: "run_title",
4316+
edx_module_id: "edx_module_id",
4317+
content_type: "content_type",
4318+
description: "description",
4319+
title: "title",
4320+
url: "url",
4321+
file_type: "file_type",
4322+
summary: "summary",
4323+
flashcards: "flashcards",
4324+
checksum: "checksum",
4325+
} as const
4326+
42594327
export type VectorContentFilesSearchRetrieveSortby =
42604328
(typeof VectorContentFilesSearchRetrieveSortby)[keyof typeof VectorContentFilesSearchRetrieveSortby]
42614329

@@ -4268,6 +4336,30 @@ export const VectorContentFilesSearchRetrieveSortby = {
42684336
} as const
42694337

42704338
export type VectorLearningResourcesSearchRetrieveParams = {
4339+
/**
4340+
* aggregations for facet counts
4341+
4342+
* `readable_id` - Readable Id
4343+
* `resource_type` - Resource Type
4344+
* `certification` - Certification
4345+
* `certification_type` - Certification Type
4346+
* `professional` - Professional
4347+
* `free` - Free
4348+
* `course_feature` - Course Feature
4349+
* `topic` - Topic
4350+
* `ocw_topic` - Ocw Topic
4351+
* `level` - Level
4352+
* `department` - Department
4353+
* `platform` - Platform
4354+
* `offered_by` - Offered By
4355+
* `delivery` - Delivery
4356+
* `title` - Title
4357+
* `url` - Url
4358+
* `resource_type_group` - Resource Type Group
4359+
* `resource_category` - Resource Category
4360+
* `published` - Published
4361+
*/
4362+
aggregations?: VectorLearningResourcesSearchRetrieveAggregationsItem[]
42714363
/**
42724364
* True if the learning resource offers a certificate
42734365
* @nullable
@@ -4400,6 +4492,10 @@ export type VectorLearningResourcesSearchRetrieveParams = {
44004492
* @nullable
44014493
*/
44024494
professional?: boolean | null
4495+
/**
4496+
* If the resource is published. We default to True unless passed in
4497+
*/
4498+
published?: boolean
44034499
/**
44044500
* The search text
44054501
* @minLength 1
@@ -4447,6 +4543,53 @@ export type VectorLearningResourcesSearchRetrieveParams = {
44474543
url__isnull?: boolean | null
44484544
}
44494545

4546+
/**
4547+
* * `readable_id` - Readable Id
4548+
* `resource_type` - Resource Type
4549+
* `certification` - Certification
4550+
* `certification_type` - Certification Type
4551+
* `professional` - Professional
4552+
* `free` - Free
4553+
* `course_feature` - Course Feature
4554+
* `topic` - Topic
4555+
* `ocw_topic` - Ocw Topic
4556+
* `level` - Level
4557+
* `department` - Department
4558+
* `platform` - Platform
4559+
* `offered_by` - Offered By
4560+
* `delivery` - Delivery
4561+
* `title` - Title
4562+
* `url` - Url
4563+
* `resource_type_group` - Resource Type Group
4564+
* `resource_category` - Resource Category
4565+
* `published` - Published
4566+
*/
4567+
export type VectorLearningResourcesSearchRetrieveAggregationsItem =
4568+
(typeof VectorLearningResourcesSearchRetrieveAggregationsItem)[keyof typeof VectorLearningResourcesSearchRetrieveAggregationsItem]
4569+
4570+
// eslint-disable-next-line @typescript-eslint/no-redeclare
4571+
export const VectorLearningResourcesSearchRetrieveAggregationsItem = {
4572+
readable_id: "readable_id",
4573+
resource_type: "resource_type",
4574+
certification: "certification",
4575+
certification_type: "certification_type",
4576+
professional: "professional",
4577+
free: "free",
4578+
course_feature: "course_feature",
4579+
topic: "topic",
4580+
ocw_topic: "ocw_topic",
4581+
level: "level",
4582+
department: "department",
4583+
platform: "platform",
4584+
offered_by: "offered_by",
4585+
delivery: "delivery",
4586+
title: "title",
4587+
url: "url",
4588+
resource_type_group: "resource_type_group",
4589+
resource_category: "resource_category",
4590+
published: "published",
4591+
} as const
4592+
44504593
/**
44514594
* * `micromasters` - MicroMasters Credential
44524595
* `professional` - Professional Certificate

load_testing/backend/test.ts

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,63 @@ import {
77

88
import { Config } from "../config.ts"
99
import { createV0Client, createV1Client } from "./client/client.ts"
10+
import { NewsEventsListParams } from "./client/v0/api.schemas.ts"
11+
import { FeaturedListParams } from "./client/v1/api.schemas.ts"
1012

1113
export function configure(config: Config) {
1214
return function () {
1315
group("api", function () {
1416
group("v0", function () {
15-
exec.vu.tags.apiVersion = "v0"
17+
exec.vu.metrics.tags.apiVersion = "v0"
1618

1719
const client = createV0Client(config)
20+
let res = client.videoShortsList({ limit: 50 })
1821

19-
check(client.videoShortsList({ limit: 50 }), {
22+
check(res, {
2023
"is status 200": (r) => r.response.status === 200,
2124
"has results": (r) => r.response.json("results").length > 0,
2225
})
2326

24-
delete exec.vu.tags.apiVersion
27+
res = client.usersMeRetrieve()
28+
check(res, {
29+
"is status 200": (r) => r.response.status === 200,
30+
})
31+
32+
res = client.testimonialsList({ position: 1 })
33+
34+
check(res, {
35+
"is status 200": (r) => r.response.status === 200,
36+
"has results": (r) => r.response.json("results").length > 0,
37+
})
38+
39+
group("news", function () {
40+
;[
41+
{
42+
feed_type: "news",
43+
sortby: "-news_date",
44+
},
45+
{
46+
feed_type: "events",
47+
sortby: "event_date",
48+
},
49+
].forEach((params: NewsEventsListParams) => {
50+
const res = client.newsEventsList({
51+
limit: 6,
52+
...params,
53+
})
54+
55+
check(res, {
56+
"is status 200": (r) => r.response.status === 200,
57+
"has results": (r) => r.response.json("results").length > 0,
58+
})
59+
})
60+
})
61+
62+
delete exec.vu.metrics.tags.apiVersion
2563
})
2664

2765
group("v1", function () {
28-
exec.vu.tags.apiVersion = "v1"
66+
exec.vu.metrics.tags.apiVersion = "v1"
2967

3068
const client = createV1Client(config)
3169

@@ -42,12 +80,43 @@ export function configure(config: Config) {
4280
check(client.learningResourcesRetrieve(resource.id), {
4381
"is status 200": (r) => r.response.status === 200,
4482
"matches resource id": (r) =>
45-
r.response.json("id") == resource.id,
83+
r.response.json("id") === resource.id,
4684
})
4785
}
86+
87+
;[
88+
{},
89+
{
90+
free: true,
91+
},
92+
{
93+
certification: true,
94+
professional: false,
95+
},
96+
{
97+
professional: true,
98+
},
99+
].forEach((params: FeaturedListParams) => {
100+
const res = client.featuredList({
101+
limit: 12,
102+
...params,
103+
})
104+
105+
check(res, {
106+
"is status 200": (r) => r.response.status === 200,
107+
"has results": (r) => r.response.json("results").length > 0,
108+
})
109+
})
110+
})
111+
112+
const res = client.topicsList({ is_toplevel: true })
113+
114+
check(res, {
115+
"is status 200": (r) => r.response.status === 200,
116+
"has results": (r) => r.response.json("results").length > 0,
48117
})
49118

50-
delete exec.vu.tags.apiVersion
119+
delete exec.vu.metrics.tags.apiVersion
51120
})
52121
})
53122
}

load_testing/frontend/test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function configure(config: Config) {
1010
const carousel = await page.getByTestId("resource-carousel")
1111
const articlesCount = await carousel.locator("article").count()
1212
await check(carousel, {
13-
"has 12 items": () => articlesCount == 12,
13+
"has 12 items": () => articlesCount === 12,
1414
})
1515

1616
await carousel
@@ -19,11 +19,37 @@ export function configure(config: Config) {
1919
.click()
2020
}
2121

22+
async function search(page: Page) {
23+
await page.goto(`${config.frontendBaseUrl}/search?sortby=-views`)
24+
await page.goto(
25+
`${config.frontendBaseUrl}/search?resource_type_group=program`,
26+
)
27+
await page.goto(
28+
`${config.frontendBaseUrl}/search?resource_type_group=learning_material`,
29+
)
30+
}
31+
32+
async function topics(page: Page) {
33+
await page.goto(`${config.frontendBaseUrl}/topics`)
34+
}
35+
36+
async function departments(page: Page) {
37+
await page.goto(`${config.frontendBaseUrl}/departments`)
38+
}
39+
40+
async function units(page: Page) {
41+
await page.goto(`${config.frontendBaseUrl}/units`)
42+
}
43+
2244
return async function () {
2345
const page = await browser.newPage(config.browserOptions)
2446

2547
try {
2648
await home(page)
49+
await search(page)
50+
await topics(page)
51+
await departments(page)
52+
await units(page)
2753
} finally {
2854
await page.close()
2955
}

load_testing/scripts/generate-from-openapi.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
44
PARENT_DIR=$(dirname "${SCRIPT_DIR}")
55
ROOT_DIR=$(dirname "${PARENT_DIR}")
66

7-
pushd $PARENT_DIR
7+
pushd $PARENT_DIR || exit 1
88

9-
npx openapi-to-k6 --mode split "${ROOT_DIR}/openapi/specs/v0.yaml" "${ROOT_DIR}/load_testing/api/client/v0/api.ts"
10-
npx openapi-to-k6 --mode split "${ROOT_DIR}/openapi/specs/v1.yaml" "${ROOT_DIR}/load_testing/api/client/v1/api.ts"
9+
npx openapi-to-k6 --mode split "${ROOT_DIR}/openapi/specs/v0.yaml" "${ROOT_DIR}/load_testing/backend/client/v0/api.ts"
10+
npx openapi-to-k6 --mode split "${ROOT_DIR}/openapi/specs/v1.yaml" "${ROOT_DIR}/load_testing/backend/client/v1/api.ts"
1111

12-
popd
12+
popd || exit 1

load_testing_locust/README.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

load_testing_locust/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)