这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 7 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ jobs:
build_server:
docker:
- image: hasura/graphql-engine-server-builder:20190826
resource_class: large
working_directory: ~/graphql-engine
steps:
- attach_workspace:
Expand Down Expand Up @@ -176,7 +177,7 @@ jobs:
make ci-binary
else
echo "Non-release branch, build with coverage"
BUILD_FLAGS="--coverage" make ci-binary
make BUILD_FLAGS='--coverage' ci-binary
fi
- run:
name: Build the docker image
Expand Down Expand Up @@ -264,7 +265,7 @@ jobs:
- image: circleci/postgres:9.5-alpine-postgis
<<: *test_pg_env

server_property_tests:
server_unit_tests:
resource_class: large
docker:
- image: hasura/graphql-engine-server-builder:20190826
Expand All @@ -281,11 +282,11 @@ jobs:
keys:
- server-deps-cache-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/stack.yaml" }}
- run:
name: Run property tests
name: Run unit tests
environment:
GHCRTS: -N2
command: |
/build/_server_output/graphql-engine-tests property
/build/_server_output/graphql-engine-tests unit

test_cli_with_last_release:
docker:
Expand Down Expand Up @@ -522,7 +523,7 @@ workflows:
<<: *filter_only_vtags
requires:
- build_server
- server_property_tests:
- server_unit_tests:
<<: *filter_only_vtags
requires:
- build_server
Expand All @@ -538,7 +539,7 @@ workflows:
- test_server_pg_10
- test_server_pg_9.6
- test_server_pg_9.5
- server_property_tests
- server_unit_tests
- test_server_upgrade
- test_cli_with_last_release:
<<: *filter_only_vtags
Expand Down
2 changes: 1 addition & 1 deletion .circleci/test-server-flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fail_if_port_busy() {
wait_for_port() {
local PORT=$1
echo "waiting for $PORT"
for _ in $(seq 1 30);
for _ in $(seq 1 60);
do
nc -z localhost $PORT && echo "port $PORT is ready" && return
echo -n .
Expand Down
6 changes: 3 additions & 3 deletions .circleci/test-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fail_if_port_busy() {
wait_for_port() {
local PORT=$1
echo "waiting for $PORT"
for _ in $(seq 1 240);
for _ in $(seq 1 60);
do
nc -z localhost $PORT && echo "port $PORT is ready" && return
echo -n .
Expand Down Expand Up @@ -218,8 +218,8 @@ run_pytest_parallel() {
fi
}

echo -e "\n$(time_elapsed): <########## RUN GRAPHQL-ENGINE HASKELL TESTS(migrate) ###########################################>\n"
"${GRAPHQL_ENGINE_TESTS:?}" migrate
echo -e "\n$(time_elapsed): <########## RUN GRAPHQL-ENGINE HASKELL TESTS ###########################################>\n"
"${GRAPHQL_ENGINE_TESTS:?}" postgres

echo -e "\n$(time_elapsed): <########## TEST GRAPHQL-ENGINE WITHOUT ADMIN SECRET ###########################################>\n"
TEST_TYPE="no-auth"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export const passWithRemoteSchemaHeader = () => {
.type('sampleHeaderValue2');

cy.get(getElementFromAlias('add-remote-schema-submit')).click();
cy.wait(5000);
cy.wait(15000);
validateRS(getRemoteSchemaName(3, testName), 'success');
cy.url().should(
'eq',
Expand Down
3 changes: 3 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__pycache__/
dist
dist-newstyle/
cabal-dev
Pipfile
Pipfile.lock
Expand All @@ -15,8 +16,10 @@ Pipfile.lock
*.tix
.hsenv
.cabal-sandbox/
.ghc.environment*
cabal.sandbox.config
cabal.config
cabal.project.local
*.prof*
*.aux
*.hp
Expand Down
35 changes: 23 additions & 12 deletions server/.stylish-haskell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,36 @@ newline: native
#
# No language extensions are enabled by default.
language_extensions:
- TemplateHaskell
- QuasiQuotes
- EmptyCase
- FlexibleContexts
- FlexibleInstances
- InstanceSigs
- MultiParamTypeClasses
- LambdaCase
- MultiWayIf
- TupleSections
- ApplicativeDo
- BangPatterns
- BlockArguments
- ConstraintKinds
- DefaultSignatures
- DeriveDataTypeable
- DeriveFoldable
- DeriveFunctor
- DeriveGeneric
- DeriveLift
- DeriveTraversable
- DerivingVia
- EmptyCase
- FlexibleContexts
- FlexibleInstances
- FunctionalDependencies
- GeneralizedNewtypeDeriving
- BangPatterns
- InstanceSigs
- LambdaCase
- MultiParamTypeClasses
- MultiWayIf
- NamedFieldPuns
- NoImplicitPrelude
- OverloadedStrings
- QuasiQuotes
- RankNTypes
- ScopedTypeVariables
- StandaloneDeriving
- TemplateHaskell
- QuasiQuotes
- TupleSections
- TypeApplications
- TypeFamilies
- TypeOperators
2 changes: 1 addition & 1 deletion server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ release-image: $(project).cabal
ci-binary:
mkdir -p packaging/build/rootfs
# --no-terminal for a cleaner output in circleci
stack $(STACK_FLAGS) build --no-terminal --test --no-run-tests --bench --no-run-benchmarks --ghc-options=-Werror $(BUILD_FLAGS)
stack $(STACK_FLAGS) build --no-terminal --test --no-run-tests --bench --no-run-benchmarks --ghc-options='-j2 -Werror' $(BUILD_FLAGS)
mkdir -p $(build_output)
cp $(build_dir)/$(project)/$(project) $(build_dir)/graphql-engine-tests/graphql-engine-tests $(build_output)
echo "$(VERSION)" > $(build_output)/version.txt
Expand Down
76 changes: 60 additions & 16 deletions server/graphql-engine.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ flag profile

common common-all
ghc-options:
-O2 -foptimal-applicative-do
-O2 -fmax-simplifier-iterations=20 -foptimal-applicative-do
-Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
-fdefer-typed-holes

Expand All @@ -38,18 +38,24 @@ common common-all

default-language: Haskell2010
default-extensions:
ApplicativeDo BangPatterns ConstraintKinds DeriveDataTypeable DeriveFoldable DeriveFunctor
DeriveGeneric DeriveLift DeriveTraversable EmptyCase FlexibleContexts FlexibleInstances
FunctionalDependencies GeneralizedNewtypeDeriving InstanceSigs LambdaCase MultiParamTypeClasses
MultiWayIf NoImplicitPrelude OverloadedStrings QuantifiedConstraints QuasiQuotes RankNTypes
ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications
TypeFamilies TypeOperators
ApplicativeDo BangPatterns BlockArguments ConstraintKinds DefaultSignatures DeriveDataTypeable
DeriveFoldable DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable DerivingVia EmptyCase
FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving
InstanceSigs LambdaCase MultiParamTypeClasses MultiWayIf NamedFieldPuns NoImplicitPrelude
OverloadedStrings QuantifiedConstraints QuasiQuotes RankNTypes ScopedTypeVariables
StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeOperators

common common-exe
ghc-options:
-threaded -rtsopts
-- Re. `-I2` see #2565
"-with-rtsopts=-N -I2"
--
-- `-qn2` limits the parallel GC to at most 2 capabilities. This came up in #3354/#3394, as the
-- parallel GC was causing significant performance overhead. Folks in #ghc on freenode advised
-- limiting the parallel GC to 2 or 3 capabilities as a very conservative choice, since more
-- than that is highly unlikely to ever be helpful. More benchmarking would be useful to know if
-- this is the right decision. It’s possible it would better to just turn it off completely.
"-with-rtsopts=-N -I2 -qn2"

if flag(profile)
ghc-prof-options: -rtsopts
Expand Down Expand Up @@ -89,6 +95,15 @@ library
, postgresql-binary
, process
, http-client-tls
, profunctors
, deepseq
, dependent-map >=0.2.4 && <0.4
, dependent-sum >=0.4 && <0.5

-- `these >=1` is split into several different packages, but our current stack
-- resolver has `these <1`; when we upgrade we just need to add an extra
-- dependency on `semialign`
, these >=0.7.1 && <0.8

-- Encoder related
, uuid
Expand Down Expand Up @@ -187,7 +202,10 @@ library
, QuickCheck
, generic-arbitrary

exposed-modules: Control.Monad.Stateless
exposed-modules: Control.Arrow.Extended
, Control.Arrow.Trans
, Control.Monad.Stateless
, Control.Monad.Unique

, Hasura.Prelude
, Hasura.App
Expand All @@ -198,6 +216,7 @@ library
, Hasura.Cache
, Hasura.Logging
, Hasura.HTTP
, Hasura.Incremental

, Hasura.Server.App
, Hasura.Server.Auth
Expand All @@ -212,14 +231,21 @@ library
, Hasura.Server.PGDump

, Hasura.RQL.Types
, Hasura.RQL.Types.Run
, Hasura.RQL.DDL.Metadata
, Hasura.RQL.DDL.Metadata.Types
, Hasura.RQL.DDL.Metadata.Generator
, Hasura.RQL.DDL.Schema
, Hasura.EncJSON

, Data.Aeson.Ordered

other-modules: Hasura.Server.Auth.JWT
other-modules: Hasura.Incremental.Select
, Hasura.Incremental.Internal.Cache
, Hasura.Incremental.Internal.Dependency
, Hasura.Incremental.Internal.Rule

, Hasura.Server.Auth.JWT
, Hasura.Server.Middleware
, Hasura.Server.Cors
, Hasura.Server.CheckUpdates
Expand All @@ -232,6 +258,7 @@ library

, Hasura.RQL.Instances
, Hasura.RQL.Types.SchemaCache
, Hasura.RQL.Types.SchemaCache.Build
, Hasura.RQL.Types.SchemaCacheTypes
, Hasura.RQL.Types.BoolExp
, Hasura.RQL.Types.Function
Expand All @@ -254,8 +281,11 @@ library
, Hasura.RQL.DDL.Permission
, Hasura.RQL.DDL.Relationship.Rename
, Hasura.RQL.DDL.Relationship.Types
, Hasura.RQL.DDL.Schema
, Hasura.RQL.DDL.Schema.Cache
, Hasura.RQL.DDL.Schema.Cache.Common
, Hasura.RQL.DDL.Schema.Cache.Dependencies
, Hasura.RQL.DDL.Schema.Cache.Fields
, Hasura.RQL.DDL.Schema.Cache.Permission
, Hasura.RQL.DDL.Schema.Catalog
, Hasura.RQL.DDL.Schema.Diff
, Hasura.RQL.DDL.Schema.Enum
Expand Down Expand Up @@ -330,6 +360,7 @@ library
, Control.Concurrent.Extended
, Control.Lens.Extended
, Data.Aeson.Extended
, Data.HashMap.Strict.Extended
, Data.HashMap.Strict.InsOrd.Extended
, Data.Parser.JSONPath
, Data.Sequence.NonEmpty
Expand Down Expand Up @@ -359,19 +390,32 @@ executable graphql-engine
test-suite graphql-engine-tests
import: common-all, common-exe
type: exitcode-stdio-1.0
hs-source-dirs: src-test
main-is: Main.hs
build-depends:
, aeson
, base
, bytestring
, graphql-engine
, hspec
, hspec >=2.6.1 && <3
, hspec-core >=2.6.1 && <3
, hspec-expectations-lifted
, http-client
, http-client-tls
, lifted-base
, monad-control
, mtl
, natural-transformation >=0.4 && <0.5
, optparse-applicative
, pg-client
, time
, aeson
, QuickCheck
, time
, transformers-base
, unordered-containers
hs-source-dirs: src-test
main-is: Main.hs
other-modules:
Hasura.IncrementalSpec
Hasura.RQL.MetadataSpec
Hasura.Server.MigrateSpec

-- Benchmarks related to caching (e.g. the plan cache).
--
Expand Down
11 changes: 7 additions & 4 deletions server/src-exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Hasura.App
import Hasura.Logging (Hasura)
import Hasura.Prelude
import Hasura.RQL.DDL.Metadata (fetchMetadata)
import Hasura.RQL.DDL.Schema
import Hasura.RQL.Types
import Hasura.Server.Init
import Hasura.Server.Migrate (dropCatalog)
Expand Down Expand Up @@ -39,13 +40,15 @@ runApp (HGEOptionsG rci hgeCmd) =
(InitCtx{..}, _) <- initialiseCtx hgeCmd rci
queryBs <- liftIO BL.getContents
let sqlGenCtx = SQLGenCtx False
res <- execQuery queryBs
& runHasSystemDefinedT (SystemDefined False)
& runAsAdmin _icPgPool sqlGenCtx _icHttpManager
res <- runAsAdmin _icPgPool sqlGenCtx _icHttpManager do
schemaCache <- buildRebuildableSchemaCache
execQuery queryBs
& runHasSystemDefinedT (SystemDefined False)
& runCacheRWT schemaCache
& fmap fst
either printErrJExit (liftIO . BLC.putStrLn) res

HCVersion -> liftIO $ putStrLn $ "Hasura GraphQL Engine: " ++ T.unpack currentVersion

where
runTx' initCtx tx =
liftIO $ runExceptT $ Q.runTx (_icPgPool initCtx) (Q.Serializable, Nothing) tx
Expand Down
Loading