Skip to content

Commit

Permalink
Refactor out E2ETests to be separate from unit tests (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-richardson authored Oct 29, 2021
1 parent 2360776 commit 369f6e8
Show file tree
Hide file tree
Showing 54 changed files with 18 additions and 18 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions Tests/OctopusDSC.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Describe "OctopusDSC" {
#even though it works fine on ubuntu locally
Set-ItResult -Inconclusive -Because "We couldnt get this test to run on our CentOS buildagent"
} else {
$path = Resolve-Path "$PSCommandPath/../../Tests/Scenarios"
$path = Resolve-Path "$PSCommandPath/../../E2ETests/Scenarios"
Write-Output "Running PsScriptAnalyzer against $path"
$results = @(Invoke-ScriptAnalyzer $path -recurse -exclude @('PSUseShouldProcessForStateChangingFunctions', 'PSAvoidUsingConvertToSecureStringWithPlainText'))
$results | ConvertTo-Json | Out-File PsScriptAnalyzer-Scenarios.log
Expand Down Expand Up @@ -288,22 +288,22 @@ Describe "OctopusDSC" {

Describe "Configuration Scenarios" {
BeforeDiscovery {
$path = Resolve-Path "$PSCommandPath/../../Tests/Scenarios"
$path = Resolve-Path "$PSCommandPath/../../E2ETests/Scenarios"
$name = @{label="name";expression={[System.Io.Path]::GetFileNameWithoutExtension($_.Name)}};
$fullName = @{label="fullName";expression={$_.FullName}};
$specPath = @{label="specPath";expression={"$path/../Spec/$([System.Io.Path]::GetFileNameWithoutExtension($_.Name).ToLower() + '_spec.rb')"}};

$cases = @(Get-ChildItem $path -Recurse -Filter *.ps1 | Select-Object -Property $name, $fullName) | ConvertTo-Hashtable
$cases = @(Get-ChildItem $path -Recurse -Filter *.ps1 | Select-Object -Property $name, $fullName, $specPath) | ConvertTo-Hashtable
}

It "Configuration block in scenario <name> should have the same name as the file" -ForEach $cases {
param([string]$name, [string]$fullName)
$fullName | Should -FileContentMatch "Configuration $name"
}

It "Scenario <name> should have a matching spec" -ForEach $cases {
param([string]$name, [string]$fullName)
$specName = ($name + '_spec.rb').ToLower()
(Resolve-Path "$PSCommandPath/../../Tests/Spec/$specName") | Should -Exist
It "Scenario <name> should have a matching spec at <specPath>" -ForEach $cases {
param([string]$name, [string]$fullName, [string]$specPath)
(Resolve-Path $specPath) | Should -Exist
}
}
}
}
20 changes: 10 additions & 10 deletions vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def run_octopus_scenario(config, scenario, log_files)
config.vm.provision "shell", inline: "write-output \"##teamcity[blockOpened name='Running Scenario #{scenario}']\""
config.vm.provision "dsc" do |dsc|
dsc.configuration_file = "#{scenario}.ps1"
dsc.configuration_data_file = "Tests/Scenarios/Configuration.psd1"
dsc.manifests_path = "Tests/Scenarios/"
dsc.configuration_data_file = "E2ETests/Scenarios/Configuration.psd1"
dsc.manifests_path = "E2ETests/Scenarios/"
dsc.abort_on_dsc_failure = true
end
config.vm.provision "shell", inline: "write-output \"##teamcity[blockClosed name='Running Scenario #{scenario}']\""
Expand All @@ -63,8 +63,8 @@ def run_tentacle_scenario(config, scenario, log_files)
config.vm.provision "shell", inline: "write-output \"##teamcity[blockOpened name='Running Scenario #{scenario}']\""
config.vm.provision "dsc" do |dsc|
dsc.configuration_file = "#{scenario}.ps1"
dsc.configuration_data_file = "Tests/Scenarios/Configuration.psd1"
dsc.manifests_path = "Tests/Scenarios/"
dsc.configuration_data_file = "E2ETests/Scenarios/Configuration.psd1"
dsc.manifests_path = "E2ETests/Scenarios/"
dsc.abort_on_dsc_failure = true
end
config.vm.provision "shell", inline: "write-output \"##teamcity[blockClosed name='Running Scenario #{scenario}']\""
Expand Down Expand Up @@ -165,7 +165,7 @@ Vagrant.configure(VAGRANT_FILE_API_VERSION) do |config|
# delete existing tests if they exist (for dev)
config.vm.provision "shell", inline: "if (Test-Path 'c:\\temp\\tests') {remove-item -force -recurse 'c:\\temp\\tests' }"
# upload tests
config.vm.provision "file", source: "Tests", destination: "c:\\temp\\tests"
config.vm.provision "file", source: "E2ETests", destination: "c:\\temp\\tests"
config.vm.provision "shell", path: "Tests/install-test-dependencies.ps1"
# in theory, we shouldn't have to do this - the vagrant-dsc should upload it automatically, but cant get it to work
config.vm.provision "file", source: "OctopusDSC", destination: 'C:\Windows\System32\WindowsPowerShell\v1.0\modules\OctopusDSC'
Expand Down Expand Up @@ -269,8 +269,8 @@ Vagrant.configure(VAGRANT_FILE_API_VERSION) do |config|
'C:/Octopus/Logs/OctopusServer.txt',
'C:/Octopus/OctopusServer-ConfigurePreInstalledInstance.config',
'C:/Octopus/OctopusServer-OctopusServer.config'])
config.vm.provision "shell", inline: "& c:\\temp\\Tests\\register-polling-tentacle.ps1; exit $LASTEXITCODE"
config.vm.provision "shell", inline: "& c:\\temp\\Tests\\trigger-and-wait-for-healthcheck.ps1; exit $LASTEXITCODE"
config.vm.provision "shell", path: "Tests/register-polling-tentacle.ps1"
config.vm.provision "shell", path: "Tests/trigger-and-wait-for-healthcheck.ps1"
config.vm.provision "shell", inline: $run_test_scenario_script.gsub('{scenario_name}', 'tentacle_scenario_01_install')

# uninstall tentacle
Expand All @@ -282,7 +282,7 @@ Vagrant.configure(VAGRANT_FILE_API_VERSION) do |config|
'C:/Octopus/Logs/trigger-and-wait-for-healthcheck.txt',
'C:/Octopus/OctopusServer-ConfigurePreInstalledInstance.config',
'C:/Octopus/OctopusServer-OctopusServer.config'])
config.vm.provision "shell", inline: "& c:\\temp\\Tests\\trigger-and-wait-for-healthcheck.ps1; exit $LASTEXITCODE"
config.vm.provision "shell", path: "Tests/trigger-and-wait-for-healthcheck.ps1"
config.vm.provision "shell", inline: $run_test_scenario_script.gsub('{scenario_name}', 'tentacle_scenario_02_remove')

# Install old version
Expand All @@ -296,7 +296,7 @@ Vagrant.configure(VAGRANT_FILE_API_VERSION) do |config|
'C:/Octopus/OctopusServer-OctopusServer.config',
'C:/Octopus/OctopusTentacleHome/Logs/OctopusTentacle.txt',
'C:/Octopus/OctopusTentacleHome/Tentacle/Tentacle.config'])
config.vm.provision "shell", inline: "& c:\\temp\\Tests\\trigger-and-wait-for-healthcheck.ps1; exit $LASTEXITCODE"
config.vm.provision "shell", path: "Tests/trigger-and-wait-for-healthcheck.ps1"
config.vm.provision "shell", inline: $run_test_scenario_script.gsub('{scenario_name}', 'tentacle_scenario_03_reinstall')

# Upgrade it
Expand All @@ -310,7 +310,7 @@ Vagrant.configure(VAGRANT_FILE_API_VERSION) do |config|
'C:/Octopus/OctopusServer-OctopusServer.config',
'C:/Octopus/OctopusTentacleHome/Logs/OctopusTentacle.txt',
'C:/Octopus/OctopusTentacleHome/Tentacle/Tentacle.config'])
config.vm.provision "shell", inline: "& c:\\temp\\Tests\\trigger-and-wait-for-healthcheck.ps1; exit $LASTEXITCODE"
config.vm.provision "shell", path: "Tests/trigger-and-wait-for-healthcheck.ps1"
config.vm.provision "shell", inline: $run_test_scenario_script.gsub('{scenario_name}', 'tentacle_scenario_04_upgrade')

# install watchdog
Expand Down

0 comments on commit 369f6e8

Please sign in to comment.