Giter VIP home page Giter VIP logo

chocolatey-test-environment's Introduction

Chocolatey Testing Environment

A testing environment setup similar to the package-verifier for testing packages. Over time this will add more Windows platforms for testing.

When creating packages or testing other parts of Chocolatey, this environment provides a good base for an independent testing minus any dependencies you may already have installed. It also allows you to completely destroy an environment and then just tear it down without worry about messing up something on your own system.

When creating packages, please review https://github.com/chocolatey/choco/wiki/CreatePackages

Table of Contents

Requirements

You need a computer with:

  • a 64-bit processor and OS
  • Intel VT-x enabled (usually not an issue if your computer is newer than 2011). This is necessary because we are using 64bit VMs.
  • Hyper-V may need to be disabled for Virtualbox to work properly if your computer is a Windows box. NOTE: This may actually not be required.
  • At least 50GB of free space.

Setup

To get started, ensure you have the following installed:

  • Vagrant 2.1+ - linked clones is the huge reason here. You can technically use any version of Vagrant 1.3.5+. But you will get the best performance with 2.1.x.
  • VirtualBox 5.2+

NOTE: If you decide to run with version 1.8.1 of Vagrant, you are going to need to set the VAGRANT_SERVER_URL environment variable as described in this forum post, otherwise, you will get an HTTP 404 error when attempting to download the base vagrant box used here.

Running Verification Manually

NOTE: The CDN for packages on https://chocolatey.org will only update every 30 minutes. This means if you just pushed an updated version, within 30 minutes from the last access time of the package it will be updated. This is why the validator and verifier wait for 31 minutes prior to testing a package.

Preparing the Testing Environment

  1. Ensure setup above is good on your machine.
  2. Fork and Clone this repository
  3. Open a command line (PowerShell.exe/cmd.exe on Windows, bash everywhere else) and navigate to the root folder of the repository. You know you are in the right place when you do a dir or ls and Vagrantfile is in your path.
    • No idea if bash on Windows (through Git/CygWin) is supported. If you run into issues, it is better to just use PowerShell.exe or cmd.exe. Please do not file issues stating it doesn't work.
  4. Run vagrant up to prepare the machine for testing.
    • Note due to the way that vagrant works, the first time that you run this command, the vagrant box named chocolatey/test-environment needs to be downloaded from the Vagrant Cloud. This will take quite a while, and should only be attempted on a reasonably fast connection, that doesn't have any download limit restrictions. Once it has downloaded it will import the box and apply the scripts and configurations to the box as listed inside the Vagrantfile. You can find the downloaded box in the ~/.vagrant.d or c:\users\username\.vagrant.d folder.
  5. Now the box is ready for you to start testing against.
  6. Run the following command: vagrant snapshot save good. This takes a snapshot of the VM using the built-in snapshot functionality. This means that after testing packages, the VM can be returned to this known "good" state.

Testing a Package

For testing a package, you have two avenues. For a locally built package, you can drop the package into the packages folder in the root of the cloned repository - it is shared with the box as C:\packages, so you can run a command on the box or with the inline provisioner (recommended as it is a closer match to the verifier) using --source c:\packages as an argument for installation. If you are trying to reproduce/investigate a problem with a package already up on the website, you can use --version number with your install arguments and that will let you install a package that is not listed (in most cases not yet approved).

  1. Search the Vagrantfile for # THIS IS WHAT YOU CHANGE. Uncomment and edit the line which best meets the current situation that you are testing.
  2. Run vagrant provision.
  3. Watch the output and go to the box for further inspection if necessary.
  4. If you need to change output or try something else, read the next section.

Make Changes and Retest

When you need to investigate making changes and rerunning the tests, remember that we took a snapshot of the vagrant machine (the virtual machine), so we can rollback to the earlier state each time and move forward with testing changes without the possibility of lingering artifacts. This is why we are using the vagrant snapshot command, it allows us to take a snapshot and then revert the virtual machine back to the previous state.

When you are ready to reset to the state just before installing:

  1. Run vagrant snapshot restore good --no-provision
  2. Follow the steps in testing a package (previous section).

Tearing Down the Testing Environment

NOTE: At any time you can:

  • stop the box with vagrant suspend, vagrant halt
  • delete the box with vagrant destroy

Upgrading the Testing Environment

When bringing up your testing environment Vagrant may report that the box being used is out of date. You can also manually check to see if a newer box is available using the vagrant box outdated command.

To upgrade the vagrant box used by your testing environment:

  1. Download the new box with vagrant box update
    • Note as with the initial setup, this is a large download so please be patient
  2. Delete the existing testing environment with vagrant destroy
  3. Restore the Vagrantfile back to it's default, i.e. there should not be any uncommented lines from testing packages
    • Note you may wish to take this opportunity to fetch the latest changes from this repository
  4. Run vagrant up to prepare the testing environment with the new box
  5. Snapshot the updated testing environment with vagrant snapshot save good

Using a Specific Vagrant Box Version

If you don't want to use the latest available Vagrant box, you can select a specific box version or otherwise constrain the valid versions used in your testing environment. To do so, edit the Vagrantfile and uncomment the config.vm.box_version line.

By default this will set the desired box version to "2.0.0" which is the last Windows Server 2012 R2 version available.

You can adjust this setting to meet your needs, for more information on the options available see the documentation on Version Constraints.

For more information on vagrant commands, see the Vagrant Docs

Using Hyper-V instead of VirtualBox

Caution

It is recommended to favor running the Chocolatey Test Environment under VirtualBox.

Hyper-V support is intended to lower the barrier to entry for those using Windows features which force the usage of Hyper-V, such as the Windows Subsystem for Linux (WSL 2), Windows Sandbox, Device Guard, and Credential Guard.

Please be sure that you're aware of the limitations of using the Vagrant Hyper-V provider.

Note

The Hyper-V role requires Windows 10 or 11 Enterprise, Pro, or Education. It cannot be installed on Home editions of Windows.

  1. Ensure setup above is complete, ignoring the need for VirtualBox.
  2. Enable the Hyper-V feature:
    • Open a PowerShell console as Administrator.
    • Run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All -All.
    • Restart Windows.
  3. Follow the general instructions to prepare the testing environment, swapping the default vagrant up command with vagrant up --provider=hyperv.
    • The Hyper-V image, downloaded the first time you run command is very large (> 5GB) and specific to Hyper-V.

Differences Between This and Package Verifier Service

There are a couple of difference between the Package Verifier service and this environment.

  • The verifier is run without the GUI - meaning it is run in a headless state. There is no box to interact with.

  • Package Verifier only runs against Windows Server 2019, currently.

  • Package Verifier times out on waiting for a command after 12 minutes.

  • Synced folders are different - Package Verifier syncs the .chocolatey folder to gather the package information files.

  • Specific VM settings are different (for performance):

    • No GUI (as previously mentioned) - v.gui = false
    • 6GB RAM - v.customize ["modifyvm", :id, "--memory", "6144"]
    • 4 CPUs - v.customize ["modifyvm", :id, "--cpus", "4"]
    • Clipboard disabled - v.customize ["modifyvm", :id, "--clipboard", "disabled"]
    • Drag and Drop disabled - v.customize ["modifyvm", :id, "--draganddrop", "disabled"]

Troubleshooting

Error: "A Vagrant environment or target machine is required to run this command."

Run vagrant init to create a new Vagrant environment. Or, get an ID of a target machine from vagrant global-status to run this command on. A final option is to change to a directory with a Vagrantfile and to try again." - please ensure you are on the correct working directory (where this ReadMe and Vagrantfile is) of this repo and try again.

Error: "WinRM: Warning: Authentication failure. Retrying..." and when the machine boots the C:\packages" folder is not present (and other configuration has not occurred).

Edit Vagrantfile and find the # Port forward WinRM / RDP section. uncomment #, host_ip: "127.0.0.1" (remove the #). Run vagrant up again.

config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true , host_ip: "127.0.0.1"

chocolatey-test-environment's People

Contributors

cfoellmann avatar dtgm avatar ferventcoder avatar franklinyu avatar gep13 avatar jordandoerksen avatar mgmax avatar mistuke avatar mkevenaar avatar mwrock avatar pauby avatar peterdavehello avatar stefanscherer avatar tirolo avatar webprofusion-chrisc avatar windos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chocolatey-test-environment's Issues

VBoxManage: error: Unknown option: --clipboard

Using the an unchanged Vagrantfile vagrant/virtualbox throws an error

$ vagrant up --provider  virtualbox
<snip>
["modifyvm", :id, "--clipboard", "bidirectional"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "c553546c-59f4-4524-957e-05ef4a7bda54", "--clipboard", "bidirectional"]

$ vagrant --version
Vagrant 2.2.6

$ VBoxManage --version
6.1.0r135406

Maybe this is the problem?
https://forums.virtualbox.org/viewtopic.php?f=6&t=95992

What's odd, if I REMOVE this line

v.customize ["modifyvm", :id, "--clipboard", "bidirectional"]

from the Vagrantfile I still get the error

Couple thoughts...

Thanks so much for setting this up!

On this item: "Hyper-V may need to be disabled for Virtualbox to work properly if your computer is a Windows box." - I know you can't run VMWare and Hyper-V, but I've never had troubles with Virtual Box with Hyper-V enabled on Win 8.1 and 10. Maybe if there have been known observed cases of conflict change this to "Although rare, in some cases Hyper-V may need to be disabled for Virtualbox to work properly on Windows."

Would be great to show the actual git clone command somewhere and give it a sample folder for the rest of the doc. Like this:

git clone https://github.com/chocolatey/chocolatey-test-environment.git c:\users\public\chocolatey-test-environment

OR

git clone https://github.com/chocolatey/chocolatey-test-environment.git

Virtualbox-guest-editions-error

Not sure if this is the right place to report issues while installing packages, but, ...

I ran into error and failure to install VB-GuestEditions.

Choco: Latest
VB: 6.0.12
Currently installed guest-editions: 6.0.8

image

Clipto Pro 2.4.0 fails to install inside Chocolatey-test-environment

It has worked wit Clipto Pro 2.2.2.

The same Chocolatey Package for Clipto Pro fails with the version 2.4.0 with the Chocolatey-Test-Environment but is successful on my Windows 10 computer:

#### INSTALLED WITH CHOCOLATEY ####
C:\Users\Administrator>cinst clipto-pro.install -pre --version=2.4.0
Chocolatey v0.10.15
Installing the following packages:
clipto-pro.install
By installing you accept licenses for the packages.
Progress: Downloading clipto-pro.install 2.4.0... 100%

clipto-pro.install v2.4.0 - Possibly broken
clipto-pro.install package files install completed. Performing other installatio
n steps.
Downloading clipto-pro.install
from 'https://github.com/clipto-pro/Desktop/releases/download/v2.4.0/clipto.pr
o-2.4.0.exe'
Progress: 100% - Completed download of C:\Users\Administrator\AppData\Local\Temp
\1\chocolatey\clipto-pro.install\2.4.0\clipto.pro-2.4.0.exe (43.85 MB).
Download of clipto.pro-2.4.0.exe (43.85 MB) completed.
Hashes match.
Installing clipto-pro.install...
ERROR: Running ["C:\Users\Administrator\AppData\Local\Temp\1\chocolatey\clipto-p
ro.install\2.4.0\clipto.pro-2.4.0.exe" /S ] was not successful. Exit code was '-
1073741819'. See log for possible error messages.
The install of clipto-pro.install was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\clipto-pro.install\tools\choc
olateyinstall.ps1'.
See log for details.

Chocolatey installed 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures

  • clipto-pro.install (exited -1073741819) - Error while running 'C:\ProgramData
    \chocolatey\lib\clipto-pro.install\tools\chocolateyinstall.ps1'.
    See log for details.
    ----> Result: Clipto is not installed.

#### INSTALLED OUTSIDE CHOCOLATEY ####
C:\Users\Administrator>"C:\Users\Administrator\AppData\Local\Temp\1\chocolatey\c
lipto-pro.install\2.4.0\clipto.pro-2.4.0.exe" /S
----> Result: Clipto is installed.

The following WinRM command responded with a non-zero exit status

Hey Guys,

I'm unsure why when testing choco packages that exit in a 3010 I get the following error:

The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

powershell -ExecutionPolicy Bypass -OutputFormat Text -file "c:\tmp\vagrant-shell.ps1"

Stdout from the command:

Error message:
https://gist.github.com/shaun-rutherford/083400876d203e59a48f45e08f162efe

Vagrantfile:
https://gist.github.com/shaun-rutherford/a5c6c3e70a383d79f644f707e2c7b6da

The package passes if I install it once, reload the box and install it again. This is not really Ideal though as the install process takes ~15 mins each time.

I've tried doing a reload in advance but that doesn't work either.

Any assistance would really be appreciated.

Glasswire update fail verification

I have recently became a maintainer of the 'glasswire' package. Its download was hardcoded to always point to the newest version, so any changes broke the checksum.

I updated the checksum and rebuilt the nupkg.

The nupkg failed first verification here:
https://gist.github.com/choco-bot/aa8fd0bf1f4f1625b26dee1ea9871cbf

The first block made me think it needed VC++ redist 2015 so I added it as a dependancy and resubmitted.

Current failure here:
https://gist.github.com/7595613a3f972a892d5f20d2311a1d94

Any assistance in getting to the bottom of this would be appreciated.

FYI: Strangely it only installed correctly when installing in the form
choco install glasswire -source path

AND not install glasswire 2.1.152.nupkg (it would still use old checksum)

Old VirtualBox version requirement

The "suggestion" for using VirtualBox 4.x (rather than 5.x) seems really outdated. Although there is a 4.3.40 package that was put out there just a couple weeks ago, the last previous 4.x release was almost 2 years ago with many 5.x releases since then.

I already have several VMs happily running in v5.2. I'd prefer to avoid the need to scrap those, uninstall VirtualBox, and install what seems reasonable to assume is a "less modern" version just so I can occasionally test a package that behaves for me on other VMs but fails automated testing. At the same time, I am stuck with packages that can't be approved because they fail.

While I am (just barely) astute enough to install and use VirtualBox, I am not well versed on it. I really don't know how the changes from 4 to 5 may have impacted things. What are the implications of using the Chocolatey-test-environment with v5, and what are the chances that the test environment can be updated to work with VirtualBox 5.x?

Thanks.

Support dotnet3.5 and other server features

I have a package that depends on the dotnet3.5 package, which uses DISM, as it's a "feature" of most Windows versions now. However, it fails dramatically on this box. I'll snip around the nasty XML output that's dumped to the console.

> choco install -y dotnet3.5
...

Deployment Image Servicing and Management tool
Version: 6.3.9600.16384

Image Version: 6.3.9600.16384

Enabling feature(s)

Error: 0x800f0906

The source files could not be downloaded.
Use the "source" option to specify the location of the files that are required to restore the feature. For more informa
tion on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077.
...

ERROR: Running ["C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" cmd.exe /c DISM /Online /NoRestart /Enable-
Feature /FeatureName:NetFx3] was not successful. Exit code was '1'. See log for possible error messages.
The install of dotnet3.5 was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\DotNet3.5\Tools\ChocolateyInstall.ps1'.
 See log for details.

Chocolatey installed 0/1 package(s). 1 package(s) failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Failures:
 - dotnet3.5 (exit code 1)

When I log onto the box and try to enable the feature manually, I get a similar nasty error.

image

And

[127.0.0.1]: PS C:\Users\Administrator\Documents> Add-WindowsFeature Net-Framework-Core
Add-WindowsFeature : The request to add or remove features on the specified server failed.
Installation of one or more roles, role services, or features failed.
The source files could not be downloaded.
Use the "source" option to specify the location of the files that are required to restore the feature. For more
information on specifying a source location, see http://go.microsoft.com/fwlink/?LinkId=243077. Error: 0x800f0906
    + CategoryInfo          : InvalidOperation: (@{Vhd=; Credent...Name=localhost}:PSObject) [Install-WindowsFeature],
    Exception
    + FullyQualifiedErrorId : DISMAPI_Error__Cbs_Download_Failure,Microsoft.Windows.ServerManager.Commands.AddWindowsF
   eatureCommand

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
False   No             Failed         {}

Looks like it was specifically removed from the box? Maybe it's removed by default.

[127.0.0.1]: PS C:\Users\Administrator\Documents> Get-WindowsFeature Net-Framework-Core

Display Name                                            Name                       Install State
------------                                            ----                       -------------
    [ ] .NET Framework 3.5 (includes .NET 2.0 and 3.0)  NET-Framework-Core               Removed

I can set a source manually if I have the install media (I don't, I guess I could download it). I don't know if the dotnet3.5 package supports alternate sources.

Should we install this feature by default or leave the sources on the local disk or something?

Support `choco verify mypackage.1.1.0.nupkg`

Support choco verify mypackage.1.1.0.nupkg

I have been resubmitting my package but have failed verification with little information on why installation test failed. It would be nice if choco CLI support this command. This uploads the package to test environment, run verification then return results right away with rich enough information on why it failed.

choco verify mypackage.1.1.0.nupkg

A setup guide with docker-compose would also be nice.

Add back in Hyper-V provider

As of v3.0.0, the Hyper-V box was removed, so the Hyper-V provider no longer works as is.
Converting the Virtualbox image to Hyper-V is possible, but is an undocumented, potentially painful process.

Given that Virtualbox does not fully work when Hyper-V is enabled (which includes WSL 2, Windows Sandbox, and Credential/Device Guard), having a Hyper-V box would be useful and would reduce testing friction for some maintainers.

Chocolatey install - Could not create SSL/TLS secure channel

Hi everybody, I hope you all have a great day ๐Ÿ™‚

I submit this issue to you because I have a problem with the installation of Chocolatey on the test environnement. Indeed, when running the command vagrant provision to run test a package, I end up with the following error :

==> default: Running provisioner: shell...
    default: Running: shell/InstallChocolatey.ps1 as c:\tmp\vagrant-shell.ps1
    default: Exception calling "DownloadString" with "1" argument(s): "The request was 
    default: aborted: Could not create SSL/TLS secure channel."
    default: At C:\tmp\vagrant-shell.ps1:70 char:7
    default: +       iex ((new-object 
    default: net.webclient).DownloadString('https://chocolatey.org/ins ...
    default: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    default: ~~~
    default:     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    default:     + FullyQualifiedErrorId : WebException
    default: choco : The term 'choco' is not recognized as the name of a cmdlet, function, 
    default: script file, or operable program. Check the spelling of the name, or if a path 
    default: was included, verify that the path is correct and try again.
    default: At C:\tmp\vagrant-shell.ps1:78 char:1
    default: + choco feature enable -n autouninstaller
    default: + ~~~~~
    default:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFou 
    default:    ndException
    default:     + FullyQualifiedErrorId : CommandNotFoundException
    default: choco : The term 'choco' is not recognized as the name of a cmdlet, function, 
    default: script file, or operable program. Check the spelling of the name, or if a path 
    default: was included, verify that the path is correct and try again.
    default: At C:\tmp\vagrant-shell.ps1:79 char:1
    default: + choco feature enable -n allowGlobalConfirmation
    default: + ~~~~~
    default:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFou 
    default:    ndException
    default:     + FullyQualifiedErrorId : CommandNotFoundException
    default: choco : The term 'choco' is not recognized as the name of a cmdlet, function, 
    default: script file, or operable program. Check the spelling of the name, or if a path 
    default: was included, verify that the path is correct and try again.
    default: At C:\tmp\vagrant-shell.ps1:80 char:1
    default: + choco feature enable -n logEnvironmentValues
    default: + ~~~~~
    default:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFou 
    default:    ndException
    default:     + FullyQualifiedErrorId : CommandNotFoundException

Here are the information of my setup:

  • Vagrant, version 2.2.7
  • VirtualBox, version 6.1.2 r135662
  • Chocolatey, version 0.10.15

This is my first package, so I may have some element not setup correctly triggering this error.
For information, I currently try to upgrade the conan package.

Thank you all for your attention,
I hope you can help me with this issue so that I can finally finish upgrading conan package ๐Ÿ˜„

CategoryInfo: OperationStopped: (:) [], ArgumentException

Very weird. I did not recall changing anything.

==> default: Running provisioner: shell...
    default: Running: shell/PrepareWindows.ps1 as c:\tmp\vagrant-shell.ps1
    default: (10,8):UserId:
    default: At line:72 char:1
    default: + $folder.RegisterTaskDefinition($task_name, $task, 6, $username, $pass ...
    default: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    default:     + CategoryInfo          : OperationStopped: (:) [], ArgumentException
    default:     + FullyQualifiedErrorId : System.ArgumentException
    default: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
    default: At line:74 char:1
    default: + $registered_task = $folder.GetTask("\$task_name")
    default: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    default:     + CategoryInfo          : OperationStopped: (:) [], FileNotFoundException
    default:     + FullyQualifiedErrorId : System.IO.FileNotFoundException
    default: You cannot call a method on a null-valued expression.
    default: At line:75 char:1
    default: + $registered_task.Run($null) | Out-Null
    default: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    default:     + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    default:     + FullyQualifiedErrorId : InvokeMethodOnNull

Print spooler disabled - purposefully or bug?

REF: https://groups.google.com/forum/#!searchin/chocolatey/spooler%7Csort:date/chocolatey/v50KZuRRjjw/N6CB352XCgAJ
REF: https://groups.google.com/forum/#!searchin/chocolatey/spooler%7Csort:date/chocolatey/uOHpAx7j_Xs/sWDfzsa3HAAJ

The print spooler is disabled by default in the Chocolatey Test Environment. Is this purposeful or an oversight?

This seems to be a bug to me as the Print Spooler service would be set to Automatic in real world OOTB default Windows configurations.

Why does vagrant display error if no package is tested?

Write-Output "Testing package if a line is uncommented. Otherwise you will see an error."

why vagrant do that?

Vagrantfile https://github.com/chocolatey/chocolatey-test-environment/blob/master/Vagrantfile#L95-L108

$ErrorActionPreference = "Stop"
$env:PATH +=";$env:SystemDrive\\ProgramData\\chocolatey\\bin"
Write-Output "Testing package if a line is uncommented. Otherwise you will see an error."
# THIS IS WHAT YOU CHANGE
# - uncomment one of the two and edit it appropriately
# - See the README for details
#choco.exe install -fdvy INSERT_NAME --version INSERT_VERSION  --allow-downgrade
#choco.exe install -fdvy INSERT_NAME  --allow-downgrade --source "'c:\\packages;http://chocolatey.org/api/v2/'"
# vagrant has issues knowing that there was an error
if ($LASTEXITCODE -ne 0) {
  exit 1
}

vagrant provision output

PS C:\dev\chocolatey-test-environment> vagrant provision
==> default: Running provisioner: shell...
    default: Running: shell/PrepareWindows.ps1 as c:\tmp\vagrant-shell.ps1
==> default: IE Enhanced Security Configuration (ESC) has been disabled.
==> default: IE first run welcome screen has been disabled.
==> default: Setting Windows Update service to Manual startup type.
==> default: Running provisioner: shell...
    default: Running: shell/InstallNet4.ps1 as c:\tmp\vagrant-shell.ps1
==> default: Running provisioner: shell...
    default: Running: shell/InstallChocolatey.ps1 as c:\tmp\vagrant-shell.ps1
==> default: Chocolatey v0.9.10-beta1-151-ga83d5c5
==> default: Nothing to change. Config already set.
==> default: Chocolatey v0.9.10-beta1-151-ga83d5c5
==> default: Nothing to change. Config already set.
==> default: Chocolatey v0.9.10-beta1-151-ga83d5c5
==> default: Nothing to change. Config already set.
==> default: Running provisioner: shell...
    default: Running: shell/NotifyGuiAppsOfEnvironmentChanges.ps1 as c:\tmp\vagrant-shell.ps1
==> default: 1
==> default:
==> default: SUCCESS: Specified value was saved.
==> default: Running provisioner: shell...
    default: Running: inline PowerShell script
==> default: Testing package if a line is uncommented. Otherwise you will see an error.
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:\tmp\vagrant-shell.ps1

Stdout from the command:



Stderr from the command:


The port chosen for WinRM is in reserved range

PS C:\Users\Jakub> netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges

Start Port    End Port
----------    --------
      5357        5357
     50000       50059     *
     51940       52039
     52040       52139
     55954       56053
     56054       56153
     56154       56253
     56254       56353
     56354       56453
     56454       56553
     56654       56753
     56754       56853
     56854       56953
     56954       57053
     57054       57153
     57154       57253

* - Administered port exclusions.

This means that this port can't be bound at all which causes vagrant up due to timeout while trying to connect through WinRM as that never ends up getting bound.

In general, I would suggest choosing ports that are within user ports range (1024-49151) to avoid these kind of problems.

using hyperv provider, can not read files in /packages share

By using the hyperv provider for vagrant, I am unable to read files in the /packages share. I can see and list (dir) the files, but I can not read the files.

Setup

  • Windows 10 pro ver 1903 (Version 10.0.18362.175)
  • hyperv installed and working across multiple other things (hyperv itself, docker, etc.)
  • Vagrant 2.2.4

Repo

  1. Setup as per instructions at https://github.com/chocolatey-community/chocolatey-test-environment/blob/master/ReadMe.md except for the following:
    • No Virtualbox -- we will be using the hyperv box and provider
    • No plugin sahara -- this is unneeded for this issue
  2. vagrant winrm -e -s powershell -c "copy c:/packages/*.* c:/"

Result

copy : Could not find file 'C:\packages\ReadMe.md'.
At C:\windows\temp\winrm-elevated-shell-fff58481-a970-493f-9281-4d343fbfd9b2.ps
1:1 char:1
+ copy c:/packages/*.* c:/
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], FileNotFoundExcep
   tion
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerS
   hell.Commands.CopyItemCommand

Expected

No errors and the Readme.md file to be copied.

Notes

Listing files succeeds like this:

vagrant winrm -e -s powershell -c "dir C:/packages/"
    Directory: C:\packages
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         6/19/2019  12:05 AM        113 ReadMe.md

All attempts to read the files (like readme.md) usign different methods results in similar errors. For example, editing the Vagrantfile to have a provision command type c:/packages/ReadMe.md results in the error:

==> default: Running provisioner: shell...
    default: Running: inline PowerShell script
    default: SUCCESS: Specified value was saved.
    default: Testing package if a line is uncommented.
    default: type : Cannot find path 'C:\packages\ReadMe.md' because it does not exist.
    default: At C:\tmp\vagrant-shell.ps1:16 char:1
    default: + type c:/packages/ReadMe.md
    default: + ~~~~~~~~~~~~~~~~~~~~~~~~~~
    default:     + CategoryInfo          : ObjectNotFound: (C:\packages\ReadMe.md:String) [
    default:    Get-Content], ItemNotFoundException
    default:     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetCo
    default:    ntentCommand

Manipulating the permissions on the packages folder and files on the host did not resolve the problems. I added full access to Everyone and yet the files can be seen, but can not be read.

In ba95e7d the hyperv provider and box was added. Was the read of local packages in the /packages share tested? If so, are there setup/permission/file requirements to get it to work?

FEATURE REQUEST: screenshot upon install failure saved along with gist

I've bumped into:

2019-03-07 01:49:44,741 2536 [WARN ] - Chocolatey timed out waiting for the command to finish. The timeout
specified (or the default value) was '2700' seconds. Perhaps try a
higher --execution-timeout? See choco -h for details.

...too numerous amount of times to mention.

A screenshot at that moment of failure would be immensely helpful to package maintainers who didn't expect a pop up request to install a dependency or a reboot request etc.

Warning: Authentication failure

I'm having trouble to get a working test environment, working as a local administrator on the host in question.

Windows 10 Pro 1803 (patched-to-date)
Vagrant 2.1.5
VirtualBox 5.2.18 r124319
VirtualBox Extension Pack 5.2.18 r124319

I forked/cloned chocolatey-test-environment yesterday, so have a fresh copy.

When I do:

vagrant up

A Windows Server 2012 R2 DC vm is launched/booted. But I start seeing default: Warning: Authentication failure. Retrying... And eventually, Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period.

See screenshot

I thought installing VirtualBox Guest Additions in the VM may be the key, but that made no difference, even after doing:

vagrant suspend
vagrant halt
vagrant up

I also tried

vagrant suspend
vagrant halt
vagrant destroy
vagrant up

It didn't help. Any suggestions would be appreciated!

Error: Could not find a part of the path 'C:\ProgramData\chocolatey\config\chocolatey.config'

After following the setup instructions and using a Virbualbox 4.3 release, I get errors while running vagrant provision:

==> default: Error deserializing response of type chocolatey.infrastructure.app.configuration.ConfigFileSettings:
==> default:
==> default: Could not find a part of the path 'C:\ProgramData\chocolatey\config\chocolatey.config'.
==> default: Could not find a part of the path 'C:\ProgramData\chocolatey\config\chocolatey.config'.
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:\tmp\vagrant-shell.ps1

Stdout from the command:

Stderr from the command:

Vagrantfile no longer works with virtualbox

Update to date clone, the vagrant file cannot find the virtualbox box to download

>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'chocolatey/test-environment' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'chocolatey/test-environment'
    default: URL: https://vagrantcloud.com/chocolatey/test-environment
The box you're attempting to add doesn't support the provider
you requested. Please find an alternate box or use an alternate
provider. Double-check your requested provider to verify you didn't
simply misspell it.

If you're adding a box from HashiCorp's Vagrant Cloud, make sure the box is
released.

Name: chocolatey/test-environment
Address: https://vagrantcloud.com/chocolatey/test-environment
Requested provider: [:virtualbox]

It looks like only the hyper-v version has been released.

image

Vagrant 2.2.2 detects vulnerability with VM and the E1000 NIC

Upgraded to Vagrant v2.2.2 and receive this warning

==> default: Vagrant has detected a configuration issue which exposes a
==> default: vulnerability with the installed version of VirtualBox. The
==> default: current guest is configured to use an E1000 NIC type for a
==> default: network adapter which is vulnerable in this version of VirtualBox.
==> default: Ensure the guest is trusted to use this configuration or update
==> default: the NIC type using one of the methods below:
==> default:
==> default:   https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
==> default:   https://www.vagrantup.com/docs/virtualbox/networking.html#virtualbox-nic-type

The request was aborted: Could not create SSL/TLS secure

Just started having this problem today.

==> default: Running provisioner: shell...
    default: Running: shell/InstallChocolatey.ps1 as C:\tmp\vagrant-shell.ps1
    default: powershell.exe : Exception calling "DownloadString" with "1" argument(s): "The request was aborted: Could not create SSL/TLS secure
    default:     + CategoryInfo          : NotSpecified: (Exception calli...SSL/TLS secure :String) [], RemoteException
    default:     + FullyQualifiedErrorId : NativeCommandError
    default: channel."
    default: At C:\tmp\vagrant-shell.ps1:70 char:7
    default: +       iex ((new-object net.webclient).DownloadString('https://chocolatey.org/ins ...
    default: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    default:     + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    default:     + FullyQualifiedErrorId : WebException
    default:
    default: choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    default: the spelling of the name, or if a path was included, verify that the path is correct and try again.
    default: At C:\tmp\vagrant-shell.ps1:78 char:1
    default: + choco feature enable -n autouninstaller
    default: + ~~~~~
    default:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    default:     + FullyQualifiedErrorId : CommandNotFoundException
    default:
    default: choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    default: the spelling of the name, or if a path was included, verify that the path is correct and try again.
    default: At C:\tmp\vagrant-shell.ps1:79 char:1
    default: + choco feature enable -n allowGlobalConfirmation
    default: + ~~~~~
    default:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    default:     + FullyQualifiedErrorId : CommandNotFoundException
    default:
    default: choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    default: the spelling of the name, or if a path was included, verify that the path is correct and try again.
    default: At C:\tmp\vagrant-shell.ps1:80 char:1
    default: + choco feature enable -n logEnvironmentValues
    default: + ~~~~~
    default:     + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    default:     + FullyQualifiedErrorId : CommandNotFoundException
    default:
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

powershell -ExecutionPolicy Bypass -OutputFormat Text -file "C:\tmp\vagrant-shell.ps1"

Stdout from the command:



Stderr from the command:

powershell.exe : Exception calling "DownloadString" with "1" argument(s): "The request was aborted: Could not create SSL/TLS secure
    + CategoryInfo          : NotSpecified: (Exception calli...SSL/TLS secure :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
channel."
At C:\tmp\vagrant-shell.ps1:70 char:7
+       iex ((new-object net.webclient).DownloadString('https://chocolatey.org/ins ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\tmp\vagrant-shell.ps1:78 char:1
+ choco feature enable -n autouninstaller
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\tmp\vagrant-shell.ps1:79 char:1
+ choco feature enable -n allowGlobalConfirmation
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\tmp\vagrant-shell.ps1:80 char:1
+ choco feature enable -n logEnvironmentValues
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

chocolatey-test-environment broken with VirtualBox 5.2.22

Upgraded to VirtualBox Version 5.2.22 r126460 (Qt5.6.3) on macOS 10.12.6 and the VM networking does not work. In fact, the 2012 VM does not even detect a network interface.

menubar_and_chocolatey-test-environment_default_1543249167931_27622__running__and_new_issue_ _chocolatey_chocolatey-test-environment

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Cloning VM...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ferventcoder/win2012r2-x64-nocm' is up to date...
==> default: Setting the name of the VM: chocolatey-test-environment_default_1543249167931_27622
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 5985 (guest) => 5985 (host) (adapter 1)
    default: 3389 (guest) => 3389 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
    default: 5986 (guest) => 55986 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: WinRM address: 127.0.0.1:5985
    default: WinRM username: vagrant
    default: WinRM execution_time_limit: PT2H
    default: WinRM transport: negotiate
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
$ vagrant box outdated
Checking if box 'ferventcoder/win2012r2-x64-nocm' is up to date...
$ vagrant box update
==> default: Checking for updates to 'ferventcoder/win2012r2-x64-nocm'
    default: Latest installed version: 1.0.0
    default: Version constraints:
    default: Provider: virtualbox
==> default: Box 'ferventcoder/win2012r2-x64-nocm' (v1.0.0) is running the latest version.
$ git pull upstream master
From https://github.com/chocolatey/chocolatey-test-environment
 * branch            master     -> FETCH_HEAD
Already up to date.
$ vagrant --version
Vagrant 2.2.1

Documentation error: [verifier service]()

There's a broken link in the ReadMe.md and I don't know where to point the link.

There are a couple of difference between the [verifier service]() and this environment.

Instructions not working

I really have no idea how Vagrant works, but walking through the instructions apparently isn't enough:

PS C:\chocolatey-test-environment> vagrant sandbox on
[default] Starting sandbox mode...
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
PS C:\chocolatey-test-environment> vagrant provision
==> default: Running provisioner: shell...
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.
PS C:\chocolatey-test-environment> vagrant sandbox rollback
[default] Rolling back the virtual machine...
VBoxManage.exe: error: Machine '0a9cbe89-3445-43eb-a029-bb0e81a53035' is not currently running
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
PS C:\chocolatey-test-environment> vagrant provision
==> default: Running provisioner: shell...
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.
PS C:\chocolatey-test-environment> vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: Guest communication could not be established! This is usually because
    default: SSH is not running, the authentication information was changed,
    default: or some other networking issue. Vagrant will force halt, if
    default: capable.
==> default: Forcing shutdown of VM...
PS C:\chocolatey-test-environment> vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...
PS C:\chocolatey-test-environment> vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Cloning VM...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ferventcoder/win2012r2-x64-nocm' version '1.0.0' is up to date...
==> default: Setting the name of the VM: chocolatey-test-environment_default_1550549316175_62876
==> default: Fixed port collision for 5985 => 5985. Now on port 2250.
Vagrant found a port collision for the specified port and virtual machine.
While this port was marked to be auto-corrected, the ports in the
auto-correction range are all also used.

VM: default
Forwarded port: 3389 => 3389
PS C:\chocolatey-test-environment> vagrant sandbox on
[default] Starting sandbox mode...
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
PS C:\chocolatey-test-environment> vagrant provision
==> default: VM is not currently running. Please, first bring it up with `vagrant up` then run this command.

vagrant destroy didn't appear to actually destroy anything. How can I back out entirely and start again? (and will that make any difference, or do I need to be fixing something else?)

Provide guidance on Vagrant Box version management

Assuming there's multiple versions of the test environment's official Vagrant box available, then documentation should be included to cover:

  1. Updating the Testing Environment
  2. Selecting the desired box version to use

Missing the Code of Conduct

Hello, this project is currently missing the Code of Conduct. If you are interested in adding one, then please let me know so that I can add a PR for that. Also, in that case, I would also need an address (email address) for adding that in the Code of Conduct file.

Support for parameters

While it is desirable to not require parameters, sometimes it is necessary. I have a package that requires a password and there is no way to pass that information to test environment.

I would like to propose support for a properties file e.g., tools\choco_test.properties that is optional and would be converted to --params "''" automatically before executing the command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.