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
11 changes: 11 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# Skip specific rules
skip_list:
- var-naming[no-role-prefix]
- saftey[risky-file-permissions]
- shared[meta-no-tags]

# Exclude files/directories
exclude_paths:
- .cache/
- .github/
11 changes: 6 additions & 5 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
# Set update schedule for GitHub Actions

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
- package-ecosystem: github-actions
directory: /
schedule:
# Check for updates to GitHub Actions every week
interval: weekly
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
name: pre-commit

on:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Binaries
fulfillment-cli

# Logs
*.log

# Temporary files
*.retry
45 changes: 27 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-symlinks
- id: detect-private-key
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-symlinks
- id: detect-private-key

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict

- repo: https://github.com/ansible/ansible-lint
rev: v24.9.2 # Pin to a specific stable tag (not "main")
hooks:
- id: ansible-lint
name: Ansible Lint
files: \.(yaml|yml)$ # Only lint YAML files
additional_dependencies: [ansible-core==2.18.1]
9 changes: 9 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
extends: default
rules:
line-length: disable
Expand All @@ -8,3 +9,11 @@ rules:
max-spaces-after: 4
truthy:
check-keys: false
comments:
min-spaces-from-content: 1
comments-indentation: false
braces:
max-spaces-inside: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
141 changes: 141 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Overview

This repository contains Ansible-based test infrastructure for OSAC end-to-end testing. It focuses on testing hub creation and VM lifecycle management through the OSAC fulfillment service using gRPC APIs and the fulfillment-cli tool.

## Architecture

### Directory Structure
- `playbooks/` - Main Ansible playbooks for executing tests
- `roles/` - Reusable Ansible roles for test functionality
- `test_vm_creation/` - Role for VM creation, verification, and cleanup
- `test_hub_creation/` - Role for hub creation, verification, and cleanup
- `fulfillment_cli_base/` - Base role for fulfillment CLI operations (dependency)
- `inventory/` - Ansible inventory and group variables
- `group_vars/all.yml` - Global configuration variables
- `retry/` - Ansible retry files for failed playbook runs

### Core Components

**Hub Creation Testing**
- Hub creation and registration using fulfillment-cli
- Hub verification through gRPC API calls (private.v1.Hubs/Get)
- Automated cleanup of hub resources and temporary files

**VM Lifecycle Testing**
- VM creation using fulfillment-cli with OSAC templates
- gRPC-based verification through the fulfillment service
- Status monitoring and readiness checks
- Automated cleanup and deletion

**Communication Methods**
- `fulfillment-cli` for hub/VM creation operations
- `grpcurl` for direct API communication with fulfillment service
- gRPC authentication using Bearer tokens from OpenShift service accounts

## Development Commands

### Code Quality
```bash
# Run pre-commit hooks (yamllint, ansible-lint, etc.)
pre-commit run --all-files

# Run yamllint specifically
yamllint --strict *.yml *.yaml

# Run ansible-lint specifically
ansible-lint
```

### Running Tests

Execute hub creation test:
```bash
ansible-playbook playbooks/test_hub_creation.yml -e test_hub_id=my-test-hub-001 -e test_namespace=foobar
```

Execute VM creation test (if VM creation playbook exists):
```bash
ansible-playbook playbooks/test_vm_creation.yml -e test_vm_id=my-test-vm-001 -e test_namespace=foobar
```

### Test Tags

Use tags to run specific parts of tests:
- `info` - Display test information and resource listings
- `test` - Run actual creation tests (hub_creation, vm_creation)
- `validation` - Resource verification and status checks
- `cleanup` - Resource deletion and file cleanup
- `mrclean` - Mass cleanup of test VMs with e2e-test-vm- prefix

Examples:
```bash
# Run only hub creation without cleanup
ansible-playbook playbooks/test_hub_creation.yml --tags test

# Run only VM creation without cleanup (if playbook exists)
ansible-playbook playbooks/test_vm_creation.yml --tags test

# Run only cleanup operations
ansible-playbook playbooks/test_vm_creation.yml --tags cleanup

# Mass cleanup of all test VMs
ansible-playbook playbooks/test_vm_creation.yml --tags mrclean
```

## Configuration

### Key Variables (inventory/group_vars/all.yml)

**Required for customization:**
- `cluster_domain_suffix` - OpenShift cluster domain (e.g., "apps.hcp.local.lab")
- `test_namespace` - Target namespace (default: "foobar")
- `fulfillment_cli_path` - Path to fulfillment-cli binary

**Auto-constructed addresses:**
- `fulfillment_address` - Constructed as `{app_name}-{namespace}.{domain}:{port}`
- `fulfillment_token_script` - OpenShift token creation command

**Hub creation specific:**
- `hub_service_account` - Service account for hub operations (default: "fulfillment-admin")
- `hub_token_duration` - Token validity period (default: "1h")

## VM Template Configuration

Default VM template: `cloudkit.templates.ocp_virt_vm`
- CPU: 2 cores
- Memory: 4GB
- Disk: 20GB
- Network: default
- Ready timeout: 15 minutes

## gRPC API Operations

**Hub Operations:**
- `private.v1.Hubs/Get` - Get specific hub details

**VM Operations:**
- `private.v1.VirtualMachines/List` - List all VMs
- `private.v1.VirtualMachines/Get` - Get specific VM details
- `private.v1.VirtualMachines/Delete` - Delete a VM

All gRPC calls use insecure connections and require Bearer token authentication.

## Test Execution Flow

1. **Setup**: Display test information and parameters
2. **Creation**: Create hub/VM using fulfillment-cli with specified parameters
3. **Verification**: Verify registration via gRPC API
4. **Monitoring**: Wait for resources to reach desired status
5. **Cleanup**: Delete resources and remove temporary files
6. **Logging**: Record test results to test-execution.log

## Error Handling

- Failed tests trigger automatic cleanup of temporary files
- Resource deletion verification ensures proper cleanup
- All operations include proper error logging and failure messages
- Retry functionality available through Ansible retry files in `retry/` directory
101 changes: 95 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,97 @@
# public_template
# OSAC Test Infrastructure

Use this repository as the template for public-facing repositories. Please keep the following warning at the top of the repository README:
Ansible-based test infrastructure for OSAC end-to-end testing.

> [!WARNING]
> Be mindful of the content you commit to this repository. Do not commit any
> material containing Red Hat confidential content, including information about
> future product development plans.
## Overview

This repository contains automated testing capabilities for OSAC hub creation and management through the OSAC fulfillment service.

## Architecture

### Directory Structure
```
playbooks/ # Main Ansible playbooks for executing tests
roles/ # Reusable Ansible roles for test functionality
├── fulfillment_cli_base/ # Base role for fulfillment CLI operations
├── test_hub_creation/ # Hub creation/deletion testing
```

### Core Components

**Hub Creation Testing**
- Hub creation and registration using fulfillment-cli
- Hub verification through gRPC API calls
- Automated cleanup of hub resources and temporary files

**Communication Methods**
- `fulfillment-cli` for hub creation operations
- `grpcurl` for direct API communication with fulfillment service
- gRPC authentication using Bearer tokens

## Quick Start

### Prerequisites
- Ansible installed
- Access to OSAC fulfillment service
- `fulfillment-cli` binary
- `grpcurl` for gRPC API calls

### Running Tests

Execute hub creation test:
```bash
ansible-playbook playbooks/test_hub_creation.yml
```

## Configuration

### Variables (Found in group_vars/all.yml)

- KUBECONFIG: Path to your KUBECONFIG
- fulfillment_cli_path: Where to find fulfillment-cli
- test_namespace: What namespace to use
- testing_workspace: What directory to put your test results in
- cluster_domain_suffix: The service dns entry for your cluster. (ie apps.hcp.local.lab)
- fulfillment_app_name: Kubernetes app name for your fulfillment api service.
- fulfillment_port: Listening port for your fulfillment-api

- osac_installer_fulfillment_address: "{{ fulfillment_app_name }}-{{ test_namespace }}.{{ cluster_domain_suffix }}:{{ fulfillment_port }}"
- fulfillment_token_script: "oc create token fulfillment-admin -n {{ test_namespace }} --duration 1h --as system:admin"

### Hub creation specific overrides
- hub_service_account: "fulfillment-admin"
- hub_token_namespace: "{{ test_namespace }}"
- hub_token_duration: "1h"


### Fulfillment Address Configuration

The fulfillment address follows standard OpenShift application naming:
```
<app-name>-<namespace>.<cluster-domain>:<port>
```

Configuration variables:
- `fulfillment_app_name` - Application name (default: "fulfillment-api")
- `test_namespace` - Target namespace
- `cluster_domain_suffix` - User-configurable cluster domain (e.g., "apps.hcp.local.lab")
- `fulfillment_port` - Service port (default: "443")

The complete address is automatically constructed as:
```
fulfillment-api-foobar.apps.hcp.local.lab:443
```

## Test Execution Flow

1. **Setup**: Display test information and parameters
2. **Creation**: Create hub using fulfillment-cli
3. **Verification**: Verify hub registration via gRPC API
4. **Cleanup**: Delete hub and remove temporary files
5. **Logging**: Record test results to test-execution.log

## Error Handling

- Hub deletion verification ensures proper cleanup
- All operations include proper error logging and failure messages
- Retry functionality available through Ansible retry files
Loading