2

I just want to see if it's possible to run kitchen tests against a server that's always on.

I know that testing cookbooks against VMs that you can create and destroy at will would be ideal, but I would expect there to be some stripped down way of converging and running tests against a box using just WinRM or SSH.

arjabbar
  • 6,044
  • 4
  • 30
  • 46

3 Answers3

3

I'll assume you want to run tests using Serverspec or InSpec. It depends on verifier, driver and provisioner sections of .kitchen.yml are optional. If you skip them test-kitchen will use dummy driver. So without driver kitchen list will look like:

$ kitchen list
Instance                          Driver  Provisioner  Verifier    Transport  Last Action
...
ci-server-ubuntu-1604             Dummy   ChefSolo     Serverspec  Ssh        <Not Created>

And if verifier supports ssh or winrm you can run kitchen verify. Serverspec verifier can do it, Inspec verifier can do it as well.

However, I'm not sure if need the whole test-kitchen if you want to just run tests on the machine. Both InSpec and Serverspec can be run standalone.

Szymon
  • 1,525
  • 1
  • 11
  • 12
3

You probably want the proxy driver:

driver:
  name: proxy
  host: testserver.example.com

Keep in mind you'll get no isolation between tests, which is a very bad thing.

coderanger
  • 52,400
  • 4
  • 52
  • 75
2

You mention, "without using any drivers?" According to the Kitchen documentation:

This file uses Vagrant as the driver, which requires no additional configuration because it’s the default driver used by Kitchen

There doesn't seem to be a way to avoid using a driver. However, as long as you don't run any create or destroy commands, you likely could constantly reconverge and test.

I think it's important to keep two things in mind, if you proceed:

  1. You're using the tools against the way they're intended, so future changes are more likely to break your workflow than the typical user's workflow.

  2. You're not truly testing how Chef would behave on a fresh build; you're only testing if you can get from an unknown current state to a desired state. You may very well be unable to build a server from scratch if you don't test it every so often.

If you only want to converge and run tests, considering running the existing testing tools in a standalone way.

Martin
  • 2,815
  • 1
  • 21
  • 30
  • This is a great answer as well as Szymon's. I can only mark one as the answer though. But thank you very much. This was helpful. – arjabbar Nov 18 '16 at 12:50