Multiple Service Version Test

I have this pipeline that works beautifully. (Actually I’m really enjoying using Drone CI so props on this. After using Jenkins, Travis and Gitlab Drone CI feels so clean and simple to use )


What I’d like to do is try to run my integration tests against multiple versions of the pipeline. I have this which works against a specific version.

kind: pipeline
name: default

steps:
  - name: build
    image: golang:1.16
    commands:
      - echo "Waiting for Grafana to come up"
      - sleep 45
      - curl http://grafana:3000
      - make linux
      - cp conf/importer-example.yml conf/importer.yml
      - make test
      - ./bin/gdg_linux version
services:
  - name: grafana
    image: grafana/grafana:7.5.6-ubuntu

trigger:
  event:
    - push
    - pull_request

Ideally I’d like it to bring up and tear down the services as it runs the test, though I suppose I could just define multiple services named grafana- and have the test runner enumerate through the expected versions. Is there a cleaner way of doing this?

Also having the tests execute against multiple versions of the language would be nice if possible?
Aka go 1.16 and go 1.12 or whatnot.

Multiple services are of course possible, if they have different names. Drone has no internal mechanism, to check for a containered service being “available”, because this is highly service specific. Though docker swarm and kubernetes implement a feature named healthcheck, allowing containers to publish these kind of information, most image providers I am aware of make no use of it.

BTW: Sleeping is probably not the best idea to wait for service being available. I would rather test it regularly by polling, e.g. for http based services:

$ timeout=$(($(date +%s) + 120))
$ until [ "$(date +%s)" -gt "$timeout" ] || curl -s --fail http://myservice/some/url; do sleep 5; done

Thanks for the snippet to avoid a sleep. I think what i was looking for was more how to setup a pattern where I could do a version list.

I think the best I can come up with right now would be to have something like:


services:
  - name: grafana-7.5.6
    image: grafana/grafana:7.5.6-ubuntu
  - name: grafana-7.5.7
    image: grafana/grafana:7.5.7-ubuntu
  - name: grafana-7.5.8
    image: grafana/grafana:7.5.8-ubuntu

then for the test to just do something like:

steps:
  - name: build
    image: golang:1.16
    commands:
... wait for grafanas to come up
      - make linux
      - cp conf/importer-example.yml conf/importer.yml
      - for i in 7.5.6 7.5.7 7.5.8; do sed -i -e "s/url:.*/url: http://grafana-$i:3000/" conf/importer.yml; make test; done;
      - ./bin/gdg_linux version

Which I understand works I was just hoping for a more built in way of doing this. I suppose I should/can explore writing a plugin to make this easier to work with.

this is a good use case for jsonnet or starlark

this thread is unrelated, but I feel like it may address a similar use case:

@bradrydzewski Yup, that’s actually exactly what I was looking for. Thanks!

Just need to figure out the right format to generate that’ll make this all work. starlark looks really interesting particularly since I’m spending a lot more time in go of late.