File tree 3 files changed +18
-3
lines changed
3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 23
23
environment :
24
24
MYSQL_ALLOW_EMPTY_PASSWORD : yes
25
25
MYSQL_ROOT_HOST : ' %'
26
+ DATA_SOURCE_NAME : ' exporter:integration-test@/'
26
27
parameters :
27
28
mysql_image :
28
29
type : string
31
32
- setup_remote_docker
32
33
- run : docker version
33
34
- run : docker-compose --version
35
+ - run : apt-get install -y mysql-client
36
+ - run : mysql < scripts/test_grant.sql
34
37
- run : make build
35
38
- run : make test
36
39
codespell :
Original file line number Diff line number Diff line change @@ -26,7 +26,14 @@ import (
26
26
"github.com/smartystreets/goconvey/convey"
27
27
)
28
28
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
+ }
30
37
31
38
func TestExporter (t * testing.T ) {
32
39
if testing .Short () {
@@ -35,7 +42,7 @@ func TestExporter(t *testing.T) {
35
42
36
43
exporter := New (
37
44
context .Background (),
38
- dsn ,
45
+ testDSN ,
39
46
NewMetrics (),
40
47
[]Scraper {
41
48
ScrapeGlobalStatus {},
@@ -79,7 +86,7 @@ func TestGetMySQLVersion(t *testing.T) {
79
86
logger = level .NewFilter (logger , level .AllowDebug ())
80
87
81
88
convey .Convey ("Version parsing" , t , func () {
82
- db , err := sql .Open ("mysql" , dsn )
89
+ db , err := sql .Open ("mysql" , testDSN )
83
90
convey .So (err , convey .ShouldBeNil )
84
91
defer db .Close ()
85
92
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