Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(framework) Add PowerShell test #4916

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
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
42 changes: 42 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,45 @@ jobs:
${{ matrix.engine }}
working-directory: e2e/${{ matrix.directory }}
run: ./../test_exec_api.sh "${{ matrix.connection }}" "${{ matrix.authentication}}" "${{ matrix.engine }}"

windows-compatibility:
runs-on: windows-latest
env:
PYTHONIOENCODING: utf-8
timeout-minutes: 10
needs: wheel

name: Windows compatibility test

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install build tools
run: python -m pip install -U pip==23.3.1
- name: Install dependencies
run: python -m pip install --upgrade .
- name: Run test
working-directory: ./e2e
run: ./test_windows.sh
shell: bash

windows-pwsh-compatibility:
runs-on: windows-latest
env:
PYTHONIOENCODING: utf-8
timeout-minutes: 10
needs: wheel

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Run test
working-directory: ./e2e
run: ./test_windows.ps1
shell: powershell
59 changes: 59 additions & 0 deletions e2e/test_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
python -m pip install -U pip==23.3.1
python -m pip install --upgrade ..

# Create and install Flower app
flwr new e2e-tmp-test --framework numpy --username flwrlabs
Set-Location e2e-tmp-test

# Modify the config file
Add-Content -Path pyproject.toml -Value ""
Add-Content -Path pyproject.toml -Value "[tool.flwr.federations.e2e]"
Add-Content -Path pyproject.toml -Value "address = '127.0.0.1:9093'"
Add-Content -Path pyproject.toml -Value "insecure = true"

# Start Flower processes in the background
Start-Process -NoNewWindow -FilePath flower-superlink -ArgumentList "--insecure" -RedirectStandardOutput flwr_output.log
Start-Sleep -Seconds 2

$cl1 = Start-Process -NoNewWindow -PassThru -FilePath flower-supernode -ArgumentList "--insecure --superlink 127.0.0.1:9092 --clientappio-api-address localhost:9094 --node-config `"partition-id=0 num-partitions=2`" --max-retries 0"
Start-Sleep -Seconds 2

Start-Process -NoNewWindow -FilePath flower-supernode -ArgumentList "--insecure --superlink 127.0.0.1:9092 --clientappio-api-address localhost:9095 --node-config `"partition-id=1 num-partitions=2`" --max-retries 0"
Start-Sleep -Seconds 2

# Run the Flower command
flwr run --run-config num-server-rounds=1 . e2e

# Function to clean up processes on exit
function Cleanup {
Write-Output "Stopping Flower processes..."
Get-Process | Where-Object { $_.ProcessName -like "flower*" } | ForEach-Object { Stop-Process -Id $_.Id -Force }
}

# Register cleanup on exit
$cleanupScript = { Cleanup }
Register-EngineEvent PowerShell.Exiting -Action $cleanupScript

# Initialize a flag to track if training is successful
$found_success = $false
$timeout = 120 # Timeout after 120 seconds
$elapsed = 0

# Check for "Run finished" in a loop with a timeout
while (-not $found_success -and $elapsed -lt $timeout) {
if (Select-String -Path flwr_output.log -Pattern "Run finished" -Quiet) {
Write-Output "Training worked correctly!"
$found_success = $true
exit 0
} else {
Write-Output "Waiting for training ... ($elapsed seconds elapsed)"
}
# Sleep for a short period and increment the elapsed time
Start-Sleep -Seconds 2
$elapsed += 2
}

if (-not $found_success) {
Write-Output "Training did not finish within timeout."
exit 1
}
56 changes: 56 additions & 0 deletions e2e/test_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

# Create and install Flower app
flwr new e2e-tmp-test --framework numpy --username flwrlabs
cd e2e-tmp-test

# Modify the config file
echo -e $"\n[tool.flwr.federations.e2e]\naddress = \"127.0.0.1:9093\"\ninsecure = true" >> pyproject.toml

# Start Flower processes in the background
flower-superlink --insecure 2>&1 | tee flwr_output.log &
sleep 2

flower-supernode --insecure --superlink 127.0.0.1:9092 \
--clientappio-api-address localhost:9094 \
--node-config "partition-id=0 num-partitions=2" --max-retries 0 &
cl1_pid=$!
sleep 2

flower-supernode --insecure --superlink 127.0.0.1:9092 \
--clientappio-api-address localhost:9095 \
--node-config "partition-id=1 num-partitions=2" --max-retries 0 &
sleep 2

flwr run --run-config num-server-rounds=1 . e2e

# Trap to clean up on exit
cleanup() {
echo "Stopping Flower processes..."
taskkill //F //FI "IMAGENAME eq flower*" //T
}
trap cleanup EXIT

# Initialize a flag to track if training is successful
found_success=false
timeout=120 # Timeout after 120 seconds
elapsed=0

# Check for "Run finished" in a loop with a timeout
while [ "$found_success" = false ] && [ $elapsed -lt $timeout ]; do
if grep -q "Run finished" flwr_output.log; then
echo "Training worked correctly!"
found_success=true
exit 0;
else
echo "Waiting for training ... ($elapsed seconds elapsed)"
fi
# Sleep for a short period and increment the elapsed time
sleep 2
elapsed=$((elapsed + 2))
done

if [ "$found_success" = false ]; then
echo "Training did not finish within timeout."
exit 1;
fi