Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ build/
.DS_Store
.idea/
src/main/resources/generator.yml
*csv
*csv

# Migration test beds (set up via setup-testbeds.sh)
testbeds/
petclinic-research/
159 changes: 159 additions & 0 deletions docs/testbed_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Spring Boot Migration Test Beds

## Overview
This directory contains Spring PetClinic clones at different Spring Boot versions (2.1-2.5) to serve as test beds for validating migration guides and testing migration automation tools.

## Quick Start

### Automated Setup (Recommended)
Run the setup script from the `antikythera-examples` directory:
```bash
./setup-testbeds.sh
```

This script will:
1. Clone the Spring PetClinic repository 5 times
2. Check out specific commits for each Spring Boot version
3. Verify the correct version is set up
4. Optionally verify that each version builds successfully

### Manual Setup
If you prefer to set up manually or need a specific configuration:

```bash
# Create testbeds directory
mkdir -p testbeds
cd testbeds

# Spring Boot 2.1.6
git clone https://github.com/spring-projects/spring-petclinic.git spring-boot-2.1
cd spring-boot-2.1
git checkout 7481e8841a452a101b14363ac36ff8df5c7c1956
cd ..

# Spring Boot 2.2.0
git clone https://github.com/spring-projects/spring-petclinic.git spring-boot-2.2
cd spring-boot-2.2
git checkout ce7c3f93deb53798e3842e583fecea3514e90f1e
cd ..

# Spring Boot 2.3.3
git clone https://github.com/spring-projects/spring-petclinic.git spring-boot-2.3
cd spring-boot-2.3
git checkout d19963e1744f56ff330be879d35672733d66f641
cd ..

# Spring Boot 2.4.5
git clone https://github.com/spring-projects/spring-petclinic.git spring-boot-2.4
cd spring-boot-2.4
git checkout 09e07869ac8cea1d08bd62802d5e0dad97827b87
cd ..

# Spring Boot 2.5.4
git clone https://github.com/spring-projects/spring-petclinic.git spring-boot-2.5
cd spring-boot-2.5
git checkout 11f1234b424fe2c55e5c02ad5683913090966ffa
cd ..
```

## Testbed Structure

```
testbeds/
├── spring-boot-2.1/ # Spring PetClinic with Spring Boot 2.1.6
├── spring-boot-2.2/ # Spring PetClinic with Spring Boot 2.2.0
├── spring-boot-2.3/ # Spring PetClinic with Spring Boot 2.3.3
├── spring-boot-2.4/ # Spring PetClinic with Spring Boot 2.4.5
└── spring-boot-2.5/ # Spring PetClinic with Spring Boot 2.5.4
```

## Version Details

| Directory | Spring Boot Version | Commit Hash | Java Version |
|-----------|---------------------|-------------|--------------|
| spring-boot-2.1 | 2.1.6.RELEASE | 7481e8841a4 | Java 8+ |
| spring-boot-2.2 | 2.2.0.RELEASE | ce7c3f93deb | Java 8+ |
| spring-boot-2.3 | 2.3.3 | d19963e1744 | Java 8+ |
| spring-boot-2.4 | 2.4.5 | 09e07869ac8 | Java 8+ |
| spring-boot-2.5 | 2.5.4 | 11f1234b424 | Java 8+ (Java 17 ready) |

## Usage

### Building a Testbed
```bash
cd testbeds/spring-boot-2.1
mvn clean install
```

### Running a Testbed
```bash
cd testbeds/spring-boot-2.1
mvn spring-boot:run
```

Then open http://localhost:8080 in your browser.

### Testing Migration
Use these testbeds to test migration scripts:

```bash
# Example: Test migration from 2.1 to 2.2
cd testbeds/spring-boot-2.1

# Run your migration tool
# java -jar ../../antikythera/target/antikythera.jar migrate --from=2.1 --to=2.2

# Verify the changes
mvn clean install
```

## Common Issues

### Build Failures
If a testbed fails to build:
1. Ensure you have the correct Java version (Java 8+ for all versions)
2. Check your Maven version (`mvn --version`)
3. Try clearing your Maven cache: `rm -rf ~/.m2/repository`
4. Check if external dependencies are available

### Port Conflicts
If you're running multiple testbeds, they'll all try to use port 8080. Either:
- Run them one at a time
- Configure different ports in `application.properties`:
```properties
server.port=8081
```

### Database Issues
All PetClinic versions use an in-memory H2 database by default, so no external database setup is needed.

## Maintenance

### Updating Commit Hashes
If you need to use different versions, update the commit hashes in:
1. `setup-testbeds.sh` - Update the `COMMITS` associative array
2. This README - Update the version details table

### Cleaning Up
To remove all testbeds:
```bash
rm -rf testbeds/
```

## Notes
- **These directories are not committed to git** - They're listed in `.gitignore`
- **Total size**: ~50MB per testbed (5 testbeds = ~250MB total)
- **Setup time**: ~2-5 minutes depending on network speed
- **Build time per testbed**: ~1-2 minutes

## About Spring PetClinic
Spring PetClinic is a sample Spring Boot application that demonstrates:
- Spring MVC with Thymeleaf templates
- Spring Data JPA
- Spring Boot DevTools
- Spring Boot Actuator
- Comprehensive testing with JUnit

It's maintained by the Spring team and serves as a reference implementation for Spring Boot applications.

**Repository**: https://github.com/spring-projects/spring-petclinic
178 changes: 178 additions & 0 deletions setup-testbeds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
#!/bin/bash
#
# Setup script for Spring Boot migration test beds
# This script clones Spring PetClinic at different Spring Boot versions (2.1-2.5)
# for testing migration guides.
#

set -e # Exit on error

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Configuration
PETCLINIC_REPO="https://github.com/spring-projects/spring-petclinic.git"
TESTBEDS_DIR="./testbeds"

# Commit hashes for each Spring Boot version
# These were identified from Spring PetClinic git history
declare -A COMMITS=(
["2.1"]="7481e8841a452a101b14363ac36ff8df5c7c1956" # Spring Boot 2.1.6
["2.2"]="ce7c3f93deb53798e3842e583fecea3514e90f1e" # Spring Boot 2.2.0
["2.3"]="d19963e1744f56ff330be879d35672733d66f641" # Spring Boot 2.3.3
["2.4"]="09e07869ac8cea1d08bd62802d5e0dad97827b87" # Spring Boot 2.4.5
["2.5"]="11f1234b424fe2c55e5c02ad5683913090966ffa" # Spring Boot 2.5.4
)

# Function to print colored messages
print_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}

print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}

print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}

print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}

# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Check prerequisites
check_prerequisites() {
print_info "Checking prerequisites..."

if ! command_exists git; then
print_error "git is not installed. Please install git first."
exit 1
fi

if ! command_exists mvn; then
print_warning "Maven is not installed. Build verification will be skipped."
fi

print_success "Prerequisites check passed"
}

# Clone and setup a specific version
setup_version() {
local version=$1
local commit=$2
local dir_name="spring-boot-${version}"
local full_path="${TESTBEDS_DIR}/${dir_name}"

print_info "Setting up Spring Boot ${version} testbed..."

# Check if directory already exists
if [ -d "$full_path" ]; then
print_info "Directory exists, resetting to commit for Spring Boot ${version}..."
(cd "$full_path" && git fetch origin >/dev/null 2>&1 || true)
(cd "$full_path" && git reset --hard "$commit" >/dev/null 2>&1)
(cd "$full_path" && git clean -fd >/dev/null 2>&1)
print_success "Reset to Spring Boot ${version} commit"
else
# Clone the repository
print_info "Cloning Spring PetClinic..."
git clone "$PETCLINIC_REPO" "$full_path" >/dev/null 2>&1

# Checkout specific commit
print_info "Checking out commit for Spring Boot ${version}..."
(cd "$full_path" && git checkout "$commit" >/dev/null 2>&1)
print_success "Cloned Spring Boot ${version} testbed"
fi

# Verify the Spring Boot version in pom.xml
if [ -f "$full_path/pom.xml" ]; then
local boot_version=$(grep -m1 "<parent>" -A 5 "$full_path/pom.xml" | grep "<version>" | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
print_info "Spring Boot version: $boot_version"
else
print_error "pom.xml not found in $full_path"
return 1
fi

# Optionally verify build
if command_exists mvn && [ "$VERIFY_BUILD" = "true" ]; then
print_info "Verifying build for Spring Boot ${version}... (this may take a few minutes on first run)"
print_info "Downloading dependencies and building..."
if timeout 600 bash -c "(cd \"$full_path\" && mvn clean verify -DskipTests 2>&1 | tail -20)"; then
print_success "Build verification passed for Spring Boot ${version}"
else
exit_code=$?
if [ $exit_code -eq 124 ]; then
print_warning "Build verification timed out for Spring Boot ${version} (>10 minutes)"
else
print_warning "Build verification failed for Spring Boot ${version} (this may be due to environment issues)"
fi
fi
fi
}

# Main function
main() {
echo ""
echo "=========================================="
echo " Spring Boot Migration Testbed Setup"
echo "=========================================="
echo ""

# Check prerequisites
check_prerequisites

# Create testbeds directory
if [ ! -d "$TESTBEDS_DIR" ]; then
mkdir -p "$TESTBEDS_DIR"
print_info "Created $TESTBEDS_DIR directory"
fi

# Ask user if they want to verify builds
echo ""
read -p "Do you want to verify builds? This will take longer. (y/N): " verify_choice
if [[ "$verify_choice" =~ ^[Yy]$ ]]; then
VERIFY_BUILD="true"
else
VERIFY_BUILD="false"
fi

echo ""
print_info "Setting up testbeds for Spring Boot versions: 2.1, 2.2, 2.3, 2.4, 2.5"
echo ""

# Setup each version
for version in 2.1 2.2 2.3 2.4 2.5; do
setup_version "$version" "${COMMITS[$version]}"
echo ""
done

# Summary
echo "=========================================="
print_success "All testbeds have been set up successfully!"
echo "=========================================="
echo ""
print_info "Testbeds location: $TESTBEDS_DIR"
echo ""
print_info "Available testbeds:"
for version in 2.1 2.2 2.3 2.4 2.5; do
echo " - spring-boot-${version}/"
done
echo ""
print_info "Next steps:"
echo " 1. Navigate to a testbed: cd $TESTBEDS_DIR/spring-boot-2.1"
echo " 2. Build the project: mvn clean install"
echo " 3. Test your migration scripts on these testbeds"
echo ""
}

# Run main function
main
Loading