-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlSetup: Create integration tests #186
Comments
Ideally, integration tests should test all basic functionality. I'm not entirely sure how much setup is required to run most of the SqlServer configurations, but I would start with just the very simple cases - minimal arguments, etc. - and get those working and then build from there. I would check out our integration tests in PSDscResources to get started. |
Integration tests are a bit more flexible than unit tests since the way to write them can vary based on the nature of the resource, so we don't have as many hard rules on writing them. The main thing is that it's testing the actual functionality of the resource - making sure it really does what it says it does. |
Hi @johlju - I do love a good integration test! 😁 I've written a few tests that had dependencies on files that you can't put into the repo. See this one in xStorage. It depends on an ISO file, and if it doesn't exist the tests are skipped (this is so they can still run in AppVeyor). I generally try to make integration tests run on AppVeyor, but sometimes it just isn't possible. And if that is the case then I think it is acceptable to have specific requirements to enable running of the tests. I believe that manually run tests are better than no tests. If the tests do require a more complex setup to run then it would be good to have a script available that will set up the test environment. But one thing to consider (and I haven't looked into this at all), but is Test Kitchen something that might help here? What I also try to do is to provide both an "Install" and a "Uninstall" integration test for each resource (in the case of xStorage/xMountImage it is Mount/Dismount)- so that I can test both main processes, but also end up with the system cleaned and reset once the tests are completed. E.g. the process for testing xSQLServerSetup could be something like this:
As for integration tests that depend on other nodes, that can get a bit trickier, but it is possible I reckon. For example, this one in xCert has a dependency on an ADCS CA Server. It will only run if one can be found. I do find integration tests pick up at least as many bugs as unit tests (for me anyway) and actually can be more fun to write 😄 But if there is anything I can do to help, let me know. |
Thanks for all the information! I think I need a crash course in AppVeyor. Are these assumptions correct?
|
@johlju - I doubt there is any (easy) way to create integration tests for xSQLServer that will work in AppVeyor because of the dependency on having access to either:
But I still think you could create integration tests that run in your own environment if configured correctly (e.g. the media ISO's were made available). In answer to your questions:
All that said, it might be worth asking the AppVeyor team if they'd consider including a build worker that contains SQL Server. If they could do this then that might enable integration tests in AppVeyor. |
@PlagueHO I saw yesterday that they did have the express installation of each major SQL Server installed on each build server, but the service was not started by default. But if so, then there are already stuff present on the build servers which might make the test unreliable (already SQL stuff on it) or full SQL Server will possible break when installing (never tried that combo). But I will see how far the Express version can be used for some of the integration tests. I will dig into AppVeyor a bit more. I will also checkout Test Kitchen if it can help in any way. If nothing else I will create a basic integration tests to run on a server and .iso provided by the user. I don't think all contributors will have lab environments to run integration tests, so would have been awesome to actually be able to test on a push. But we have to use what we have and go from there. 😄 |
Update 2017-08-13: Added the failed test with Hyper-V in AppVeyor. We got simple integration tests going with PR #710. Doing integration testing for the advanced installation options using xSQLServerSetup which depends on a cluster and AD will not work with AppVeyor in the way we use it now. I'm currently working on option 5.1 for the resource module xFailOverCluster. OptionsOption 1 - Docker in AppVeyor- did not workSetting up a several Docker images in the AppVeyor build worker. Would work if Failover Clustering would run on the server core docker image. It does not (today). Option 2 - Hyper-V in AppVeyor - did not workSetting up a several virtual servers i Hyper-V in the AppVeyor build worker. Would work if the build worker host supported nested virtualization. It does not today. Option 3 - My personal Azure subscription - not secureSetting up an environment for integration tests in my personal Azure subscription is not secure. There is no secure way to set up a test environment for public use and allow PR's to test against it. Application ID and Password will be available publicly. Option 4 - AppVeyor Build Cloud - works, but costs moneyThis would work and be secure using an AppVeyor Build Cloud against Azure, where the configuration against an Azure subscription would be secure in the AppVeyor portal, and then each PR could be tested as well. But that will be a monthly cost of $500 (for open source projects) for the DSC Resource Kit. Option 5 - Add a new manual testing frameworkOption 5.1 - Manual tests in AzureI'm currently working with the DscConfigurations repository to see if that can be used to able integration testing for xFailOverCluster. xFailOverCluster has similar problems as xSQLServerSetup that it needs several servers for testing (AD etc.). If that works, the same setup can be used here. Option 5.2 - Manual tests in Hyper-VNot started work on this. Running the integration tests in Hyper-V, using for example LabBuilder or Lability. |
This is from PR #1295 by @codykonior
@codykonior This is really super awesome work! We really need to have a manual integration tests that can be run locally. It sounds that you have already done a lot of work for this. I would be really interested in merging something that, at least starts to, cover option 5.2. |
We should start to create integration tests. xSQLServerSetup would be the ideal resource to start with since all other integration tests are dependent on that working (?). We need a SQL instance to test the other resources on.
If nobody else is up to it I would be happy to try to get some basic integration tests done. It would be a fun challenge.
I looked at @PlagueHO's integration tests in xNetworking and also the integration tests in SharePointDsc. And templates are here: https://github.com/PowerShell/DscResources/tree/master/Tests.Template
But... I need a bit more information how this works practically.
@kwirkykat @mbreakey3 @PlagueHO or anyone else with experience with this.
The text was updated successfully, but these errors were encountered: