Skip to content

Commit 28dfb18

Browse files
committed
refactor: restructure as Rust application with main and E2E test binaries
- Move Rust project to root directory as main application - Create main binary that displays usage instructions - Move E2E test functionality to separate e2e-tests binary - Update project structure and README to reflect new organization - Add default-run configuration to Cargo.toml for main binary - Remove old tests subdirectory structure - Update .gitignore for root-level Rust artifacts The application now provides: - Main binary: Usage instructions and getting started guide - E2E tests binary: Automated infrastructure testing with wait-cloud-init test - Both binaries tested and working correctly (E2E test passed in ~22s)
1 parent 69c0073 commit 28dfb18

File tree

7 files changed

+465
-5
lines changed

7 files changed

+465
-5
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ Thumbs.db
4646
# Temporary files
4747
*.tmp
4848
*.temp
49+
50+
# Rust build artifacts
51+
target/
52+
Cargo.lock

Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "torrust-testing-infra"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "Torrust Testing Infrastructure with Ansible and OpenTofu"
6+
license = "MIT"
7+
default-run = "torrust-testing-infra"
8+
[[bin]]
9+
name = "torrust-testing-infra"
10+
path = "src/main.rs"
11+
[[bin]]
12+
name = "e2e-tests"
13+
path = "src/bin/e2e_tests.rs"
14+
[dependencies]
15+
tokio = { version = "1.0", features = ["full"] }
16+
serde = { version = "1.0", features = ["derive"] }
17+
serde_json = "1.0"
18+
anyhow = "1.0"
19+
clap = { version = "4.0", features = ["derive"] }
20+
regex = "1.0"
21+
dirs = "5.0"

README.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Torrust Testing Infrastructure PoC
1+
# Torrust Testing Infrastructure
22

3-
This repository contains configurations for testing VM provisioning and cloud-init execution using different virtualization approaches. The goal is to find the best solution for creating VMs that support cloud-init both locally (development) and in CI environments (GitHub Actions).
3+
This Rust application provides automated testing infrastructure for Torrust projects. It manages VM provisioning and cloud-init execution using different virtualization approaches, with the goal of finding the best solution for creating VMs that support cloud-init both locally (development) and in CI environments (GitHub Actions).
44

55
## 🎯 Project Goals
66

@@ -48,11 +48,13 @@ This repository tests two different virtualization technologies:
4848

4949
### Prerequisites
5050

51+
This is a Rust application that automates testing infrastructure deployment using OpenTofu and Ansible.
52+
5153
Install the required tools:
5254

5355
```bash
5456
# Check installations
55-
lxd version && tofu version && ansible --version
57+
lxd version && tofu version && ansible --version && cargo --version
5658
```
5759

5860
**Missing tools?** See detailed installation guides:
@@ -63,6 +65,9 @@ lxd version && tofu version && ansible --version
6365
**Quick install:**
6466

6567
```bash
68+
# Install Rust (if not already installed)
69+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
70+
6671
# Install LXD
6772
sudo snap install lxd && sudo lxd init --auto && sudo usermod -a -G lxd $USER && newgrp lxd
6873

@@ -73,7 +78,42 @@ curl -fsSL https://get.opentofu.org/install-opentofu.sh | sudo bash
7378
sudo apt install ansible
7479
```
7580

76-
### Deployment Steps
81+
### Usage
82+
83+
#### Main Application
84+
85+
The main application provides usage instructions:
86+
87+
```bash
88+
# Build and run the application
89+
cargo run
90+
91+
# Or install and run directly
92+
cargo install --path .
93+
torrust-testing-infra
94+
```
95+
96+
#### Running E2E Tests
97+
98+
Use the E2E tests binary to run automated infrastructure tests:
99+
100+
```bash
101+
# Run the wait-cloud-init test
102+
cargo run --bin e2e-tests -- wait-cloud-init
103+
104+
# Keep the test environment after completion
105+
cargo run --bin e2e-tests -- wait-cloud-init --keep
106+
107+
# Run with verbose output
108+
cargo run --bin e2e-tests -- wait-cloud-init --verbose
109+
110+
# See all available options
111+
cargo run --bin e2e-tests -- --help
112+
```
113+
114+
### Manual Deployment Steps
115+
116+
If you prefer manual deployment instead of using the E2E tests:
77117

78118
#### 1. Deploy Infrastructure
79119

@@ -172,6 +212,10 @@ Both configurations include GitHub Actions workflows for CI testing:
172212
## 📁 Repository Structure
173213

174214
```text
215+
├── src/ # Rust application source code
216+
│ ├── main.rs # Main application binary
217+
│ └── bin/
218+
│ └── e2e_tests.rs # E2E tests binary
175219
├── docs/ # Detailed documentation
176220
│ ├── opentofu.md # OpenTofu setup and usage guide
177221
│ ├── ansible.md # Ansible setup and usage guide
@@ -182,7 +226,9 @@ Both configurations include GitHub Actions workflows for CI testing:
182226
│ │ └── lxd/ # LXD container configuration
183227
│ └── ansible/ # Ansible configuration management
184228
├── .github/workflows/ # CI/CD workflows
229+
├── Cargo.toml # Rust project configuration
185230
├── README.md # This file - project overview
231+
├── target/ # Rust build artifacts (ignored)
186232
└── .gitignore # Git ignore rules
187233
```
188234

config/ansible/inventory.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ all:
3232
# 🔗 OPENTOFU: IP assigned by lxd_instance.torrust_vm via lxdbr0 network
3333
# 🔗 DISCOVERY: Find current IP with: lxc list torrust-vm
3434
# 🔗 AUTOMATION: Could be retrieved via: lxc list torrust-vm -f json | jq -r '.[0].state.network.eth0.addresses[0].address'
35-
ansible_host: 10.140.190.177
35+
ansible_host: 10.140.190.84
3636

3737
# The username to use when connecting via SSH
3838
# 🔗 CLOUD-INIT: This must match the user created in cloud-init

project-words.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ containerd
44
cpus
55
dearmor
66
debootstrap
7+
ehthumbs
78
eprintln
89
getent
910
journalctl
@@ -21,6 +22,7 @@ runcmd
2122
serde
2223
subshell
2324
sysfs
25+
terraformrc
2426
tfstate
2527
tfvars
2628
tlsv

0 commit comments

Comments
 (0)