Skip to content

Commit

Permalink
Use docker compose to run the integration instance (#320)
Browse files Browse the repository at this point in the history
* Use docker compose to run the integration instance
This removes the need for a docker build and it will allow me to run a second instance for #318
The second one will have a sub-path configured

Other docker compose advantages:
 - Allows to turn down the stack after tests
 - Will recreate the stack from scratch each time

* Revert to same version as before

* Move docker-compose to common path
  • Loading branch information
julienduchesne committed Feb 1, 2024
1 parent 8c55110 commit 530ca55
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 21 deletions.
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
.PHONY: dev lint test integration static install uninstall cross build-test-image run-test-image-locally test-clean
.PHONY: dev lint test integration static install uninstall cross run-test-image-locally stop-test-image-locally test-clean
VERSION := $(shell git describe --tags --dirty --always)
BIN_DIR := $(GOPATH)/bin
GOX := $(BIN_DIR)/gox
DOCKER_COMPOSE := docker compose -f ./test-docker-compose/docker-compose.yml

lint:
test -z $$(gofmt -s -l cmd/ pkg/)
go vet ./...

build-test-image:
docker build pkg/grafana/testdata -t grizzly-grafana-test:latest
run-test-image-locally: test-clean
$(DOCKER_COMPOSE) up --force-recreate --detach --remove-orphans --wait

run-test-image-locally: build-test-image test-clean
docker rm -f grizzly-grafana
docker run -d --name grizzly-grafana -p 3001:3001 --rm grizzly-grafana-test:latest
stop-test-image-locally:
$(DOCKER_COMPOSE) down

test-clean:
go clean -testcache

test: run-test-image-locally
go test -v ./cmd/... ./pkg/... || ( status=$$?; docker logs grizzly-grafana ; exit $$status )
make stop-test-image-locally

integration: run-test-image-locally dev
go test -v ./integration/...
make stop-test-image-locally

# Compilation
dev:
Expand Down
6 changes: 0 additions & 6 deletions pkg/grafana/testdata/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions pkg/grafana/testdata/custom.ini

This file was deleted.

18 changes: 18 additions & 0 deletions test-docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3'
services:
grafana:
image: grafana/grafana:10.2.0
ports:
- "3001:3001"
environment:
- GF_SERVER_HTTP_PORT=3001
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
- GF_PATHS=/etc/grafana/provisioning
volumes:
- ./provisioning:/etc/grafana/provisioning
healthcheck:
test: wget --no-verbose --tries=1 --spider http://0.0.0.0:3001/api/health || exit 1 # Use wget because older versions of Grafana don't have curl
interval: 1s
retries: 30
start_period: 10s

0 comments on commit 530ca55

Please sign in to comment.