Skip to content

Commit 9859c0f

Browse files
authored
Merge pull request #195 from tisnik/lcore-317-tooling-to-generate-list-of-scenarios
LCORE 317: tooling to generate list of scenarios
2 parents cc2d649 + 9acb538 commit 9859c0f

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

docs/e2e_scenarios.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# List of scenarios
2+
3+
## [`smoketests.feature`](https://github.com/lightspeed-core/lightspeed-stack/blob/main/tests/e2e/features/smoketests.feature)
4+
5+
* Check if the main endpoint is reachable
6+
7+
## [`rest_api.feature`](https://github.com/lightspeed-core/lightspeed-stack/blob/main/tests/e2e/features/rest_api.feature)
8+
9+
* Check if service report proper readiness state
10+
* Check if service report proper liveness state
11+
* Check if the OpenAPI endpoint works as expected
12+
* Check if info endpoint is working
13+
14+
## [`llm_interface.feature`](https://github.com/lightspeed-core/lightspeed-stack/blob/main/tests/e2e/features/llm_interface.feature)
15+
16+
* Check if LLM responds to sent question

tests/e2e/gen_scenario_list.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright © 2022, 2023, 2025 Pavel Tisnovsky
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""Scenario list generator."""
18+
19+
# Usage
20+
# python gen_scenario_list.py > docs/scenarios_list.md
21+
22+
import os
23+
24+
# URL prefix to create links to feature files
25+
FEATURES_URL_PREFIX = "https://github.com/lightspeed-core/lightspeed-stack/blob/main/tests/e2e/features" # noqa E501
26+
27+
# list of prefixes for scenarios or scenario outlines
28+
PREFIXES = ("Scenario: ", "Scenario Outline: ")
29+
30+
# sub-directory where feature files are stored
31+
FEATURE_DIRECTORY = "features"
32+
33+
# generate page header
34+
print("---")
35+
print("layout: page")
36+
print("nav_order: 3")
37+
print("---")
38+
print()
39+
print("# List of scenarios")
40+
print()
41+
42+
# generage list of scenarios
43+
directory = FEATURE_DIRECTORY
44+
# files within one subdirectory needs to be sorted so the
45+
# resulting scenario list will have stable structure across versions
46+
files = sorted(os.listdir(directory))
47+
for filename in files:
48+
# grep all .feature files
49+
if filename.endswith(".feature"):
50+
# feature file header
51+
print("## [`{}`]({}/{})\n".format(filename, FEATURES_URL_PREFIX, filename))
52+
with open(os.path.join(directory, filename), "r") as fin:
53+
for line in fin.readlines():
54+
line = line.strip()
55+
# process all scenarios and scenario outlines
56+
for prefix in PREFIXES:
57+
if line.startswith(prefix):
58+
line = line[len(prefix) :]
59+
print(f"* {line}")
60+
# vertical space between subsections in generated file
61+
print()

0 commit comments

Comments
 (0)