Skip to content

Commit

Permalink
Add Vagrant and Docker Scripts to setup Tentacles for compatibility t…
Browse files Browse the repository at this point in the history
…esting (#479)

Added docker compose file to stand up docker containers with many versions of Tentacle
Added Vagrant scripts to setup a windows vm with a provided set of tentacles.
  • Loading branch information
nathanwoctopusdeploy authored Nov 27, 2023
1 parent 24510b0 commit 5b0b3eb
Show file tree
Hide file tree
Showing 27 changed files with 755 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ Currently we can only debug netcore apps running in WSL from VSCode, Visual Stud
"problemMatcher": "$msCompile"
}
```
## Additional Resources

- Scripts to help with manual testing can be found in [./testing](./testing/README.md).
6 changes: 6 additions & 0 deletions testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vs
.vagrant
.env
compatibility/docker/config.generated.json
compatibility/docker/docker-compose.yml
compatibility/docker/config.json
17 changes: 17 additions & 0 deletions testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Manually Testing Tentacle

## Compatibility Testing

The following Vagrant and Docker and Azure scripts are available to provision Tentacles and assist with manually setting up different versions of Tentacle for compatibility testing.

### Vagrant

Use the [Vagrant](./compatibility/Vagrant/README.md) scripts to setup a Windows or Linux VM with a selection of Tentacle versions, both Polling and Listening Deployment Targets and Workers are supported.

### Docker

Use the [Docker Compose](./compatibility/docker/README.md) scripts to setup docker containers with a selection of Tentacle versions, both Polling and Listening Deployment Targets and Workers are supported.

### Azure

Use the [Azure](./compatibility/azure/README.md) scripts to setup Azure Virtual Machines with a selection of Tentacle versions, both Polling and Listening Deployment Targets and Workers are supported.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
50 changes: 50 additions & 0 deletions testing/compatibility/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Docker

Setup docker containers with a set of Polling and Listening Deployment Targets and Workers

## Pre-Req Installation

Install Powershell

Install Docker

## Configuration

Copy the file `example.config.json` to `config.json` and modify the settings

- **pollingDeploymentTargets** true to set-up polling deployment targets e.g. `"pollingDeploymentTargets": true`
- **listeningDeploymentTargets** true to set-up listening deployment targets e.g. `"listeningDeploymentTargets": true`
- **pollingWorkers** true to set-up polling workers e.g. `"pollingWorkers": true`
- **listeningWorkers** true to set-up listening workers e.g. `"listeningWorkers": true`
- **tentacleVersions** comma separated list of versions to install e.g. `"tentacleVersions": "6.1.1531,6.2.277,6.3.417,6.3.605,latest"`

Copy the file `example.env` to `.env` and modify the settings

- **serverUrl** The url of Octopus Server to configure the Tentacles for e.g. `serverUrl=http://mymachine.local:8066`
- **serverPollingPort** The Octopus Server polling port e.g. `serverPollingPort=10943`
- **serverApiKey** The Octopus Server API Key e.g. `serverApiKey=API-APIKEY01`
- **environment** The environment to configure the Deployment Targets for e.g. `environment=Development`
- **pollingRole** The role to assign to the polling Deployment Targets e.g. `pollingRole=pollingBreadRoll`
- **listeningRole** The role to assign to the listening Deployment Targets e.g. `listeningRole=listeningBreadRoll`
- **space** the space to configure the Tentacle for e.g. `space=Default` Note: Versions of Tentacle prior to `4.x` had no concept of spaces so will be configured against the `Default` workspace
- **workerPool** The name of the worker pool to add workers to e.g. `workerPool=Default Worker Pool`

`tentacleVersions` can be any version that is available on [Docker Hub](https://hub.docker.com/r/octopusdeploy/tentacle/tags)

## Running

Generate the docker compose file

`.\generate.ps1`

> This will generate 2 files. `config.generated.json` and `docker-compose.yml`
Deploy the containers

`.\run.ps1`

> This calls `docker-compose up --remove-orphans`
Delete the containers

`docker-compose down`
66 changes: 66 additions & 0 deletions testing/compatibility/docker/docker-compose.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: '3.8'
services:
{{#versions}}
{{#pollingDeploymentTargets}}
pollingDeploymentTarget{{version}}:
image: "octopusdeploy/tentacle:{{version}}"
privileged: true
environment:
TargetName: "DockerPollingDeploymentTarget.{{version}}"
Space: ${space}
TargetEnvironment: "${environment}"
TargetRole: "${pollingRole}"
ACCEPT_EULA: "Y"
ServerPort: "${serverPollingPort}"
ServerApiKey: ${serverApiKey}
ServerUrl: "${serverUrl}"
{{/pollingDeploymentTargets}}
{{#listeningDeploymentTargets}}
listeningDeploymentTarget{{version}}:
image: "octopusdeploy/tentacle:{{version}}"
privileged: true
environment:
TargetName: "DockerListeningDeploymentTarget.{{version}}"
Space: ${space}
TargetEnvironment: "${environment}"
TargetRole: "${listeningRole}"
ACCEPT_EULA: "Y"
ListeningPort: "{{deploymentTargetListeningPort}}"
ServerApiKey: ${serverApiKey}
ServerUrl: "${serverUrl}"
PublicHostNameConfiguration: "Custom"
CustomPublicHostName: "${CustomPublicHostName}"
ports:
- "{{deploymentTargetListeningPort}}:10933"
{{/listeningDeploymentTargets}}
{{#pollingWorkers}}
pollingWorker{{version}}:
image: "octopusdeploy/tentacle:{{version}}"
privileged: true
environment:
TargetName: "DockerPollingWorker.{{version}}"
TargetWorkerPool: "${workerPool}"
Space: ${space}
ACCEPT_EULA: "Y"
ServerPort: "${serverPollingPort}"
ServerApiKey: ${serverApiKey}
ServerUrl: "${serverUrl}"
{{/pollingWorkers}}
{{#listeningWorkers}}
listeningWorker{{version}}:
image: "octopusdeploy/tentacle:{{version}}"
privileged: true
environment:
TargetName: "DockerListeningWorker.{{version}}"
TargetWorkerPool: "${workerPool}"
Space: ${space}
ACCEPT_EULA: "Y"
ListeningPort: "{{workerListeningPort}}"
ServerApiKey: ${serverApiKey}
ServerUrl: "${serverUrl}"
PublicHostNameConfiguration: "Custom"
CustomPublicHostName: "${CustomPublicHostName}"
ports:
- "{{workerListeningPort}}:10933"
{{/listeningWorkers}}
{{/versions}}
7 changes: 7 additions & 0 deletions testing/compatibility/docker/example.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"pollingDeploymentTargets": true,
"listeningDeploymentTargets": true,
"pollingWorkers": true,
"listeningWorkers": true,
"tentacleVersions": "6.1.1531,6.2.277,6.3.417,6.3.605,latest"
}
9 changes: 9 additions & 0 deletions testing/compatibility/docker/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
serverUrl=http://host.docker.internal:8066
serverPollingPort=10943
serverApiKey=API-APIKEY01
environment=Development
pollingRole=polling
listeningRole=listen
space=Default
workerPool=Default Worker Pool
customPublicHostName=MyMachine.local
32 changes: 32 additions & 0 deletions testing/compatibility/docker/generate.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generate the configuration

$config = Get-Content 'config.json' -raw | ConvertFrom-Json
$tentacleVersionsString = $config.tentacleVersions;
$tentacleVersions = $tentacleVersionsString.Split(',')

$versions = 1..$tentacleVersions.Count
$startPort = 11900

for ($i = 0; $i -lt $tentacleVersions.Count; $i++) {
$v = New-Object -TypeName psobject
$v | Add-Member -MemberType NoteProperty -Name "version" -Value $tentacleVersions[$i]
$v | Add-Member -MemberType NoteProperty -Name "workerListeningPort" -Value $startPort
$v | Add-Member -MemberType NoteProperty -Name "deploymentTargetListeningPort" -Value ($startPort + 1)
$versions[$i] = $v;

$startPort += 2
}

$config | add-member -Name "versions" -value $versions -MemberType NoteProperty

$config | ConvertTo-Json -depth 32 | set-content 'config.generated.json'

# Install Mustache

Install-Module Poshstache -f

# Generate the docker-compose file

$jsonConfigFile = "config.generated.json"
$jsonConfig = Get-Content $jsonConfigFile | Out-String
ConvertTo-PoshstacheTemplate -InputFile "docker-compose.mustache" -ParametersObject $jsonConfig | Out-File "docker-compose.yml" -Force -Encoding "UTF8"
3 changes: 3 additions & 0 deletions testing/compatibility/docker/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.\generate.ps1

docker-compose up --remove-orphans
58 changes: 58 additions & 0 deletions testing/compatibility/vagrant/Linux/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|

config.vm.box = "ubuntu/focal64"
config.env.enable # Enable vagrant-env(.env)
config.vm.network "public_network"
config.vm.synced_folder '.', '/vagrant', disabled: true

config.vm.box_check_update = false

config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = 10240
vb.cpus = 6
end

config.vm.provider :hyperv do |v, override|
v.gui = true
v.maxmemory = 10240
v.memory = 10240
v.cpus = 6
end

$installPowershell = <<-SCRIPT
# Update the list of packages
sudo apt-get update
# Install pre-requisite packages.
sudo apt-get install -y wget apt-transport-https software-properties-common
# Download the Microsoft repository GPG keys
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
# Register the Microsoft repository GPG keys
sudo dpkg -i packages-microsoft-prod.deb
# Delete the the Microsoft repository GPG keys file
rm packages-microsoft-prod.deb
# Update the list of packages after we added packages.microsoft.com
sudo apt-get update
# Install PowerShell
sudo apt-get install -y powershell
# Start PowerShell
pwsh
SCRIPT

config.vm.provision "shell", inline: $installPowershell

config.vm.provision "file", source: "./bootstrap.ps1", destination: "/tmp/bootstrap.ps1"
config.vm.provision "file", source: "./install.ps1", destination: "/tmp/install.ps1"
config.vm.provision "file", source: "./polling.ps1", destination: "/tmp/polling.ps1"
config.vm.provision "file", source: "./listening.ps1", destination: "/tmp/listening.ps1"

config.vm.provision :shell, path: "bootstrap.ps1", upload_path: "/tmp/vagrant-shell.ps1", :args => "-serverUrl " + "'" + ENV['serverUrl'] + "'" + " -serverPollingPort " + ENV['serverPollingPort'] + " -serverApiKey " + "'" + ENV['serverApiKey'] + "'" + " -environment " + "'" + ENV['environment'] + "'" + " -listeningRole " + "'" + ENV['listeningRole'] + "'" + " -pollingRole " + "'" + ENV['pollingRole'] + "'" + " -space " + "'" + ENV['space'] + "'" + " -tentacleVersions " + "'" + ENV['tentacleVersions'] + "'" + " -listening " + ENV['listening'] + " -polling " + ENV['polling'] + " -serverThumbprint " + "'" + ENV['serverThumbprint'] + "'" + " -deploymentTargets " + ENV['deploymentTargets'] + " -workers " + ENV['workers'] + " -workerPool " + "'" + ENV['workerPool'] + "'"

end
76 changes: 76 additions & 0 deletions testing/compatibility/vagrant/Linux/bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env pwsh
param([string] $serverUrl,
[string] $serverPollingPort,
[string] $serverApiKey,
[string] $environment,
[string] $pollingRole,
[string] $listeningRole,
[string] $space,
[string] $tentacleVersions,
[string] $listening,
[string] $polling,
[string] $deploymentTargets,
[string] $workers,
[string] $serverThumbprint,
[string] $workerPool)

echo "serverUrl:$serverUrl"
echo "serverPollingPort:$serverPollingPort"
echo "serverApiKey:$serverApiKey"
echo "environment:$environment"
echo "listeningRole:$listeningRole"
echo "pollingRole:$pollingRole"
echo "space:$space"
echo "workerPool:$workerPool"

sudo ufw disable

$versions = $tentacleVersions.Split(",")

echo "verisons:$versions"
echo "listening:$listening"
echo "polling:$polling"

echo "deploymentTargets:$deploymentTargets"
echo "workers:$workers"

cd /tmp/

$port = 12900

apt-key adv --fetch-keys https://apt.octopus.com/public.key
add-apt-repository "deb https://apt.octopus.com/ stretch main"
apt-get update

foreach ( $version in $versions )
{
./install.ps1 -version $version

if($polling.ToLower() -eq "true")
{
if($deploymentTargets.ToLower() -eq "true")
{
./polling.ps1 -deploymentTarget $True -version "$version" -serverUrl "$serverUrl" -serverPollingPort "$serverPollingPort" -serverApiKey "$serverApiKey" -environment "$environment" -roll "$listeningRole" -space "$space" -workerpool "na"
}

if($workers.ToLower() -eq "true")
{
./polling.ps1 -deploymentTarget $False -version "$version" -serverUrl "$serverUrl" -serverPollingPort "$serverPollingPort" -serverApiKey "$serverApiKey" -environment "na" -roll "na" -space "$space" -workerpool "$workerPool"
}
}

if($listening.ToLower() -eq "true")
{
if($deploymentTargets.ToLower() -eq "true")
{
./listening.ps1 -deploymentTarget $True -version "$version" -serverUrl "$serverUrl" -serverApiKey "$serverApiKey" -environment "$environment" -roll "$pollingRole" -space "$space" -port $port.ToString() -serverthumbprint $serverThumbprint -workerpool "na"
$port = $port + 1
}

if($workers.ToLower() -eq "true")
{
./listening.ps1 -deploymentTarget $False -version "$version" -serverUrl "$serverUrl" -serverApiKey "$serverApiKey" -environment "na" -roll "na" -space "$space" -port $port.ToString() -serverthumbprint $serverThumbprint -workerpool "$workerPool"
$port = $port + 1
}
}
}
14 changes: 14 additions & 0 deletions testing/compatibility/vagrant/Linux/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
serverUrl=http://MyMachine:8066
serverThumbprint=ABCDEF123456
serverPollingPort=10943
serverApiKey=API-APIKEY01
environment=Development
pollingRole=pollingBreadRoll
listeningRole=listeningBreadRoll
space=Default
tentacleVersions=5.0.15,6.0.645,6.1.1531,6.2.277,6.3.417,6.3.605
polling=True
listening=True
deploymentTargets=True
workers=True
workerPool=Default Worker Pool
9 changes: 9 additions & 0 deletions testing/compatibility/vagrant/Linux/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
param ([string] $version)

$path = "/opt/octopus/tentacle$version/"

If(!(test-path -PathType container $path))
{
apt-get install tentacle=$version
cp -R "/opt/octopus/tentacle/" $path
}
Loading

0 comments on commit 5b0b3eb

Please sign in to comment.