From efd2d46721cfcbd3fea30dd3a905f08a236524b0 Mon Sep 17 00:00:00 2001 From: Aravind Shankar Date: Tue, 21 Aug 2018 15:56:54 +0530 Subject: [PATCH 1/6] cli: update tests to use access key --- cli/commands/metadata_apply_test.go | 3 ++- cli/commands/metadata_export_test.go | 3 ++- cli/commands/metadata_reset_test.go | 3 ++- cli/commands/migrate_apply_test.go | 2 +- cli/commands/migrate_status_test.go | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cli/commands/metadata_apply_test.go b/cli/commands/metadata_apply_test.go index 261d1fba585a4..bb779add678c9 100644 --- a/cli/commands/metadata_apply_test.go +++ b/cli/commands/metadata_apply_test.go @@ -2,6 +2,7 @@ package commands import ( "net/url" + "os" "testing" "time" @@ -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_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/metadata_export_test.go b/cli/commands/metadata_export_test.go index 98e8f0d21b9a5..459ff731889a1 100644 --- a/cli/commands/metadata_export_test.go +++ b/cli/commands/metadata_export_test.go @@ -2,6 +2,7 @@ package commands import ( "net/url" + "os" "testing" "time" @@ -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_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/metadata_reset_test.go b/cli/commands/metadata_reset_test.go index 1b508dc9a2c69..293d4d221d0f6 100644 --- a/cli/commands/metadata_reset_test.go +++ b/cli/commands/metadata_reset_test.go @@ -2,6 +2,7 @@ package commands import ( "net/url" + "os" "testing" "time" @@ -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_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/migrate_apply_test.go b/cli/commands/migrate_apply_test.go index 218cbf92d6776..8ad79f9325099 100644 --- a/cli/commands/migrate_apply_test.go +++ b/cli/commands/migrate_apply_test.go @@ -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_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/migrate_status_test.go b/cli/commands/migrate_status_test.go index 4dbbb0d055fb0..1f138290acfbd 100644 --- a/cli/commands/migrate_status_test.go +++ b/cli/commands/migrate_status_test.go @@ -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_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, From aef4d138249917218cb00768cef2cdd050561bff Mon Sep 17 00:00:00 2001 From: Aravind Shankar Date: Thu, 23 Aug 2018 14:50:58 +0530 Subject: [PATCH 2/6] change env from HASURA_GRAPHQL_ACCESS_KEY to HASURA_GRAPHQL_TEST_ACCESS_KEY --- cli/commands/metadata_apply_test.go | 2 +- cli/commands/metadata_export_test.go | 2 +- cli/commands/metadata_reset_test.go | 2 +- cli/commands/migrate_apply_test.go | 2 +- cli/commands/migrate_status_test.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/commands/metadata_apply_test.go b/cli/commands/metadata_apply_test.go index bb779add678c9..c6f3a42867223 100644 --- a/cli/commands/metadata_apply_test.go +++ b/cli/commands/metadata_apply_test.go @@ -20,7 +20,7 @@ func testMetadataApply(t *testing.T, metadataFile string, endpoint *url.URL) { MetadataFile: metadataFile, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: os.Getenv("HASURA_GRAPHQL_ACCESS_KEY"), + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/metadata_export_test.go b/cli/commands/metadata_export_test.go index 459ff731889a1..ea7012a676a81 100644 --- a/cli/commands/metadata_export_test.go +++ b/cli/commands/metadata_export_test.go @@ -20,7 +20,7 @@ func testMetadataExport(t *testing.T, metadataFile string, endpoint *url.URL) { MetadataFile: metadataFile, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: os.Getenv("HASURA_GRAPHQL_ACCESS_KEY"), + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/metadata_reset_test.go b/cli/commands/metadata_reset_test.go index 293d4d221d0f6..78dc8d736d8a0 100644 --- a/cli/commands/metadata_reset_test.go +++ b/cli/commands/metadata_reset_test.go @@ -20,7 +20,7 @@ func testMetadataReset(t *testing.T, metadataFile string, endpoint *url.URL) { MetadataFile: metadataFile, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: os.Getenv("HASURA_GRAPHQL_ACCESS_KEY"), + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/migrate_apply_test.go b/cli/commands/migrate_apply_test.go index 8ad79f9325099..dd647604c5794 100644 --- a/cli/commands/migrate_apply_test.go +++ b/cli/commands/migrate_apply_test.go @@ -24,7 +24,7 @@ func testMigrateApply(t *testing.T, endpoint *url.URL, migrationsDir string, up MigrationDir: migrationsDir, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: os.Getenv("HASURA_GRAPHQL_ACCESS_KEY"), + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, diff --git a/cli/commands/migrate_status_test.go b/cli/commands/migrate_status_test.go index 1f138290acfbd..a0fc63f4cce89 100644 --- a/cli/commands/migrate_status_test.go +++ b/cli/commands/migrate_status_test.go @@ -25,7 +25,7 @@ func testMigrateStatus(t *testing.T, endpoint *url.URL, migrationsDir string, ex MigrationDir: migrationsDir, Config: &cli.HasuraGraphQLConfig{ Endpoint: endpoint.String(), - AccessKey: os.Getenv("HASURA_GRAPHQL_ACCESS_KEY"), + AccessKey: os.Getenv("HASURA_GRAPHQL_TEST_ACCESS_KEY"), ParsedEndpoint: endpoint, }, }, From 68e1914ea1f2f1b2ff43944c5f54c853b8234e0e Mon Sep 17 00:00:00 2001 From: Aravind Shankar Date: Thu, 23 Aug 2018 14:53:17 +0530 Subject: [PATCH 3/6] update circlci to use access key tests --- .circleci/test-cli.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.circleci/test-cli.sh b/.circleci/test-cli.sh index c159c62f6fa60..01c7f0b8ec5d1 100755 --- a/.circleci/test-cli.sh +++ b/.circleci/test-cli.sh @@ -20,13 +20,26 @@ 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 'DROP DATABASE "gql_test";' +psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test";' +/build/_server_output/graphql-engine \ + --database-url postgres://gql_test@localhost:5432/gql_test serve --access-key "abcd" > /build/_cli_output/server.log 2>&1 & +PID=$! + +wait_for_port 8080 + +# test cli +HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ACCESS_KEY="abcd" make test +kill $PID From 59f2ba94a623347f85348bf9faab696e02fed9dd Mon Sep 17 00:00:00 2001 From: Aravind Shankar Date: Thu, 30 Aug 2018 18:46:48 +0530 Subject: [PATCH 4/6] instal postgresql-client on cli docker builder --- .circleci/cli-builder.dockerfile | 4 ++-- .circleci/config.yml | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.circleci/cli-builder.dockerfile b/.circleci/cli-builder.dockerfile index 8c1d3a7da79d9..fd7e89055bf35 100644 --- a/.circleci/cli-builder.dockerfile +++ b/.circleci/cli-builder.dockerfile @@ -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/* \ No newline at end of file + && rm -rf /var/lib/apt/lists/* diff --git a/.circleci/config.yml b/.circleci/config.yml index 93f9fa724fe3c..a76e9c671cc06 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 From 9275be5b185136135cff5224eb232e249736d944 Mon Sep 17 00:00:00 2001 From: Aravind Shankar Date: Thu, 30 Aug 2018 19:06:59 +0530 Subject: [PATCH 5/6] create db for cli tests with access key --- .circleci/test-cli.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.circleci/test-cli.sh b/.circleci/test-cli.sh index 01c7f0b8ec5d1..7a8cc05683158 100755 --- a/.circleci/test-cli.sh +++ b/.circleci/test-cli.sh @@ -32,10 +32,9 @@ HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" make test kill $PID # start graphql-engine with access key -psql -U gql_test -h localhost -c 'DROP DATABASE "gql_test";' -psql -U gql_test -h localhost -c 'CREATE DATABASE "gql_test";' +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 serve --access-key "abcd" > /build/_cli_output/server.log 2>&1 & + --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 From eeffb972151f40d912c8fe46a5bd0980ffda0693 Mon Sep 17 00:00:00 2001 From: Aravind Shankar Date: Thu, 30 Aug 2018 19:14:45 +0530 Subject: [PATCH 6/6] disable cache for go tests --- .circleci/test-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/test-cli.sh b/.circleci/test-cli.sh index 7a8cc05683158..343bce27a9cc0 100755 --- a/.circleci/test-cli.sh +++ b/.circleci/test-cli.sh @@ -40,5 +40,5 @@ PID=$! wait_for_port 8080 # test cli -HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ACCESS_KEY="abcd" make test +GOCACHE=off HASURA_GRAPHQL_TEST_ENDPOINT="http://localhost:8080" HASURA_GRAPHQL_TEST_ACCESS_KEY="abcd" make test kill $PID