Skip to content

Commit

Permalink
update tests to use access key (close #113) (#296)
Browse files Browse the repository at this point in the history
Closes #113
  • Loading branch information
arvi3411301 authored and shahidhk committed Aug 30, 2018
1 parent 80bc927 commit ea9b187
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .circleci/cli-builder.dockerfile
Expand Up @@ -10,10 +10,10 @@ RUN go get github.com/golang/dep/cmd/dep \

# install UPX and netcat
RUN apt-get update && apt-get install -y \
xz-utils netcat libpq5 \
xz-utils netcat libpq5 postgresql-client \
&& curl -Lo /tmp/upx-${upx_version}.tar.xz https://github.com/upx/upx/releases/download/v${upx_version}/upx-${upx_version}-amd64_linux.tar.xz \
&& xz -d -c /tmp/upx-${upx_version}.tar.xz \
| tar -xOf - upx-${upx_version}-amd64_linux/upx > /bin/upx \
&& chmod a+x /bin/upx \
&& apt-get -y auto-remove \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*
16 changes: 8 additions & 8 deletions .circleci/config.yml
Expand Up @@ -70,7 +70,7 @@ jobs:
# changes only contains files in .ciignore
check_build_worthiness:
docker:
- image: hasura/graphql-engine-cli-builder:v0.2
- image: hasura/graphql-engine-cli-builder:v0.3
working_directory: ~/graphql-engine
steps:
- checkout
Expand All @@ -81,7 +81,7 @@ jobs:
# build the server binary, and package into docker image
build_server:
docker:
- image: hasura/graphql-engine-server-builder:v0.2
- image: hasura/graphql-engine-server-builder:v0.3
working_directory: ~/graphql-engine
steps:
- checkout
Expand Down Expand Up @@ -137,28 +137,28 @@ jobs:
test_server_pg_10.4:
<<: *test_server
docker:
- image: hasura/graphql-engine-cli-builder:v0.2
- image: hasura/graphql-engine-cli-builder:v0.3
- image: circleci/postgres:10.4-alpine
<<: *test_pg_env

test_server_pg_9.6:
<<: *test_server
docker:
- image: hasura/graphql-engine-cli-builder:v0.2
- image: hasura/graphql-engine-cli-builder:v0.3
- image: circleci/postgres:9.6-alpine
<<: *test_pg_env

test_server_pg_9.5:
<<: *test_server
docker:
- image: hasura/graphql-engine-cli-builder:v0.2
- image: hasura/graphql-engine-cli-builder:v0.3
- image: circleci/postgres:9.5-alpine
<<: *test_pg_env

# test and build cli
test_and_build_cli:
docker:
- image: hasura/graphql-engine-cli-builder:v0.2
- image: hasura/graphql-engine-cli-builder:v0.3
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
# test and build console
test_and_build_console:
docker:
- image: hasura/graphql-engine-console-builder:v0.2
- image: hasura/graphql-engine-console-builder:v0.3
- image: circleci/postgres:10-alpine
environment:
POSTGRES_USER: gql_test
Expand Down Expand Up @@ -245,7 +245,7 @@ jobs:

deploy:
docker:
- image: hasura/graphql-engine-deployer:v0.2
- image: hasura/graphql-engine-deployer:v0.3
working_directory: ~/graphql-engine
steps:
- *setup_remote_docker
Expand Down
18 changes: 15 additions & 3 deletions .circleci/test-cli.sh
Expand Up @@ -20,13 +20,25 @@ cd "$CLI_ROOT"
mkdir -p /build/_cli_output
touch /build/_cli_output/server.log

# start graphql-engine
# start graphql-engine without access key
/build/_server_output/graphql-engine \
--database-url postgres://gql_test@localhost:5432/gql_test serve > /build/_cli_output/server.log 2>&1 &
#PID=$!
PID=$!

wait_for_port 8080

# test cli
HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test
#kill $PID
kill $PID

# start graphql-engine with access key
psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test_with_access";'
/build/_server_output/graphql-engine \
--database-url postgres://gql_test@localhost:5432/gql_test_with_access serve --access-key "abcd" > /build/_cli_output/server.log 2>&1 &
PID=$!

wait_for_port 8080

# test cli
GOCACHE=off HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ACCESS_KEY="abcd" make test
kill $PID
3 changes: 2 additions & 1 deletion cli/commands/metadata_apply_test.go
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"net/url"
"os"
"testing"
"time"

Expand All @@ -19,7 +20,7 @@ func testMetadataApply(t *testing.T, metadataFile string, endpoint *url.URL) {
MetadataFile: metadataFile,
Config: &cli.HasuraGraphQLConfig{
Endpoint: endpoint.String(),
AccessKey: "",
AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"),
ParsedEndpoint: endpoint,
},
},
Expand Down
3 changes: 2 additions & 1 deletion cli/commands/metadata_export_test.go
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"net/url"
"os"
"testing"
"time"

Expand All @@ -19,7 +20,7 @@ func testMetadataExport(t *testing.T, metadataFile string, endpoint *url.URL) {
MetadataFile: metadataFile,
Config: &cli.HasuraGraphQLConfig{
Endpoint: endpoint.String(),
AccessKey: "",
AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"),
ParsedEndpoint: endpoint,
},
},
Expand Down
3 changes: 2 additions & 1 deletion cli/commands/metadata_reset_test.go
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"net/url"
"os"
"testing"
"time"

Expand All @@ -19,7 +20,7 @@ func testMetadataReset(t *testing.T, metadataFile string, endpoint *url.URL) {
MetadataFile: metadataFile,
Config: &cli.HasuraGraphQLConfig{
Endpoint: endpoint.String(),
AccessKey: "",
AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"),
ParsedEndpoint: endpoint,
},
},
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/migrate_apply_test.go
Expand Up @@ -24,7 +24,7 @@ func testMigrateApply(t *testing.T, endpoint *url.URL, migrationsDir string, up
MigrationDir: migrationsDir,
Config: &cli.HasuraGraphQLConfig{
Endpoint: endpoint.String(),
AccessKey: "",
AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"),
ParsedEndpoint: endpoint,
},
},
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/migrate_status_test.go
Expand Up @@ -25,7 +25,7 @@ func testMigrateStatus(t *testing.T, endpoint *url.URL, migrationsDir string, ex
MigrationDir: migrationsDir,
Config: &cli.HasuraGraphQLConfig{
Endpoint: endpoint.String(),
AccessKey: "",
AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"),
ParsedEndpoint: endpoint,
},
},
Expand Down

0 comments on commit ea9b187

Please sign in to comment.