Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
45 changes: 45 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Gradual

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build pytest pytest-cov
pip install -e .
pip install -e .[dev]

# - name: Lint with flake8
# run: |
# flake8 src tests

- name: Type check with mypy
run: |
mypy src

- name: Test with pytest
run: |
pytest --cov=src tests/

- name: Build package
run: |
python -m build
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual Environment
venv/
env/
ENV/

# Testing
.coverage
htmlcov/
.pytest_cache/

# IDE specific files
.idea/
.vscode/
*.swp
*.swo

# Documentation builds
docs/_build/

# Logs
server_logs/
logs/
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.0
hooks:
- id: mypy
additional_dependencies:
- types-requests
- types-PyYAML
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
SHELL := /bin/bash

VENV_DIR = venv

ifeq ($(OS),Windows_NT)
VENV_PYTHON = $(VENV_DIR)\Scripts\python.exe
VENV_PIP = $(VENV_DIR)\Scripts\pip.exe
DEL = rmdir /S /Q
else
VENV_PYTHON = $(VENV_DIR)/bin/python
VENV_PIP = $(VENV_DIR)/bin/pip
DEL = rm -rf
endif

setup:
@if [ ! -d "$(VENV_DIR)" ]; then \
echo "Creating new virtual environment..."; \
python -m venv $(VENV_DIR); \
else \
echo "Using existing virtual environment..."; \
fi

$(VENV_PYTHON) -m pip install --upgrade pip setuptools wheel
$(VENV_PYTHON) -m pip install -e ".[dev,bokeh,websockets]"

shell:
ifeq ($(OS),Windows_NT)
@cmd /k "venv\Scripts\activate"
else
@bash --rcfile <(echo "source venv/bin/activate")
endif

develop:
pip install -e ".[dev,bokeh,websockets]"

build:
$(VENV_PYTHON) -m build

test:
pytest -v -s --log-cli-level=INFO

clean:
$(DEL) build dist *.egg-info
ifeq ($(OS),Windows_NT)
@for /d %%D in (.) do if exist "%%D\__pycache__" $(DEL) "%%D\__pycache__"
@del /S /Q *.pyc 2>nul || true
else
@find . -type d -name "__pycache__" -exec $(DEL) {} +
@find . -name "*.pyc" -delete
endif

docs:
cd docs && $(MAKE) html

lint:
flake8 src tests
mypy src

format:
black src tests examples
isort src tests examples
188 changes: 188 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# Stress Testing Framework

General Python Stress Testing Framework

## Quick Installation

```bash
# Clone the repository
git clone https://github.com/Gradual-Load-Testing/Gradual.git
cd gradual

# Set up virtual environment and install dependencies
make setup

# Alternatively, install directly
pip install -e ".[dev,bokeh,websockets,notebook]"


# Optional: Install authentication dependencies
pip install -e ".[auth]" # Install all authentication methods
pip install -e ".[kerberos]" # Install only Kerberos authentication
```

## Building the Package

```bash
# Build the package
make build

# Or manually
python -m build
```

## Usage Examples

### Basic Example

### Using Command Line Interface

```bash
# Run a stress test using a YAML configuration
stress-run examples/api_test.yaml --users 500 --duration 60

# Start the monitoring dashboard
stress-dashboard --mode websocket # or --mode bokeh
```

## Development Guide

### Setup Development Environment

```bash
# Clone the repository
git clone https://github.com/Gradual-Load-Testing/Gradual.git
cd gradual

# Install development dependencies
make setup

# Only for the first time
pre-commit install

# Run tests
make test

# Format code
make format

# Run linting
make lint
```

### Project Structure

```text
gradual/
├── benchmarks/ # Benchmark configurations
├── docs/ # Documentation
├── examples/ # Example scenarios and usage
├── notebooks/ # Jupyter notebooks for development
├── results/ # Test results output directory
├── src/ # Source code
│ └── gradual/
├── tests/ # Test suite
├── .gitignore # Git ignore file
├── LICENSE # License file
├── Makefile # Build and development commands
├── pyproject.toml # Project configuration
├── README.md # This file
├── requirements.txt # Dependencies
└── setup.py # Setup script
```

### Adding Dependencies

When adding new packages to the project, update the following files:

1. **pyproject.toml**: Add the package to the appropriate section:

```toml
# For core dependencies
[project]

dependencies = [
# Existing dependencies...
"new-package>=1.0.0",
]


# For optional dependencies
[project.optional-dependencies]
auth = [
"requests_kerberos>=0.14.0", # For Kerberos authentication
"requests_ntlm>=1.2.0", # For NTLM authentication
"requests_oauthlib>=1.3.1", # For OAuth authentication
]
kerberos = [
"requests_kerberos>=0.14.0", # For Kerberos authentication only
]
```

2. **requirements.txt**: Add core dependencies with version constraints.


```text
new-package>=1.0.0
```


3. After updating these files, install the dependencies:


```bash
# Activate the virtual environment if not already activated
source .venv/bin/activate # On Unix/MacOS
# OR
.venv\Scripts\activate # On Windows

# Install core dependencies
pip install -e .

# Install optional dependencies
pip install -e ".[auth]" # For all authentication methods
pip install -e ".[kerberos]" # For Kerberos authentication only

```

4. If the package is only needed for development, testing, or documentation:
- Add it to the appropriate section in `pyproject.toml`:

```toml
[project.optional-dependencies]
dev = [
# Existing dev dependencies...
"new-dev-package>=1.0.0",
]
```

- Install it with:

```bash
pip install -e ".[dev]" # For dev dependencies
# OR
pip install -e ".[docs]" # For documentation dependencies
```

5. Update build and CI configurations if necessary (e.g., `.github/workflows/python-package.yml`).

6. Commit your changes to version control:

```bash
git add pyproject.toml requirements.txt
git commit -m "Add new-package dependency"
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## License

This project is licensed under the MIT License - see the LICENSE file for details.
Empty file.
Empty file added docs/dev_guide.md
Empty file.
Empty file added docs/user_guide.md
Empty file.
9 changes: 9 additions & 0 deletions examples/fastapi_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.10-slim

WORKDIR /app

COPY app ./app
COPY requirements.txt .

RUN pip install --upgrade pip && \
pip install -r requirements.txt
Loading