Skip to content

Commit d4f2323

Browse files
committed
fix(presto): fix MaxWait and Ping query
1 parent d6a65c8 commit d4f2323

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

plugins/extractors/presto/presto_test.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ import (
1919
"log"
2020
"os"
2121
"testing"
22-
"time"
2322
)
2423

2524
const (
2625
user = "presto"
27-
port = "8080"
26+
port = "8888"
2827
)
2928

3029
var (
@@ -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
}

test/utils/dockertest.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package utils
22

33
import (
44
"fmt"
5+
"time"
56

67
"github.com/ory/dockertest/v3"
78
)
@@ -13,6 +14,8 @@ import (
1314
//"retryOp" is an exponential backoff-retry, because the application in the container might not be ready to accept connections yet
1415
func CreateContainer(opts dockertest.RunOptions, retryOp func(r *dockertest.Resource) error) (purgeFn func() error, err error) {
1516
pool, err := dockertest.NewPool("")
17+
// exponential backoff-retry, because the application in the container might not be ready to accept connections yet
18+
pool.MaxWait = 120 * time.Second
1619
if err != nil {
1720
return purgeFn, fmt.Errorf("could not create dockertest pool: %s", err)
1821
}

0 commit comments

Comments
 (0)