@@ -19,12 +19,11 @@ import (
1919 "log"
2020 "os"
2121 "testing"
22- "time"
2322)
2423
2524const (
2625 user = "presto"
27- port = "8080 "
26+ port = "8888 "
2827)
2928
3029var (
@@ -38,26 +37,18 @@ func TestMain(m *testing.M) {
3837 Repository : "ahanaio/prestodb-sandbox" ,
3938 Tag : "0.270" ,
4039 ExposedPorts : []string {"8080" },
41- PortBindings : map [docker.Port ][]docker.PortBinding {
42- "8080" : {
43- {HostIP : "0.0.0.0" , HostPort : "8080" },
44- },
45- },
40+ PortBindings : map [docker.Port ][]docker.PortBinding {"8080" : {{HostIP : "0.0.0.0" , HostPort : port }}},
4641 }
4742
48- // Exponential backoff-retry for container to accept connections
4943 // dsn format - http[s]://user[:pass]@host[:port][?parameters]
5044 retryFn := func (r * dockertest.Resource ) (err error ) {
51- dsn := "http://presto@localhost:8080"
45+ dsn := fmt . Sprintf ( "http://presto@localhost:%s" , port )
5246 db , err = sql .Open ("presto" , dsn )
5347 if err != nil {
5448 return err
5549 }
56-
57- // wait until presto ready, might want to call SELECT 1 and retry if failed and give timeout
58- time .Sleep (1 * time .Minute )
59-
60- return db .Ping ()
50+ _ , err = db .Query ("SELECT 1" )
51+ return
6152 }
6253 purgeFn , err := utils .CreateContainer (opts , retryFn )
6354 if err != nil {
@@ -95,7 +86,7 @@ func TestExtract(t *testing.T) {
9586
9687 if err := newExtractor .Init (ctx , map [string ]interface {}{
9788 "connection_url" : fmt .Sprintf ("http://%s@%s" , user , host ),
98- "exclude_catalog" : "memory,system ,tpcds,tpch" , // only jmx catalog is not excluded
89+ "exclude_catalog" : "memory,jmx ,tpcds,tpch" , // only system catalog is not excluded
9990 }); err != nil {
10091 t .Fatal (err )
10192 }
@@ -110,6 +101,6 @@ func TestExtract(t *testing.T) {
110101 urns = append (urns , table .Resource .Urn )
111102
112103 }
113- assert .Equal (t , 242 , len (urns ))
104+ assert .Equal (t , 30 , len (urns ))
114105 })
115106}
0 commit comments