8

I took a look into Server Spec and it says it clearly:

Remark: serverspec test suites are meant to be run against a single machine (or docker container). In other words, you should not try to issue a single rspec command that would harvest and run tests against multiple machines or containers. You need to issue one rspec command for each of them.

So I can do test per-server, which is good for some cases. But the problem is the following: my microservice architecture has a auto-discovery service, so some services are known after querying it. Is there any project to express this? I know I can tool around with ruby (or python if I choose testinfra or other)

Something integrates with Consul with serverspec or similar will be great, in 2014 people were looking for this, does anyone know of any project that tackled this issue?

5
  • 1
    I think you are misunderstanding run on a single instance (whatever the external needs are) with testing multiple instances within the same run.
    – Tensibai
    Mar 30, 2017 at 21:12
  • 2
    How are your microservices hosted? Docker Containers? Mar 31, 2017 at 10:03
  • My microservices are running in VMs and some of them in Physical Machines (we do genetics, so there is some on-prem clusters next to sequencers)
    – nicocesar
    Mar 31, 2017 at 11:38
  • I have found this article helpful if anyone has time to make use of it. toptal.com/nodejs/nodejs-guide-integration-tests
    – avi
    Apr 2, 2017 at 17:18
  • 2
    Please clarify on type of testing you're looking for, there are different approaches to address system/integration testing of server configuration using for example ServerSpec or KitchenCI, or testing that microservice is up and running using simple HTTP request that each microservice should implement, and different in nature end-to-end application testing can be whitebox/blackbox using for example BDD automation test frameworks or Selenium.
    – rombob
    Jun 21, 2017 at 13:28

3 Answers 3

1

If nothing exists to easily mock Consul, have you considered spinning up a Consul service along with your other microservices? Consul can run in Docker, so this should be fairly straightforward if you use docker-compose and your apps can be configured to point to a different Consul endpoint.

Once your docker-compose is configured to spin up all the infrastructure/microservices required for your test, you will be able to use whatever tools you're familiar with to test your microservices, e.g. Selenium.

1
  • The OP is talking about VMs, not docker. Jan 9, 2021 at 7:47
1

I like SaltStack because the configuration management provides node testing if you want in the states, per node, and the results are coalesced in the job status and fully accounted for in the returners.

SaltStack states also allow you to generate events on successes or failures, and it allows nodes to advertise (mines) arbitrary endpoint data (ie. which ip:port is it listening on), available to other nodes' configuration states.

The combination of the two gets you what you probably want from Consul.

1
  • How does it compare to consul in term of service availability ? If one node of a dependent service has fall in OOM 3 hours after your salt job returned, how would you remove this node from the service cluster and avoid your deploying job to call it ? I think the last line is absolutely out of scope.
    – Tensibai
    Oct 26, 2017 at 9:07
-1

locally you can test against kind (kubernetes in docker) cluster or k3d which is tiny k3s cluster in docker.

Just spin up the cluster, install bundle of microservices there and run the tests.

Have a look on https://github.com/AbsaOSS/k3d-action which demonstrates spinning such cluster.

3
  • The OP is talking about VMs, not even docker, let alone K8S. Jan 9, 2021 at 7:46
  • please explain what ha change if you use VM's instead of dockers. I think the docker with kubernetes is the most common way how to test mictroservices. Also, please can you point to place where he is talking about VM? Thanks for minus!
    – Michal K
    Jan 13, 2021 at 10:34
  • It's the 3rd comment under the question. Although I'm a K8S trainer I'd have to contest your assertion that the most common way to do microservices is k8s. K8S is great, and growing in popularity, but most organisations are still only in the early days of adoption, and, 3-years ago when this question was asked K8S was a terrifying dream in the eyes of most companies. If you use VMs instead of docker/k8s there is no need to learn an entirely new suite of tools. Also, while k3d is great, if you don't already have a k8s configuration it is far from simple to just 'install bundle of ms'. Jan 13, 2021 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.