浏览代码

run db tests in all packages

bergquist 6 年之前
父节点
当前提交
c68da40710
共有 3 个文件被更改,包括 36 次插入2 次删除
  1. 2 2
      .circleci/config.yml
  2. 17 0
      scripts/circle-test-mysql.sh
  3. 17 0
      scripts/circle-test-postgres.sh

+ 2 - 2
.circleci/config.yml

@@ -35,7 +35,7 @@ jobs:
         - run: cat devenv/docker/blocks/mysql_tests/setup.sql | mysql -h 127.0.0.1 -P 3306 -u root -prootpass
         - run:
             name: mysql integration tests
-            command: 'GRAFANA_TEST_DB=mysql go test ./pkg/services/sqlstore/... ./pkg/tsdb/mysql/... '
+            command: './scripts/circle-test-mysql.sh'
 
   postgres-integration-test:
     docker:
@@ -54,7 +54,7 @@ jobs:
         - run: 'PGPASSWORD=grafanatest psql -p 5432 -h 127.0.0.1 -U grafanatest -d grafanatest -f devenv/docker/blocks/postgres_tests/setup.sql'
         - run:
             name: postgres integration tests
-            command: 'GRAFANA_TEST_DB=postgres go test ./pkg/services/sqlstore/... ./pkg/tsdb/postgres/...'
+            command: './scripts/circle-test-postgres.sh'
 
   codespell:
     docker:

+ 17 - 0
scripts/circle-test-mysql.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+function exit_if_fail {
+    command=$@
+    echo "Executing '$command'"
+    eval $command
+    rc=$?
+    if [ $rc -ne 0 ]; then
+        echo "'$command' returned $rc."
+        exit $rc
+    fi
+}
+
+export GRAFANA_TEST_DB=mysql
+
+time for d in $(go list ./pkg/...); do
+  exit_if_fail go test -tags=integration $d
+done

+ 17 - 0
scripts/circle-test-postgres.sh

@@ -0,0 +1,17 @@
+#!/bin/bash
+function exit_if_fail {
+    command=$@
+    echo "Executing '$command'"
+    eval $command
+    rc=$?
+    if [ $rc -ne 0 ]; then
+        echo "'$command' returned $rc."
+        exit $rc
+    fi
+}
+
+export GRAFANA_TEST_DB=postgres
+
+time for d in $(go list ./pkg/...); do
+  exit_if_fail go test -tags=integration $d
+done