Skip to content
Merged

4.1 #12

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
76 changes: 74 additions & 2 deletions .github/workflows/docker-helm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name: Docker and Helm CI
on:
push:
branches: [ main, master ]
tags: [ 'v*' ]
pull_request:
branches: [ main, master ]
release:
types: [ published ]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -70,8 +73,9 @@ jobs:
rate_normal_min: 0.0001
rate_normal_max: 0.1
rate_peak: 0.500
log_line_size: 100
log_line_size_estimate: 100 # Added missing parameter
log_line_size_estimate: 100
user_agent_pool_size: 100
max_segment_duration_normal: 5
base_exit_probability: 0.05
rate_change_probability: 0.1
rate_change_max_percentage: 0.1
Expand All @@ -91,6 +95,28 @@ jobs:
- INFO
- WARNING
- ERROR

# HTTP status codes and corresponding messages
http_status_codes:
'200 OK':
- 'API request received'
- 'API response sent'
'400 Bad Request':
- 'Invalid user input detected'
'500 Internal Server Error':
- 'Unexpected error occurred'

# User agent browsers for generating user agents
user_agent_browsers:
- 'Chrome'
- 'Firefox'
- 'Safari'

# User agent systems for generating user agents
user_agent_systems:
- 'Windows NT 10.0; Win64; x64'
- 'Macintosh; Intel Mac OS X 13_4'
- 'X11; Linux x86_64'
EOF

# Run the container with the test config for a short time
Expand Down Expand Up @@ -227,3 +253,49 @@ jobs:

# Clean up
helm delete test-release

docker-publish:
runs-on: ubuntu-latest
needs: [python-tests, docker-build]
if: github.event_name == 'release' || (github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'))
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.10.0

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5.6.0
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v6.16.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,25 @@ pip install random-log-generator

### Using Docker

You can also run the Random Log Generator using Docker:
You can run the Random Log Generator using Docker in several ways:

#### Using Pre-built Images from GitHub Container Registry

```bash
# Pull and run the latest image
docker run -v $(pwd)/logs:/app/logs ghcr.io/sd416/random-log-generator:latest

# Run a specific version
docker run -v $(pwd)/logs:/app/logs ghcr.io/sd416/random-log-generator:v0.1.0

# Run with a custom configuration file
docker run -v $(pwd)/config.yaml:/app/config.yaml -v $(pwd)/logs:/app/logs ghcr.io/sd416/random-log-generator:latest --config config.yaml

# Run with environment variable overrides
docker run -e LOG_GEN_STOP_AFTER_SECONDS=30 -v $(pwd)/logs:/app/logs ghcr.io/sd416/random-log-generator:latest
```

#### Building from Source

```bash
# Build the Docker image
Expand All @@ -47,6 +65,14 @@ docker run -v $(pwd)/logs:/app/logs random-log-generator
docker run -v $(pwd)/config.yaml:/app/config.yaml -v $(pwd)/logs:/app/logs random-log-generator --config config.yaml
```

#### Available Image Tags

- `latest` - Latest stable release from the main branch
- `v{version}` - Specific version tags (e.g., `v0.1.0`, `v0.2.0`)
- `main` - Latest development build from the main branch

Images are automatically built for both `linux/amd64` and `linux/arm64` platforms.

### Using Kubernetes with Helm

If you want to deploy the Random Log Generator on a Kubernetes cluster, you can use the provided Helm chart:
Expand Down
122 changes: 120 additions & 2 deletions helm/random-log-generator/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ data:
rate_normal_min: {{ .Values.config.rateNormalMin }}
rate_normal_max: {{ .Values.config.rateNormalMax }}
rate_peak: {{ .Values.config.ratePeak }}
log_line_size: {{ .Values.config.logLineSize }}
log_line_size_estimate: {{ .Values.config.logLineSize }}
user_agent_pool_size: {{ .Values.config.userAgentPoolSize | default 100 }}
max_segment_duration_normal: {{ .Values.config.maxSegmentDurationNormal | default 5 }}
base_exit_probability: {{ .Values.config.baseExitProbability }}
rate_change_probability: {{ .Values.config.rateChangeProbability }}
rate_change_max_percentage: {{ .Values.config.rateChangeMaxPercentage }}
Expand All @@ -31,4 +33,120 @@ data:
log_levels:
{{- range .Values.config.logLevels }}
- {{ . }}
{{- end }}
{{- end }}

# HTTP status codes and corresponding messages
http_status_codes:
'200 OK':
- 'API request received'
- 'API response sent'
- 'Application deployment completed'
- 'Application deployment started'
- 'Application rollback completed'
- 'Application rollback initiated'
- 'Backup completed successfully'
- 'Cache cleared'
- 'Configuration updated'
- 'Database connection established'
- 'Data fetched successfully'
- 'Data processed successfully'
- 'Email sent successfully'
- 'File uploaded successfully'
- 'New user registered'
- 'Password change requested'
- 'Password change successful'
- 'Payment transaction completed'
- 'Scheduled task completed'
- 'Scheduled task started'
- 'Service health check passed'
- 'Service started'
- 'Service stopped'
- 'Session token refreshed'
- 'SMS sent successfully'
- 'User account unlocked'
- 'User login successful'
- 'User logged out'
- 'User profile updated'
'400 Bad Request':
- 'Invalid user input detected'
- 'Configuration validation error'
- 'Credit card validation error'
- 'License key expired'
- 'Service rate limit exceeded'
- 'Service quota exceeded'
- 'Request body too large'
- 'Invalid request header'
- 'Missing required parameter'
'401 Unauthorized':
- 'User login failed'
- 'Permission denied'
- 'Unauthorized access attempt detected'
- 'Invalid authentication token'
- 'Authentication token expired'
'403 Forbidden':
- 'Permission denied'
- 'Access to resource forbidden'
- 'Account suspended'
'404 Not Found':
- 'File not found'
- 'Service endpoint deprecated'
- 'Service endpoint removed'
- 'Resource not found'
- 'User not found'
'500 Internal Server Error':
- 'Error fetching data from database'
- 'Unexpected error occurred'
- 'Resource allocation failure'
- 'Database connection lost'
- 'Cache update failed'
- 'Backup failed'
- 'Password change failed'
- 'Service health check failed'
- 'File upload failed'
- 'User profile update failed'
- 'Email delivery failed'
- 'SMS delivery failed'
- 'Payment transaction failed'
- 'User account locked'
- 'Service degraded'
- 'High memory usage detected'
- 'Memory leak detected'
- 'System backup cancelled'
- 'User subscription cancelled'
- 'Trial period ended'
- 'Database migration started'
- 'Database migration completed'
- 'Cloud resource deprovisioned'
- 'API key revoked'
- 'User role update failed'
- 'Service unavailable'
- 'Timeout error'
'503 Service Unavailable':
- 'Service temporarily unavailable'
- 'Maintenance in progress'
- 'Server overloaded'

# User agent browsers for generating user agents
user_agent_browsers:
- 'Chrome'
- 'Firefox'
- 'Safari'
- 'Edge'
- 'Opera'
- 'Brave'

# User agent systems for generating user agents
user_agent_systems:
- 'Windows NT 10.0; Win64; x64'
- 'Macintosh; Intel Mac OS X 13_4'
- 'iPhone; CPU iPhone OS 16_5 like Mac OS X'
- 'X11; Linux x86_64'
- 'Linux; Android 13; K'
- 'iPad; CPU OS 16_5 like Mac OS X'
- 'Macintosh; Intel Mac OS X 13_4_1'
- 'Windows NT 10.0; WOW64'
- 'X11; Ubuntu; Linux i686'
- 'Macintosh; Intel Mac OS X 10_15_7'
- 'Linux; Android 13; SM-S918B'
- 'Linux; Android 14; Pixel 7'
- 'ChromeOS; x86_64 15183.78.0'
6 changes: 4 additions & 2 deletions helm/random-log-generator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ config:
rateNormalMin: 0.0001
rateNormalMax: 0.1
ratePeak: 0.500
logLineSize: 100
logLineSize: 100 # This maps to log_line_size_estimate in the config
userAgentPoolSize: 100 # Number of user agents to pre-generate
maxSegmentDurationNormal: 5 # Maximum duration for a single segment during normal log generation
baseExitProbability: 0.05
rateChangeProbability: 0.1
rateChangeMaxPercentage: 0.1
Expand All @@ -79,4 +81,4 @@ config:
- DEBUG
- INFO
- WARNING
- ERROR
- ERROR
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 27 additions & 1 deletion random_log_generator/config/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
'http_format_logs',
'stop_after_seconds',
'custom_app_names',
'custom_log_format'
'custom_log_format',
'logging_level'
]


Expand Down Expand Up @@ -83,6 +84,7 @@ def validate_config(config):
# Validate string values
validate_string(config_params, 'log_file_path')
validate_string(config_params, 'custom_log_format')
validate_logging_level(config_params, 'logging_level')

# Validate list values
validate_list(config_params, 'custom_app_names')
Expand Down Expand Up @@ -207,3 +209,27 @@ def validate_dict(config, key):
error_msg = f"Configuration parameter '{key}' must be a dictionary, got {type(value).__name__}"
logging.error(error_msg)
raise ValueError(error_msg)


def validate_logging_level(config, key):
"""
Validate that a configuration value is a valid logging level.

Args:
config (dict): Configuration dictionary.
key (str): Key to validate.

Raises:
ValueError: If the value is not a valid logging level.
"""
value = config[key]
if not isinstance(value, str):
error_msg = f"Configuration parameter '{key}' must be a string, got {type(value).__name__}"
logging.error(error_msg)
raise ValueError(error_msg)

valid_levels = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
if value.upper() not in valid_levels:
error_msg = f"Configuration parameter '{key}' must be one of {valid_levels}, got '{value}'"
logging.error(error_msg)
raise ValueError(error_msg)
Binary file modified random_log_generator/core/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file modified random_log_generator/core/__pycache__/generator.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified random_log_generator/core/__pycache__/strategies.cpython-312.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.