Skip to content

Commit

Permalink
chore(ci): Add linux integration tests + win/mac unit tests (GoogleCl…
Browse files Browse the repository at this point in the history
…oudPlatform#8)

* chore(ci): Add integration tests + win/mac unit tests
  • Loading branch information
shubha-rajan authored Apr 20, 2022
1 parent c872c9e commit 242025c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 29 deletions.
55 changes: 42 additions & 13 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,46 @@ on:
- main

jobs:
integration:
runs-on: [self-hosted, linux, x64]
name: "integration tests (linux)"
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.18"
- name: Checkout code
uses: actions/checkout@v3
- name: Get Secrets
id: 'secrets'
uses: 'google-github-actions/get-secretmanager-secrets@v0'
with:
secrets: |-
ALLOYDB_CONN_NAME:alloydb-connector-testing/ALLOYDB_CONN_NAME
ALLOYDB_CLUSTER_PASS:alloydb-connector-testing/ALLOYDB_CLUSTER_PASS
- name: Run tests
env:
ALLOYDB_DB: 'postgres'
ALLOYDB_USER: 'postgres'
ALLOYDB_PASS: '${{ steps.secrets.outputs.ALLOYDB_CLUSTER_PASS }}'
ALLOYDB_CONNECTION_NAME: '${{ steps.secrets.outputs.ALLOYDB_CONN_NAME }}'
run: |
go test -v -race -cover ./...
build:
name: "unit tests"
runs-on: ubuntu-latest
environment: "Private Repos"
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.18"
- name: Checkout code
uses: actions/checkout@v3
- name: Run tests
run: |
go test -v -race -cover -short ./...
name: "unit tests"
runs-on: ${{ matrix.os }}
environment: "Private Repos"
strategy:
matrix:
os: [macos-latest, windows-latest]
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: "1.18"
- name: Checkout code
uses: actions/checkout@v3
- name: Run tests
run: |
go test -v -race -cover -short ./...
38 changes: 22 additions & 16 deletions internal/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package proxy_test
import (
"context"
"net"
"os"
"testing"

"cloud.google.com/go/alloydbconn"
Expand All @@ -26,6 +27,12 @@ import (

type fakeDialer struct{}

type testCase struct {
desc string
in *proxy.Config
wantAddrs []string
}

func (fakeDialer) Dial(ctx context.Context, inst string, opts ...alloydbconn.DialOption) (net.Conn, error) {
return nil, nil
}
Expand All @@ -39,11 +46,7 @@ func TestClientInitialization(t *testing.T) {
cluster1 := "/projects/proj/locations/region/clusters/clust/instances/inst1"
cluster2 := "/projects/proj/locations/region/clusters/clust/instances/inst2"

tcs := []struct {
desc string
in *proxy.Config
wantAddrs []string
}{
tcs := []testCase{
{
desc: "multiple instances",
in: &proxy.Config{
Expand All @@ -67,17 +70,6 @@ func TestClientInitialization(t *testing.T) {
},
wantAddrs: []string{"0.0.0.0:5000"},
},
{
desc: "IPv6 support",
in: &proxy.Config{
Addr: "::1",
Port: 5000,
Instances: []proxy.InstanceConnConfig{
{Name: cluster1},
},
},
wantAddrs: []string{"[::1]:5000"},
},
{
desc: "with instance port",
in: &proxy.Config{
Expand Down Expand Up @@ -120,6 +112,20 @@ func TestClientInitialization(t *testing.T) {
},
},
}
_, isFlex := os.LookupEnv("FLEX")
if !isFlex {
tcs = append(tcs, testCase{
desc: "IPv6 support",
in: &proxy.Config{
Addr: "::1",
Port: 5000,
Instances: []proxy.InstanceConnConfig{
{Name: cluster1},
},
},
wantAddrs: []string{"[::1]:5000"},
})
}

for _, tc := range tcs {
t.Run(tc.desc, func(t *testing.T) {
Expand Down
8 changes: 8 additions & 0 deletions tests/alloydb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func TestPostgresAuthWithToken(t *testing.T) {
if testing.Short() {
t.Skip("skipping Postgres integration tests")
}
_, isFlex := os.LookupEnv("FLEX")
if isFlex {
t.Skip("disabling until we migrate tests to Kokoro")
}
requirePostgresVars(t)
cleanup, err := pgxv4.RegisterDriver("alloydb2")
if err != nil {
Expand All @@ -84,6 +88,10 @@ func TestPostgresAuthWithCredentialsFile(t *testing.T) {
if testing.Short() {
t.Skip("skipping Postgres integration tests")
}
_, isFlex := os.LookupEnv("FLEX")
if isFlex {
t.Skip("disabling until we migrate tests to Kokoro")
}
requirePostgresVars(t)
cleanup, err := pgxv4.RegisterDriver("alloydb3")
if err != nil {
Expand Down

0 comments on commit 242025c

Please sign in to comment.