File tree Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Expand file tree Collapse file tree 3 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,12 @@ jobs:
1818 file : mysqld_exporter
1919 integration :
2020 docker :
21- - image : circleci/golang :1.17
21+ - image : cimg/go :1.17
2222 - image : << parameters.mysql_image >>
2323 environment :
2424 MYSQL_ALLOW_EMPTY_PASSWORD : yes
2525 MYSQL_ROOT_HOST : ' %'
26+ DATA_SOURCE_NAME : ' exporter:integration-test@/'
2627 parameters :
2728 mysql_image :
2829 type : string
3132 - setup_remote_docker
3233 - run : docker version
3334 - run : docker-compose --version
35+ - run : sudo apt-get install -y mysql-client
36+ - run : mysql < scripts/test_grant.sql
3437 - run : make build
3538 - run : make test
3639 codespell :
Original file line number Diff line number Diff line change @@ -26,7 +26,14 @@ import (
2626 "github.com/smartystreets/goconvey/convey"
2727)
2828
29- const dsn = "root@/mysql"
29+ var testDSN = "root@/mysql"
30+
31+ func init () {
32+ testDSNEnv := os .Getenv ("DATA_SOURCE_NAME" )
33+ if testDSNEnv != ""
34+ testDSN = testDSNEnv
35+ }
36+ }
3037
3138func TestExporter (t * testing.T ) {
3239 if testing .Short () {
@@ -35,7 +42,7 @@ func TestExporter(t *testing.T) {
3542
3643 exporter := New (
3744 context .Background (),
38- dsn ,
45+ testDSN ,
3946 NewMetrics (),
4047 []Scraper {
4148 ScrapeGlobalStatus {},
@@ -79,7 +86,7 @@ func TestGetMySQLVersion(t *testing.T) {
7986 logger = level .NewFilter (logger , level .AllowDebug ())
8087
8188 convey .Convey ("Version parsing" , t , func () {
82- db , err := sql .Open ("mysql" , dsn )
89+ db , err := sql .Open ("mysql" , testDSN )
8390 convey .So (err , convey .ShouldBeNil )
8491 defer db .Close ()
8592
Original file line number Diff line number Diff line change 1+ CREATE USER 'exporter '@' localhost' IDENTIFIED BY ' integration-test' WITH MAX_USER_CONNECTIONS 3 ;
2+ GRANT PROCESS, REPLICATION CLIENT TO ' exporter' @' localhost' ;
3+ GRANT SELECT ON performance_schema.* TO ' exporter' @' localhost' ;
4+ GRANT SELECT ON information_schema.* TO ' exporter' @' localhost' ;
5+
You can’t perform that action at this time.
0 commit comments