Skip to content

Commit a91117f

Browse files
Address Issue OctopusDeploy#177, Hyper-V networking (OctopusDeploy#197)
* Hyper-v changes in response to OctopusDeploy#177. Extra documentation * couple of typos * Move setting of OctopusDSCVMSwitch env var into common code (should fix issue OctopusDeploy#176) * Should probably include the commit to build-hyperv.ps1 as well * Address PR feeedback * debug output to troubleshoot intermittent scenario_08 problem * Upgrade vagrant-dsc to 2.0.2
1 parent 0142826 commit a91117f

6 files changed

+33
-9
lines changed

CONTRIBUTING.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# How to Contribute
22
Thank you for going to the effort of contributing some code.
33

4-
If you've found a bug or something isn't working, please quickly check the issues in
4+
If you've found a bug or something isn't working, please quickly check the issues in
55
our [main issue repository](https://github.com/OctopusDeploy/Issues).
66

77
If your change is small or you have already made the change, please go ahead and submit a pull request.
@@ -10,4 +10,6 @@ For other changes, please raise an issue first to check that the change aligns w
1010

1111
If your pull request or proposed change is for a bug that is causing problems for you, please also [contact support](http://octopusdeploy.com/support) referencing your pull request to make sure it gets prioritized properly. They may also be able to find a work around in the meantime.
1212

13-
If you have an idea or a feature request, please post it to [our UserVoice site](http://octopusdeploy.uservoice.com) so others can vote for it.
13+
If you have an idea or a feature request, please post it to [our UserVoice site](http://octopusdeploy.uservoice.com) so others can vote for it.
14+
15+
If you're a keen contributor, a regular OctopusDSC user or just curious, please feel free to join us in the `#octopusdsc` channel at our [Community Slack](https://join.slack.com/t/octopususergroup/shared_invite/enQtNDcyNjM3OTczNzAxLTU0MjI3YmIyMDc1MzdmYjk3OTYzZGY4ZTI2NTcwMzY3OGJkZTExYTVkNThjYjM1MWE2YjlmNWQyMmQwNzRmMjk)

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ To run just the scenarios locally, follow these steps:
5959
5. If you want to test locally using Hyper-V
6060
- Run `vagrant plugin install vagrant-dsc`
6161
- Run `vagrant plugin install vagrant-winrm-syncedfolders`
62+
- Optionally set the environment variable `OctopusDSCVMSwitch`, to use a specific Hyper-V switch by name. For example, for older Hyper-V systems, you may wish to set this to 'External Connection'
6263
- Run `build-hyperv.ps1`. This will run all the scenarios under the [Tests](Tests) folder.
6364
6. If you want to test using AWS
6465
- Run `vagrant plugin install vagrant-aws`
@@ -78,6 +79,19 @@ To run just the scenarios locally, follow these steps:
7879
- Run `build-azure.ps1`. This will run all the scenarios under the [Tests](Tests) folder.
7980
8. Run `vagrant destroy -f` or the appropriate `cleanup-*.ps1` once you have finished to kill the virtual machine.
8081

81-
Tests are written in [ServerSpec](serverspec.org), which is an infrastructure oriented layer over [RSpec](rspec.info).
82+
Each of the `build-*` scripts can take parameters at the command prompt.
83+
84+
These are generally designed to tighten the feedback loop during development, since the VM-based integration test phase can be quite time consuming.
85+
86+
| Parameter | Type | Default Value | Description |
87+
| ----------------------------- | --------- | ---------------- | -------------------------------------------- |
88+
| `-SkipPester` | Switch | False | Skips the Pester and PSScriptAnalyzer unit tests, going straight to the slower, VM-based integration tests. |
89+
| `-ServerOnly` | Switch | False | Runs only the Server-related integration scenarios. |
90+
| `-TentacleOnly` | Switch | False | Runs Server scenarios 14 and 15 to install and configure an Octopus Deploy server instance, then moves on to Tentacle-related tests (which require a server to be present). |
91+
| `-OctopusVersion` | String | `vLatest` | Allows you to run tests against a specific version of Octopus Deploy. Does not apply to 'Scenario_07', which installs an older version in order to test upgrading. |
92+
| `-RetainOnDestroy` | Switch | False | Retains the virtual machine after the tests finish, so you can examine the state of the VM. |
93+
| `-debug` | Switch | False | Adds the `--debug` flag to the vagrant invocation, allowing you to step through the process and examine machine state before moving on. |
94+
95+
Tests are written in [ServerSpec](serverspec.org), which is an infrastructure oriented layer over [RSpec](rspec.info) and use our [octopus-serverspec-extensions](https://github.com/OctopusDeploy/octopus-serverspec-extensions) project for octopus-specific tests.
8296

8397
When creating a PR, please ensure that all existing tests run succesfully against VirtualBox, and please include a new scenario where possible. Before you start, please raise an issue to discuss your plans so we can make sure it fits with the goals of the project.

Tests/Scenarios/Server_Scenario_08_Upgrade.ps1

+3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ Configuration Server_Scenario_08_Upgrade
88
$pass = ConvertTo-SecureString "SuperS3cretPassw0rd!" -AsPlainText -Force
99
$cred = New-Object System.Management.Automation.PSCredential ("OctoAdmin", $pass)
1010

11+
Write-Output "Using ApiKey $($ENV:OctopusApiKey)" # debugging an intermittent issue in Scenario_08 throwing exception 'Cannot bind argument to parameter 'String' because it is null'
12+
1113
$pass = ConvertTo-SecureString $ENV:OctopusApiKey -AsPlainText -Force
14+
1215
$apiCred = New-Object System.Management.Automation.PSCredential ("ignored", $pass)
1316

1417
Node "localhost"

Tests/powershell-helpers.ps1

+7-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ function Test-CustomVersionOfVagrantDscPluginIsInstalled() { # does not deal we
5555

5656
write-host "It doesn't appear that you've got the custom Octopus version of the vagrant-dsc plugin installed" -foregroundcolor red
5757
write-host "Please download it from github:"
58-
write-host " irm https://github.com/OctopusDeploy/vagrant-dsc/releases/download/v2.0.1/vagrant-dsc-2.0.1.gem -outfile vagrant-dsc-2.0.1.gem"
59-
write-host " vagrant plugin install vagrant-dsc-2.0.1.gem"
58+
write-host " irm https://github.com/OctopusDeploy/vagrant-dsc/releases/download/v2.0.1/vagrant-dsc-2.0.2.gem -outfile vagrant-dsc-2.0.2.gem"
59+
write-host " vagrant plugin install vagrant-dsc-2.0.2.gem"
6060
exit 1
6161
}
6262

@@ -115,6 +115,11 @@ Function Set-OctopusDSCEnvVars {
115115
[string]$OctopusVersion
116116
)
117117

118+
if(-not $env:OctopusDSCVMSwitch)
119+
{
120+
$env:OctopusDSCVMSwitch = 'Default Switch' # Override this variable to use a different switch in hyper-v
121+
}
122+
118123
# Clear the OctopusDSCTestMode Env Var
119124
if(Test-Path env:\OctopusDSCTestMode) {
120125
get-item env:\OctopusDSCTestMode | Remove-Item

build-hyperv.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ else {
4343
}
4444
Write-Output "Hyper-V installed - good."
4545

46-
if (-not (Get-VMSwitch -SwitchType External -Name 'External Connection' -ErrorAction SilentlyContinue)) {
47-
Write-Output "Please create an external virtual switch named 'External Connection'."
46+
if (-not (Get-VMSwitch -Name $env:OctopusDSCVMSwitch -ErrorAction SilentlyContinue)) {
47+
Write-Output "Could not find a Hyper-V switch called $($env:OctopusDSCVMSwitch)"
4848
exit 1
4949
}
50-
Write-Output "External virtual switch detected - good."
50+
Write-Output (@("Hyper-V virtual switch '", $env:OctopusDSCVMSwitch, "' detected - good.") -join "")
5151

5252
Test-CustomVersionOfVagrantDscPluginIsInstalled
5353
Test-PluginInstalled "vagrant-winrm-syncedfolders"

vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Vagrant.configure(VAGRANT_FILE_API_VERSION) do |config|
8080
config.vm.provider "hyperv" do |v, override|
8181
override.vm.box = "OctopusDeploy/dsc-test-server-windows-server-1803"
8282
override.vm.box_url = "https://s3-ap-southeast-2.amazonaws.com/octopus-vagrant-boxes/vagrant/json/OctopusDeploy/hyperv/dsc-test-server-windows-server-1803.json"
83-
config.vm.network "public_network", bridge: "External Connection"
83+
config.vm.network "public_network", bridge: ENV['OctopusDSCVMSwitch']
8484
v.memory = 4096
8585
v.maxmemory = 4096
8686
v.cpus = 2

0 commit comments

Comments
 (0)