Skip to content

Commit 10eba5b

Browse files
committed
Opening up TestIAMRoleCanIssueSelectFromS3 for dynamic CLICKHOUSE connection parameters and skipping if FLOW_TESTS_AWS_S3_BUCKET_NAME is not passed. It will only be run locally if that env-var is passed
1 parent 91ea49c commit 10eba5b

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

flow/connectors/clickhouse/s3_iam_role_test.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package connclickhouse
33
import (
44
"fmt"
55
"os"
6+
"strconv"
67
"testing"
78
"time"
89

@@ -13,6 +14,11 @@ import (
1314
)
1415

1516
func TestIAMRoleCanIssueSelectFromS3(t *testing.T) {
17+
const bucketNameEnvVar = "FLOW_TESTS_AWS_S3_BUCKET_NAME"
18+
if os.Getenv(bucketNameEnvVar) == "" {
19+
t.Skipf("skipping test since %s is not set", bucketNameEnvVar)
20+
}
21+
1622
for _, envVar := range []string{
1723
"AWS_ACCESS_KEY_ID",
1824
"AWS_SECRET_ACCESS_KEY",
@@ -34,13 +40,24 @@ func TestIAMRoleCanIssueSelectFromS3(t *testing.T) {
3440
} {
3541
t.Setenv(envVar, os.Getenv("FLOW_TESTS_"+envVar))
3642
}
37-
t.Setenv("PEERDB_CLICKHOUSE_AWS_S3_BUCKET_NAME", os.Getenv("FLOW_TESTS_AWS_S3_BUCKET_NAME"))
43+
t.Setenv("PEERDB_CLICKHOUSE_AWS_S3_BUCKET_NAME", os.Getenv(bucketNameEnvVar))
3844
ctx := t.Context()
3945

46+
chHost := "localhost"
47+
if host := os.Getenv("CI_CLICKHOUSE_HOST"); host != "" {
48+
chHost = host
49+
}
50+
var chPort uint32 = 9000
51+
if port := os.Getenv("CI_CLICKHOUSE_NATIVE_PORT"); port != "" {
52+
if p, err := strconv.ParseUint(port, 10, 32); err == nil {
53+
chPort = uint32(p)
54+
}
55+
}
56+
4057
conn, err := NewClickHouseConnector(ctx, nil,
4158
&protos.ClickhouseConfig{
42-
Host: "localhost",
43-
Port: 9000,
59+
Host: chHost,
60+
Port: chPort,
4461
Database: "default",
4562
DisableTls: true,
4663
})

0 commit comments

Comments
 (0)