Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4545cd9
fix: rename tag to plugins
GrayFlash Mar 22, 2022
118d3f8
fix: add curr branch on workflow to test ci
GrayFlash Mar 22, 2022
219e02e
fix(clickhouse): try different network config
GrayFlash Mar 27, 2022
1508918
ifx: revert fixed tags, to hit ci, one by one
GrayFlash Mar 29, 2022
5e90aee
chore: add a new temporary workflow for tests
GrayFlash Mar 29, 2022
66e2a45
fix: rename workflow
GrayFlash Mar 29, 2022
0c40cee
fix(bigtable-test): update tags for docker repo
GrayFlash Mar 29, 2022
ef6331b
fix: increase retry time duration
GrayFlash Mar 29, 2022
97db599
chore: remove plugins test from the curr branch
GrayFlash Mar 29, 2022
2f73891
fix(kafka): change port, remove closing connection
GrayFlash Mar 30, 2022
c95653f
fix(kafka): missing build tags
GrayFlash Mar 30, 2022
f056664
fix: tests for clickhouse, kafka and bigtable
GrayFlash Mar 30, 2022
8a5a435
fix: incorrect port allocation
GrayFlash Mar 30, 2022
241ce47
chore: clean back unnecessary changes
GrayFlash Mar 30, 2022
725105b
fix: wrong bramch name
GrayFlash Mar 30, 2022
5895eb6
fix(bigtable): remove unused imports
GrayFlash Mar 30, 2022
25471f4
fix(bigtable): remove string as error
GrayFlash Mar 30, 2022
2499a82
chore: increase dockertest max wait to 5 mins
mabdh Mar 31, 2022
bc95c77
fix(couchdb): add single node config in test
mabdh Mar 31, 2022
062640c
fix(kafka): add healthcheck in test
mabdh Mar 31, 2022
af6d2be
fix(test): kafka and couchbase healthcheck
mabdh Mar 31, 2022
d642434
fix(couchdb): unreliable test
mabdh Mar 31, 2022
b240f2e
fix(couchdb): unreliable test
mabdh Mar 31, 2022
6bc2ce2
fix(superset): broken test
mabdh Mar 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/plugin_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- fix-plugin-tests
workflow_dispatch:

jobs:
Expand Down
45 changes: 3 additions & 42 deletions plugins/extractors/bigtable/bigtable_test.go
Original file line number Diff line number Diff line change
@@ -1,58 +1,19 @@
//go:build integration
// +build integration
//go:build plugins
// +build plugins

package bigtable_test

import (
"context"
"log"
"os"
"testing"

"github.com/odpf/meteor/test/utils"

"cloud.google.com/go/bigtable"
"github.com/odpf/meteor/plugins"
bt "github.com/odpf/meteor/plugins/extractors/bigtable"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"github.com/stretchr/testify/assert"
)

func TestMain(m *testing.M) {
// setup test
opts := dockertest.RunOptions{
Repository: "shopify/bigtable-emulator",
Env: []string{
"BIGTABLE_EMULATOR_HOST=localhost:9035",
},
ExposedPorts: []string{"9035"},
PortBindings: map[docker.Port][]docker.PortBinding{
"9035": {
{HostIP: "0.0.0.0", HostPort: "9035"},
},
},
Cmd: []string{"-cf", "dev.records.data,dev.records.metadata"},
}
// exponential backoff-retry, because the application in the container might not be ready to accept connections yet
retryFn := func(resource *dockertest.Resource) (err error) {
_, err = bigtable.NewAdminClient(context.Background(), "dev", "dev")
return
}
purgeFn, err := utils.CreateContainer(opts, retryFn)
if err != nil {
log.Fatal("", err)
}

// run tests
code := m.Run()

if err := purgeFn(); err != nil {
log.Fatal("", err)
}
os.Exit(code)
}

func TestInit(t *testing.T) {
t.Run("should return error if no project_id in config", func(t *testing.T) {
err := bt.New(utils.Logger).Init(context.TODO(), map[string]interface{}{
Expand All @@ -67,6 +28,6 @@ func TestInit(t *testing.T) {
"project_id": "",
})

assert.EqualError(t, err, "invalid extractor config")
assert.Equal(t, plugins.InvalidConfigError{}, err)
})
}
6 changes: 3 additions & 3 deletions plugins/extractors/clickhouse/clickhouse_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build integration
// +build integration
//go:build plugins
// +build plugins

package clickhouse_test

Expand Down Expand Up @@ -51,7 +51,7 @@ func TestMain(m *testing.M) {
Tag: "21.7.4-alpine",
ExposedPorts: []string{"9000", port},
Mounts: []string{
fmt.Sprintf("%s/localConfig/users.xml:/etc/clickhouse-server/users.xml:rw", pwd),
fmt.Sprintf("%s/localConfig/users.xml:/etc/clickhouse-server/users.d/user.xml:rw", pwd),
},
PortBindings: map[docker.Port][]docker.PortBinding{
"9000": {
Expand Down
28 changes: 20 additions & 8 deletions plugins/extractors/couchdb/couchdb_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//go:build integration
// +build integration
//go:build plugins
// +build plugins

package couchdb_test

import (
"context"
"fmt"
"log"
"net/http"
"os"
"strconv"
"testing"
Expand Down Expand Up @@ -38,6 +39,10 @@ var (
)

func TestMain(m *testing.M) {
pwd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
// setup test
opts := dockertest.RunOptions{
Repository: "docker.io/bitnami/couchdb",
Expand All @@ -46,7 +51,10 @@ func TestMain(m *testing.M) {
"COUCHDB_USER=" + user,
"COUCHDB_PASSWORD=" + pass,
},
ExposedPorts: []string{"4369", "5984", port},
Mounts: []string{
fmt.Sprintf("%s/localConfig:/opt/bitnami/couchdb/etc/local.d:rw", pwd),
},
ExposedPorts: []string{port},
PortBindings: map[docker.Port][]docker.PortBinding{
"5984": {
{HostIP: "0.0.0.0", HostPort: "5984"},
Expand All @@ -57,18 +65,15 @@ func TestMain(m *testing.M) {
retryFn := func(resource *dockertest.Resource) (err error) {
client, err = kivik.New("couch", fmt.Sprintf("http://%s:%s@%s/", user, pass, host))
if err != nil {
return err
return
}
_, err = client.Ping(context.TODO())
err = setup()
return
}
purgeFn, err := utils.CreateContainer(opts, retryFn)
if err != nil {
log.Fatal(err)
}
if err := setup(); err != nil {
log.Fatal(err)
}

// run tests
code := m.Run()
Expand Down Expand Up @@ -115,6 +120,10 @@ func setup() (err error) {
for _, database := range dbs {
// create database
err = client.CreateDB(context.TODO(), database)
// DB already created
if kivik.StatusCode(err) == http.StatusPreconditionFailed {
err = nil
}
if err != nil {
return
}
Expand All @@ -131,6 +140,9 @@ func setup() (err error) {
func execute(queries []map[string]interface{}, db *kivik.DB) (err error) {
for _, query := range queries {
_, err := db.Put(context.TODO(), query["_id"].(string), query)
if kivik.StatusCode(err) == http.StatusConflict {
err = nil
}
if err != nil {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions plugins/extractors/couchdb/localConfig/local.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[couchdb] single_node=true

[admins]
meteor_test_user = -pbkdf2-5ab0d9d0d782edcd1353a0b058a4ea48618e363a,11726daaa26701e6ae8eccb6748f6abb,10

[chttpd_auth]
secret = ba1f0b5979e7e969f603da7710f8d7bf
4 changes: 2 additions & 2 deletions plugins/extractors/elastic/elastic_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build integration
// +build integration
//go:build plugins
// +build plugins

package elastic_test

Expand Down
16 changes: 14 additions & 2 deletions plugins/extractors/kafka/kafka_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//go:build integration
// +build integration
//go:build plugins
// +build plugins

package kafka_test

import (
"context"
"errors"
"log"
"net"

Expand Down Expand Up @@ -54,6 +55,17 @@ func TestMain(m *testing.M) {
if err != nil {
return
}

// healthcheck
brokerList, err := conn.Brokers()
if err != nil {
return
}
if len(brokerList) == 0 {
err = errors.New("not ready")
return
}

broker, err = conn.Controller()
if err != nil {
conn.Close()
Expand Down
3 changes: 3 additions & 0 deletions plugins/extractors/redshift/redshift_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build plugins
// +build plugins

package redshift_test

import (
Expand Down
1 change: 1 addition & 0 deletions plugins/extractors/superset/localConfig/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
2 changes: 2 additions & 0 deletions plugins/extractors/superset/localConfig/superset_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = False
Loading