Skip to content

Commit afaf777

Browse files
committed
Add initial project structure with configuration files, README, and example FastAPI application
- Created .flake8 for linting configuration with a max line length of 120. - Added .gitignore to exclude common Python and environment files. - Introduced .pre-commit-config.yaml for managing pre-commit hooks. - Included LICENSE file with MIT License. - Created Makefile for project setup, testing, and documentation. - Added pyproject.toml for project metadata and dependencies. - Developed README.md with installation instructions and usage guidelines. - Established requirements.txt for core and development dependencies. - Set up GitHub Actions workflow for CI/CD. - Added example FastAPI application with Docker support. - Created benchmarks and documentation structure. - Implemented initial stress testing framework structure in src/gradual. - Added tests for various components to ensure functionality and reliability.
1 parent 02c2092 commit afaf777

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4128
-0
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 120
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Gradual
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install build pytest pytest-cov
28+
pip install -e .
29+
pip install -e .[dev]
30+
31+
# - name: Lint with flake8
32+
# run: |
33+
# flake8 src tests
34+
35+
- name: Type check with mypy
36+
run: |
37+
mypy src
38+
39+
- name: Test with pytest
40+
run: |
41+
pytest --cov=src tests/
42+
43+
- name: Build package
44+
run: |
45+
python -m build

.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
23+
# Virtual Environment
24+
venv/
25+
env/
26+
ENV/
27+
28+
# Testing
29+
.coverage
30+
htmlcov/
31+
.pytest_cache/
32+
33+
# IDE specific files
34+
.idea/
35+
.vscode/
36+
*.swp
37+
*.swo
38+
39+
# Documentation builds
40+
docs/_build/
41+
42+
# Logs
43+
server_logs/
44+
logs/

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/psf/black
11+
rev: 23.10.0
12+
hooks:
13+
- id: black
14+
language_version: python3
15+
16+
- repo: https://github.com/pycqa/isort
17+
rev: 5.12.0
18+
hooks:
19+
- id: isort
20+
21+
- repo: https://github.com/pycqa/flake8
22+
rev: 6.1.0
23+
hooks:
24+
- id: flake8
25+
additional_dependencies: [flake8-bugbear]
26+
27+
- repo: https://github.com/pre-commit/mirrors-mypy
28+
rev: v1.6.0
29+
hooks:
30+
- id: mypy
31+
additional_dependencies:
32+
- types-requests
33+
- types-PyYAML

Makefile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
SHELL := /bin/bash
2+
3+
VENV_DIR = venv
4+
5+
ifeq ($(OS),Windows_NT)
6+
VENV_PYTHON = $(VENV_DIR)\Scripts\python.exe
7+
VENV_PIP = $(VENV_DIR)\Scripts\pip.exe
8+
DEL = rmdir /S /Q
9+
else
10+
VENV_PYTHON = $(VENV_DIR)/bin/python
11+
VENV_PIP = $(VENV_DIR)/bin/pip
12+
DEL = rm -rf
13+
endif
14+
15+
setup:
16+
@if [ ! -d "$(VENV_DIR)" ]; then \
17+
echo "Creating new virtual environment..."; \
18+
python -m venv $(VENV_DIR); \
19+
else \
20+
echo "Using existing virtual environment..."; \
21+
fi
22+
23+
$(VENV_PYTHON) -m pip install --upgrade pip setuptools wheel
24+
$(VENV_PYTHON) -m pip install -e ".[dev,bokeh,websockets]"
25+
26+
shell:
27+
ifeq ($(OS),Windows_NT)
28+
@cmd /k "venv\Scripts\activate"
29+
else
30+
@bash --rcfile <(echo "source venv/bin/activate")
31+
endif
32+
33+
develop:
34+
pip install -e ".[dev,bokeh,websockets]"
35+
36+
build:
37+
$(VENV_PYTHON) -m build
38+
39+
test:
40+
pytest -v -s --log-cli-level=INFO
41+
42+
clean:
43+
$(DEL) build dist *.egg-info
44+
ifeq ($(OS),Windows_NT)
45+
@for /d %%D in (.) do if exist "%%D\__pycache__" $(DEL) "%%D\__pycache__"
46+
@del /S /Q *.pyc 2>nul || true
47+
else
48+
@find . -type d -name "__pycache__" -exec $(DEL) {} +
49+
@find . -name "*.pyc" -delete
50+
endif
51+
52+
docs:
53+
cd docs && $(MAKE) html
54+
55+
lint:
56+
flake8 src tests
57+
mypy src
58+
59+
format:
60+
black src tests examples
61+
isort src tests examples

README.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Stress Testing Framework
2+
3+
General Python Stress Testing Framework
4+
5+
## Quick Installation
6+
7+
```bash
8+
# Clone the repository
9+
git clone https://github.com/Gradual-Load-Testing/Gradual.git
10+
cd gradual
11+
12+
# Set up virtual environment and install dependencies
13+
make setup
14+
15+
# Alternatively, install directly
16+
pip install -e ".[dev,bokeh,websockets,notebook]"
17+
18+
19+
# Optional: Install authentication dependencies
20+
pip install -e ".[auth]" # Install all authentication methods
21+
pip install -e ".[kerberos]" # Install only Kerberos authentication
22+
```
23+
24+
## Building the Package
25+
26+
```bash
27+
# Build the package
28+
make build
29+
30+
# Or manually
31+
python -m build
32+
```
33+
34+
## Usage Examples
35+
36+
### Basic Example
37+
38+
### Using Command Line Interface
39+
40+
```bash
41+
# Run a stress test using a YAML configuration
42+
stress-run examples/api_test.yaml --users 500 --duration 60
43+
44+
# Start the monitoring dashboard
45+
stress-dashboard --mode websocket # or --mode bokeh
46+
```
47+
48+
## Development Guide
49+
50+
### Setup Development Environment
51+
52+
```bash
53+
# Clone the repository
54+
git clone https://github.com/Gradual-Load-Testing/Gradual.git
55+
cd gradual
56+
57+
# Install development dependencies
58+
make setup
59+
60+
# Only for the first time
61+
pre-commit install
62+
63+
# Run tests
64+
make test
65+
66+
# Format code
67+
make format
68+
69+
# Run linting
70+
make lint
71+
```
72+
73+
### Project Structure
74+
75+
```text
76+
gradual/
77+
├── benchmarks/ # Benchmark configurations
78+
├── docs/ # Documentation
79+
├── examples/ # Example scenarios and usage
80+
├── notebooks/ # Jupyter notebooks for development
81+
├── results/ # Test results output directory
82+
├── src/ # Source code
83+
│ └── gradual/
84+
├── tests/ # Test suite
85+
├── .gitignore # Git ignore file
86+
├── LICENSE # License file
87+
├── Makefile # Build and development commands
88+
├── pyproject.toml # Project configuration
89+
├── README.md # This file
90+
├── requirements.txt # Dependencies
91+
└── setup.py # Setup script
92+
```
93+
94+
### Adding Dependencies
95+
96+
When adding new packages to the project, update the following files:
97+
98+
1. **pyproject.toml**: Add the package to the appropriate section:
99+
100+
```toml
101+
# For core dependencies
102+
[project]
103+
104+
dependencies = [
105+
# Existing dependencies...
106+
"new-package>=1.0.0",
107+
]
108+
109+
110+
# For optional dependencies
111+
[project.optional-dependencies]
112+
auth = [
113+
"requests_kerberos>=0.14.0", # For Kerberos authentication
114+
"requests_ntlm>=1.2.0", # For NTLM authentication
115+
"requests_oauthlib>=1.3.1", # For OAuth authentication
116+
]
117+
kerberos = [
118+
"requests_kerberos>=0.14.0", # For Kerberos authentication only
119+
]
120+
```
121+
122+
2. **requirements.txt**: Add core dependencies with version constraints.
123+
124+
125+
```text
126+
new-package>=1.0.0
127+
```
128+
129+
130+
3. After updating these files, install the dependencies:
131+
132+
133+
```bash
134+
# Activate the virtual environment if not already activated
135+
source .venv/bin/activate # On Unix/MacOS
136+
# OR
137+
.venv\Scripts\activate # On Windows
138+
139+
# Install core dependencies
140+
pip install -e .
141+
142+
# Install optional dependencies
143+
pip install -e ".[auth]" # For all authentication methods
144+
pip install -e ".[kerberos]" # For Kerberos authentication only
145+
146+
```
147+
148+
4. If the package is only needed for development, testing, or documentation:
149+
- Add it to the appropriate section in `pyproject.toml`:
150+
151+
```toml
152+
[project.optional-dependencies]
153+
dev = [
154+
# Existing dev dependencies...
155+
"new-dev-package>=1.0.0",
156+
]
157+
```
158+
159+
- Install it with:
160+
161+
```bash
162+
pip install -e ".[dev]" # For dev dependencies
163+
# OR
164+
pip install -e ".[docs]" # For documentation dependencies
165+
```
166+
167+
5. Update build and CI configurations if necessary (e.g., `.github/workflows/python-package.yml`).
168+
169+
6. Commit your changes to version control:
170+
171+
```bash
172+
git add pyproject.toml requirements.txt
173+
git commit -m "Add new-package dependency"
174+
```
175+
176+
## Contributing
177+
178+
Contributions are welcome! Please feel free to submit a Pull Request.
179+
180+
1. Fork the repository
181+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
182+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
183+
4. Push to the branch (`git push origin feature/amazing-feature`)
184+
5. Open a Pull Request
185+
186+
## License
187+
188+
This project is licensed under the MIT License - see the LICENSE file for details.

benchmarks/sample_benchmarks.yaml

Whitespace-only changes.

docs/dev_guide.md

Whitespace-only changes.

docs/user_guide.md

Whitespace-only changes.

examples/fastapi_app/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM python:3.10-slim
2+
3+
WORKDIR /app
4+
5+
COPY app ./app
6+
COPY requirements.txt .
7+
8+
RUN pip install --upgrade pip && \
9+
pip install -r requirements.txt

0 commit comments

Comments
 (0)