Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

[Enhancement] Install-ChocolateyService #489

Open
030 opened this issue Jun 19, 2014 · 22 comments
Open

[Enhancement] Install-ChocolateyService #489

030 opened this issue Jun 19, 2014 · 22 comments

Comments

@030
Copy link

030 commented Jun 19, 2014

Helper Function which checks whether a certain service exists, a port is available and installs a service.

@030 030 changed the title Install-ChocolateyService [Enhancement] Install-ChocolateyService Jun 19, 2014
@030
Copy link
Author

030 commented Jun 19, 2014

I have created some code and would like to push it to the master

@gep13
Copy link
Member

gep13 commented Jun 19, 2014

Hey,

In order to get code added to the codebase, you would need to submit a pull request.

Have a look here:

https://github.com/chocolatey/chocolatey/blob/master/CONTRIBUTING.md

For the process, and let us know if you have any questions.

Gary

@030
Copy link
Author

030 commented Jun 19, 2014

Thank you. I will send you an email.

@030
Copy link
Author

030 commented Jun 19, 2014

I cannot find the mailing list. Could you indicate where this list could be found?

@gep13
Copy link
Member

gep13 commented Jun 19, 2014

Hey,

No probs. The mailing list is hosted in a Google Group which you can find here:

https://groups.google.com/forum/#!forum/chocolatey

Gary

@030
Copy link
Author

030 commented Jun 19, 2014

Thank you

@030
Copy link
Author

030 commented Jun 19, 2014

I have submitted a post but cannot find it

@gep13
Copy link
Member

gep13 commented Jun 19, 2014

Hey,

Since this is your first post to the forum, it was sitting in the moderation queue. I have just approved it, so you should see it now.

Gary

@030
Copy link
Author

030 commented Jun 19, 2014

Yes it is visible now https://groups.google.com/forum/#!topic/chocolatey/6xq1-TIHigE. Thank you

@030
Copy link
Author

030 commented Jul 4, 2014

May I build and commit this feature this weekend?

@gep13
Copy link
Member

gep13 commented Jul 4, 2014

Hello,

Have you read through this:

https://github.com/chocolatey/chocolatey/blob/master/CONTRIBUTING.md

This is the process that we follow for accepting contributions to Chocolatey. You would need to make the changes, and then submit the changes in the form of a Pull Request.

Gary

@030
Copy link
Author

030 commented Jul 4, 2014

Thank you. I am now creating and running tests using Pester. When I have completed the Test class I will follow the next step. Thank you for the link to the process.

@ferventcoder
Copy link
Contributor

Left some comments at 9a0af45
I think there are some design decisions here that are a little outside of chocolatey that would need to be fixed up.

@ferventcoder
Copy link
Contributor

Also, you can just use (GH-489) at the start of your commits. That is the way most of the commits are done to reference issues.

@030
Copy link
Author

030 commented Jul 8, 2014

All 10 test pass, but there are still some issues:

New-Item : Cannot find drive. A drive with the name 'TestDrive' does not exist.
At C:\Chocolatey\lib\pester.2.1.0\tools\Functions\TestDrive.ps1:109 char:28
+         $item = $Content | New-Item -Name $Path -Path "${TestDriveName}:" -Type  ...
+                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (TestDrive:String) [New-Item], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.NewItemCommand

and

WARNING: The names of some imported commands from the module 'chocolateyInstaller' include unapproved verbs that might
make them less discoverable. To find the commands with unapproved verbs, run the Import-Module command again with the
Verbose parameter. For a list of approved verbs, type Get-Verb.

I will check the latter tomorrow by running the test using the verbose parameter

@030
Copy link
Author

030 commented Jul 8, 2014

Issue:

New-Item : Cannot find drive. A drive with the name 'TestDrive' does not exist.
At C:\Chocolatey\lib\pester.2.1.0\tools\Functions\TestDrive.ps1:109 char:28

$item = $Content | New-Item -Name $Path -Path "${TestDriveName}:" -Type ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CategoryInfo : ObjectNotFound: (TestDrive:String) [New-Item], DriveNotFoundException
    FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.NewItemCommand

persist. How could this be solved?

@gep13
Copy link
Member

gep13 commented Jul 8, 2014

Looks like you are using version 2.0.1 of Pester. As per the setup script here:

https://github.com/chocolatey/chocolatey/blob/master/setup.ps1

And also the discussion here:

https://groups.google.com/forum/#!topic/chocolatey/9oQwi0-z3K0/discussion

Chocolatey needs version 2.0.2 of Pester.

Can you try installing this version, and let us know how you get on?

@030
Copy link
Author

030 commented Jul 8, 2014

cinst pester -Version 2.0.2

and subsequently executing

PS C:\chocolatey-1\tests\unit> C:\Chocolatey\lib\pester.2.0.2\tools\bin\pester.bat .\In
stall-ChocolateyService.Tests.ps1
Executing all tests in C:\chocolatey-1\tests\unit\Install-ChocolateyService.Tests.ps1
Please run chocolatey /? or chocolatey help - chocolatey v0.9.8.24
Describing Install-ChocolateyService
  When provided parameters are correct the service should be created and started
The default install location has been changed to 'C:\ProgramData\chocolatey'.
  This install will be updated to that location in the next version. It
  is strongly suggested you move this installation to the new location
  as soon as possible to limit write access from all users. Do not forget
  to update PATH & ChocolateyInstall environment variables.
Chocolatey (v0.9.8.24) is installing 'NSSM' and dependencies. By installing you accept the license for 'NSSM' and each d
ependency you are installing.
'NSSM 2.21.1.0' already installed.
If you want to reinstall the current version of an existing package, please use the -force command.

Finished installing 'NSSM' and dependencies - if errors not shown in console, none detected. Check log for errors if uns
ure.
C:\installChocolateyServiceTest directory does not exist and will be created


    Directory: C:\


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        07/08/2014     18:35            installChocolateyServiceTest
installServiceTest service will be installed
nssm install installServiceTest "C:\installChocolateyServiceTest\testService.bat"
Service "installServiceTest" installed successfully!
installServiceTest service will be started
installServiceTest service has been started
[+]    service creation should succeed 548ms
[+]    service start should succeed 46ms
  When provided parameters are correct and service exist it should be removed, subsequently created and started
The default install location has been changed to 'C:\ProgramData\chocolatey'.
  This install will be updated to that location in the next version. It
  is strongly suggested you move this installation to the new location
  as soon as possible to limit write access from all users. Do not forget
  to update PATH & ChocolateyInstall environment variables.
Chocolatey (v0.9.8.24) is installing 'NSSM' and dependencies. By installing you accept the license for 'NSSM' and each d
ependency you are installing.
'NSSM 2.21.1.0' already installed.
If you want to reinstall the current version of an existing package, please use the -force command.

Finished installing 'NSSM' and dependencies - if errors not shown in console, none detected. Check log for errors if uns
ure.
installServiceTest service already exists and will be removed

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

installServiceTest service will be installed
nssm install installServiceTest "C:\installChocolateyServiceTest\testService.bat"
Service "installServiceTest" installed successfully!
installServiceTest service will be started
installServiceTest service has been started
[+]    service creation should succeed after deletion of previous service 457ms
[+]    service start should succeed after deletion of previous service 3ms
  When availablePort parameter is passed to this function and it is in LISTENING state and not available
The default install location has been changed to 'C:\ProgramData\chocolatey'.
  This install will be updated to that location in the next version. It
  is strongly suggested you move this installation to the new location
  as soon as possible to limit write access from all users. Do not forget
  to update PATH & ChocolateyInstall environment variables.
Chocolatey (v0.9.8.24) is installing 'NSSM' and dependencies. By installing you accept the license for 'NSSM' and each d
ependency you are installing.
'NSSM 2.21.1.0' already installed.
If you want to reinstall the current version of an existing package, please use the -force command.

Finished installing 'NSSM' and dependencies - if errors not shown in console, none detected. Check log for errors if uns
ure.
installServiceTest service already exists and will be removed

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

installServiceTest service will be installed
nssm install installServiceTest "C:\installChocolateyServiceTest\testService.bat"
Service "installServiceTest" installed successfully!
135 is in LISTENING state and not available.
[+]    should return an error 212ms
  When no packageName parameter is passed to this function
[+]    should return an error 8ms
  When no serviceName parameter is passed to this function
[+]    should return an error 7ms
  When no createServiceCommand parameter is passed to this function
[+]    should return an error 8ms
  When service does not exist
The default install location has been changed to 'C:\ProgramData\chocolatey'.
  This install will be updated to that location in the next version. It
  is strongly suggested you move this installation to the new location
  as soon as possible to limit write access from all users. Do not forget
  to update PATH & ChocolateyInstall environment variables.
Chocolatey (v0.9.8.24) is installing 'NSSM' and dependencies. By installing you accept the license for 'NSSM' and each d
ependency you are installing.
'NSSM 2.21.1.0' already installed.
If you want to reinstall the current version of an existing package, please use the -force command.

Finished installing 'NSSM' and dependencies - if errors not shown in console, none detected. Check log for errors if uns
ure.
unavailableServiceName service will be installed
nssm install installServiceTest "C:\installChocolateyServiceTest\testService.bat"
Error creating service!
[+]    should return an error 7ms
  When createServiceCommand is incorrect
The default install location has been changed to 'C:\ProgramData\chocolatey'.
  This install will be updated to that location in the next version. It
  is strongly suggested you move this installation to the new location
  as soon as possible to limit write access from all users. Do not forget
  to update PATH & ChocolateyInstall environment variables.
Chocolatey (v0.9.8.24) is installing 'NSSM' and dependencies. By installing you accept the license for 'NSSM' and each d
ependency you are installing.
'NSSM 2.21.1.0' already installed.
If you want to reinstall the current version of an existing package, please use the -force command.

Finished installing 'NSSM' and dependencies - if errors not shown in console, none detected. Check log for errors if uns
ure.
installServiceTest service already exists and will be removed

__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 0
PSComputerName   :

installServiceTest service will be installed
unavailableServiceName "C:\installChocolateyServiceTest\testService.bat"
[+]    should return an error 8ms
Remove test directory after finishing testing
Tests completed in 1.31s
Passed: 10 Failed: 0


PS C:\chocolatey-1\tests\unit>

works. Thank you.

@030
Copy link
Author

030 commented Jul 8, 2014

Work on comments @ferventcoder has been done. The code and tests have been created. Looking forward to hear whether the code and tests need to be improved.

@ferventcoder
Copy link
Contributor

@030 If you submit a PR we can work through changes there. It's much easier to do.

@030
Copy link
Author

030 commented Jul 8, 2014

@ferventcoder Thank you. Pull request (GH-506) has been created.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants