Skip to content

Commit

Permalink
e2e tests for http-backend-datasource (#318)
Browse files Browse the repository at this point in the history
* e2e tests for http-backend-datasource, mockserver, add mockserver to github workflow

* Run and stop mockserver for every version of grafana

* Run and stop mockserver for every version of grafana

* change ci workflow back

* update to grafana 10.4.0 to be able to use e2e selectors

* add host configurations for grafana with latest and canary versions

* delete hello message

* fix build

* fix the build
  • Loading branch information
Ukochka authored Jun 13, 2024
1 parent bac92e8 commit d1ebb58
Show file tree
Hide file tree
Showing 15 changed files with 8,437 additions and 10,559 deletions.
27 changes: 24 additions & 3 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,22 @@ jobs:
npm exec --package semver-compare-cli --call 'semver-compare $LATEST_STABLE_VERSION ge $EXPECTED_GRAFANA_VERSION'
working-directory: ${{ matrix.pluginDir }}

- name: Check if mockserver is defined
id: mockserver-check
run: |
echo $(docker compose config --services)
if docker compose config --services | grep -wq mockserver; then
echo "MOCKSERVER_DEFINED=true" >> $GITHUB_OUTPUT
else
echo "MOCKSERVER_DEFINED=false" >> $GITHUB_OUTPUT
fi
working-directory: ${{ matrix.pluginDir }}

- name: Run mock server
if: steps.mockserver-check.outputs.MOCKSERVER_DEFINED == 'true'
run: docker compose up -d mockserver
working-directory: ${{ matrix.pluginDir }}

- name: Setup playwright browser
if: steps.has-integration-tests.outputs.DIR == 'true'
run: npx playwright install --with-deps chromium
Expand All @@ -147,7 +163,7 @@ jobs:
- name: Expected version - Start Grafana
if: steps.has-integration-tests.outputs.DIR == 'true' && steps.should-run-expected-latest-tests.outcome == 'success'
run: |
docker run -d -p 3000:3000 --name $PLUGIN_ID -v ${PWD}/dist:/var/lib/grafana/plugins/$PLUGIN_ID -v ${PWD}/provisioning:/etc/grafana/provisioning -e GF_DEFAULT_APP_MODE -e GF_INSTALL_PLUGINS -e GF_AUTH_ANONYMOUS_ORG_ROLE -e GF_AUTH_ANONYMOUS_ENABLED -e GF_AUTH_BASIC_ENABLED grafana/grafana:$EXPECTED_GRAFANA_VERSION
docker run -d -p 3000:3000 --add-host=host.docker.internal:host-gateway --name $PLUGIN_ID -v ${PWD}/dist:/var/lib/grafana/plugins/$PLUGIN_ID -v ${PWD}/provisioning:/etc/grafana/provisioning -e GF_DEFAULT_APP_MODE -e GF_INSTALL_PLUGINS -e GF_AUTH_ANONYMOUS_ORG_ROLE -e GF_AUTH_ANONYMOUS_ENABLED -e GF_AUTH_BASIC_ENABLED grafana/grafana:$EXPECTED_GRAFANA_VERSION
working-directory: ${{ matrix.pluginDir }}

- name: Expected - Wait for Grafana to start
Expand Down Expand Up @@ -188,7 +204,7 @@ jobs:
- name: Latest - Start Grafana
if: steps.has-integration-tests.outputs.DIR == 'true' && steps.should-run-expected-latest-tests.outcome == 'success'
run: |
docker run -d -p 3000:3000 --name $PLUGIN_ID -v ${PWD}/dist:/var/lib/grafana/plugins/$PLUGIN_ID -v ${PWD}/provisioning:/etc/grafana/provisioning -e GF_DEFAULT_APP_MODE -e GF_INSTALL_PLUGINS -e GF_AUTH_ANONYMOUS_ORG_ROLE -e GF_AUTH_ANONYMOUS_ENABLED -e GF_AUTH_BASIC_ENABLED grafana/grafana:latest
docker run -d -p 3000:3000 --add-host=host.docker.internal:host-gateway --name $PLUGIN_ID -v ${PWD}/dist:/var/lib/grafana/plugins/$PLUGIN_ID -v ${PWD}/provisioning:/etc/grafana/provisioning -e GF_DEFAULT_APP_MODE -e GF_INSTALL_PLUGINS -e GF_AUTH_ANONYMOUS_ORG_ROLE -e GF_AUTH_ANONYMOUS_ENABLED -e GF_AUTH_BASIC_ENABLED grafana/grafana:latest
working-directory: ${{ matrix.pluginDir }}

- name: Latest - Wait for Grafana to start
Expand Down Expand Up @@ -254,7 +270,7 @@ jobs:
- name: Canary - Start Grafana dev image
if: steps.has-integration-tests.outputs.DIR == 'true'
run: |
docker run -d -p 3000:3000 --name $PLUGIN_ID -v ${PWD}/dist:/var/lib/grafana/plugins/$PLUGIN_ID -v ${PWD}/provisioning:/etc/grafana/provisioning -e GF_DEFAULT_APP_MODE -e GF_INSTALL_PLUGINS -e GF_AUTH_ANONYMOUS_ORG_ROLE -e GF_AUTH_ANONYMOUS_ENABLED -e GF_AUTH_BASIC_ENABLED grafana/grafana-dev:$CANARY_DOCKER_TAG
docker run -d -p 3000:3000 --add-host=host.docker.internal:host-gateway --name $PLUGIN_ID -v ${PWD}/dist:/var/lib/grafana/plugins/$PLUGIN_ID -v ${PWD}/provisioning:/etc/grafana/provisioning -e GF_DEFAULT_APP_MODE -e GF_INSTALL_PLUGINS -e GF_AUTH_ANONYMOUS_ORG_ROLE -e GF_AUTH_ANONYMOUS_ENABLED -e GF_AUTH_BASIC_ENABLED grafana/grafana-dev:$CANARY_DOCKER_TAG
working-directory: ${{ matrix.pluginDir }}

- name: Canary - Wait for Grafana to start
Expand Down Expand Up @@ -289,6 +305,11 @@ jobs:
docker stop $PLUGIN_ID && docker rm $PLUGIN_ID
working-directory: ${{ matrix.pluginDir }}

- name: Stop mockserver if running
if: steps.mockserver-check.outputs.MOCKSERVER_DEFINED == 'true'
run: docker compose down mockserver
working-directory: ${{ matrix.pluginDir }}

notify:
if: ${{ (always() && github.event_name == 'schedule') }}
runs-on: ubuntu-latest
Expand Down
10 changes: 9 additions & 1 deletion examples/datasource-http-backend/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ services:
context: ./.config
args:
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
grafana_version: ${GRAFANA_VERSION:-10.3.3}
grafana_version: ${GRAFANA_VERSION:-10.4.0}
ports:
- 3000:3000/tcp
volumes:
- ./dist:/var/lib/grafana/plugins/grafana-datasourcehttpbackend-datasource
- ./provisioning:/etc/grafana/provisioning
extra_hosts:
- 'host.docker.internal:host-gateway'
mockserver:
container_name: 'mockserver-datasourcehttpbackend-datasource'
build:
context: ./server
ports:
- 10000:10000/tcp
Loading

0 comments on commit d1ebb58

Please sign in to comment.