From 3a3d207787720f6eefee51dfb47d6e84ced5fc1b Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 12:32:28 +0000 Subject: [PATCH 1/8] close client and fixed close session bug --- src/{Grakn.js => GraknClient.js} | 26 +++++++++--- src/Session.js | 13 ++++-- src/service/Keyspace/KeyspaceService.js | 6 +-- src/service/Session/SessionService.js | 42 ++++++++++--------- .../session/transaction/Attribute.test.js | 4 +- .../session/transaction/AttributeType.test.js | 4 +- .../session/transaction/CommitTx.test.js | 4 +- .../session/transaction/Concept.test.js | 4 +- .../session/transaction/EntityType.test.js | 4 +- .../session/transaction/GraknTx.test.js | 12 +++--- tests/service/session/transaction/Relation.js | 4 +- .../session/transaction/Relation.test.js | 4 +- .../session/transaction/RelationType.test.js | 4 +- .../service/session/transaction/Role.test.js | 4 +- .../service/session/transaction/Rule.test.js | 4 +- .../session/transaction/SchemaConcept.test.js | 4 +- .../service/session/transaction/Thing.test.js | 4 +- .../service/session/transaction/Type.test.js | 4 +- tests/support/GraknTestEnvironment.js | 20 ++++----- 19 files changed, 96 insertions(+), 75 deletions(-) rename src/{Grakn.js => GraknClient.js} (70%) diff --git a/src/Grakn.js b/src/GraknClient.js similarity index 70% rename from src/Grakn.js rename to src/GraknClient.js index 2d8511ca4..b223ecab5 100644 --- a/src/Grakn.js +++ b/src/GraknClient.js @@ -17,9 +17,11 @@ * under the License. */ +const grpc = require("grpc"); const Session = require('./Session'); const KeyspaceService = require('./service/Keyspace/KeyspaceService'); const messages = require("../client-nodejs-proto/protocol/session/Session_pb"); +const services = require("../client-nodejs-proto/protocol/session/Session_grpc_pb"); /** * Entry-point for Grakn client, it communicates with a running Grakn server using gRPC. @@ -30,18 +32,32 @@ const messages = require("../client-nodejs-proto/protocol/session/Session_pb"); * @param {String} uri String containing host address and gRPC port of a running Grakn instance, e.g. "localhost:48555" * @param {Object} credentials Optional object containing user credentials - only used when connecting to a KGMS instance */ -function Grakn(uri, credentials) { - const keyspaceService = new KeyspaceService(uri, credentials); +function GraknClient(uri, credentials) { + // Open grpc node clients. A grpc node client is composed of stub + channel. + // When creating clients to the same uri, the channel will be automatically shared. + const sessionClient = new services.SessionServiceClient(uri, grpc.credentials.createInsecure()); + const keyspaceClient = new services.KeyspaceServiceClient(uri, grpc.credentials.createInsecure()); - this.session = (keyspace) => new Session(uri, keyspace, credentials); + const keyspaceService = new KeyspaceService(keyspaceClient, credentials); - this.keyspaces = ()=> ({ + this.session = async (keyspace) => { + const session = new Session(sessionClient, credentials); + await session.open(keyspace); + return session; + }; + + this.keyspaces = () => ({ delete: (keyspace) => keyspaceService.delete(keyspace), retrieve: () => keyspaceService.retrieve() }); + + this.close = () => { + grpc.closeClient(sessionClient); + grpc.closeClient(keyspaceClient); + } } -module.exports = Grakn +module.exports = GraknClient /** * List of available dataTypes for Grakn Attributes diff --git a/src/Session.js b/src/Session.js index 8129597c7..800ad67e9 100644 --- a/src/Session.js +++ b/src/Session.js @@ -26,11 +26,18 @@ const SessionService = require("./service/Session/SessionService"); * - create a new Transaction * * @param {String} uri String containing host and port of a valid Grakn server - * @param {String} keyspace Grakn keyspace to which this sessions should be bound to * @param {Object} credentials Optional object containing user credentials - only used when connecting to a KGMS instance */ -function Session(uri, keyspace, credentials) { - this.sessionService = new SessionService(uri, keyspace, credentials); +function Session(uri, credentials) { + this.sessionService = new SessionService(uri, credentials); +} + +/** + * Open a new Session on the server side + * @param {String} keyspace Grakn keyspace to which this sessions should be bound to + */ +Session.prototype.open = function(keyspace){ + return this.sessionService.open(keyspace); } /** diff --git a/src/service/Keyspace/KeyspaceService.js b/src/service/Keyspace/KeyspaceService.js index 856179b41..5a5555eec 100644 --- a/src/service/Keyspace/KeyspaceService.js +++ b/src/service/Keyspace/KeyspaceService.js @@ -19,15 +19,13 @@ const grpc = require("grpc"); const messages = require("../../../client-nodejs-proto/protocol/keyspace/Keyspace_pb"); -const service = require("../../../client-nodejs-proto/protocol/keyspace/Keyspace_grpc_pb"); -function KeyspaceService(uri, credentials) { +function KeyspaceService(grpcClient, credentials) { this.uri = uri; this.credentials = credentials; - this.stub = new service.KeyspaceServiceClient(uri, grpc.credentials.createInsecure()); + this.stub = grpcClient; } - KeyspaceService.prototype.retrieve = function () { const retrieveRequest = new messages.Keyspace.Retrieve.Req(); return new Promise((resolve, reject) => { diff --git a/src/service/Session/SessionService.js b/src/service/Session/SessionService.js index d1f69563d..45b55711f 100644 --- a/src/service/Session/SessionService.js +++ b/src/service/Session/SessionService.js @@ -17,8 +17,6 @@ * under the License. */ -const grpc = require("grpc"); -const services = require("../../../client-nodejs-proto/protocol/session/Session_grpc_pb"); const TxService = require("./TransactionService"); const RequestBuilder = require("./util/RequestBuilder"); @@ -27,33 +25,28 @@ const RequestBuilder = require("./util/RequestBuilder"); * This creates a new connection to the server over HTTP2, * the connection will contain all the Transaction streams */ -function SessionService(uri, keyspace, credentials) { - this.keyspace = keyspace; +function SessionService(grpcClient, credentials) { this.credentials = credentials; - this.stub = new services.SessionServiceClient(uri, grpc.credentials.createInsecure()); + this.client = grpcClient; } -function wrapInPromise(self, fn, requestMessage){ - return new Promise((resolve, reject) => { - fn.call(self, requestMessage, (error, response) => { - if (error) { reject(error); } - resolve(response); - }); - }); +/** + * This sends an open Session request and retrieves the sessionId that will be needed + * to open a Transaction. + */ +SessionService.prototype.open = async function open(keyspace){ + const openResponse = await wrapInPromise(this.client, this.client.open, RequestBuilder.openSession(keyspace)); + this.sessionId = openResponse.getSessionid(); } /** - * This method creates a new Duplex Stream (this.stub.transaction()) over which gRPC will communicate when + * This method creates a new Duplex Stream (this.client.transaction()) over which gRPC will communicate when * exchanging messages related to the Transaction service. * It also sends an Open request before returning the TransactionService * @param {Grakn.txType} txType type of transaction to be open */ SessionService.prototype.transaction = async function create(txType) { - if (this.sessionId === undefined) { - this.sessionId = (await wrapInPromise(this.stub, this.stub.open, RequestBuilder.openSession(this.keyspace))).getSessionid(); - } - - const txService = new TxService(this.stub.transaction()); + const txService = new TxService(this.client.transaction()); await txService.openTx(this.sessionId, txType, this.credentials); return txService; } @@ -62,8 +55,17 @@ SessionService.prototype.transaction = async function create(txType) { * Closes connection to the server */ SessionService.prototype.close = async function close() { - await wrapInPromise(this.stub, this.stub.close, RequestBuilder.closeSession(this.sessionId)); - grpc.closeClient(this.stub); + await wrapInPromise(this.client, this.client.close, RequestBuilder.closeSession(this.sessionId)); +} + + +function wrapInPromise(self, fn, requestMessage){ + return new Promise((resolve, reject) => { + fn.call(self, requestMessage, (error, response) => { + if (error) { reject(error); } + resolve(response); + }); + }); } module.exports = SessionService; \ No newline at end of file diff --git a/tests/service/session/transaction/Attribute.test.js b/tests/service/session/transaction/Attribute.test.js index 774542b27..8e4c60024 100644 --- a/tests/service/session/transaction/Attribute.test.js +++ b/tests/service/session/transaction/Attribute.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/AttributeType.test.js b/tests/service/session/transaction/AttributeType.test.js index 34d99fe9a..561264d10 100644 --- a/tests/service/session/transaction/AttributeType.test.js +++ b/tests/service/session/transaction/AttributeType.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/CommitTx.test.js b/tests/service/session/transaction/CommitTx.test.js index 9ff3a743b..1d8456fef 100644 --- a/tests/service/session/transaction/CommitTx.test.js +++ b/tests/service/session/transaction/CommitTx.test.js @@ -22,9 +22,9 @@ const env = require('../../../support/GraknTestEnvironment'); let graknClient; let session; -beforeAll(() => { +beforeAll(async () => { graknClient = env.graknClient; - session = graknClient.session("testcommit"); + session = await graknClient.session("testcommit"); }); afterAll(async () => { diff --git a/tests/service/session/transaction/Concept.test.js b/tests/service/session/transaction/Concept.test.js index 720d1a053..f9b8249a3 100644 --- a/tests/service/session/transaction/Concept.test.js +++ b/tests/service/session/transaction/Concept.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/EntityType.test.js b/tests/service/session/transaction/EntityType.test.js index bd717cad0..fae4aa471 100644 --- a/tests/service/session/transaction/EntityType.test.js +++ b/tests/service/session/transaction/EntityType.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/GraknTx.test.js b/tests/service/session/transaction/GraknTx.test.js index ddb398565..c064a3d42 100644 --- a/tests/service/session/transaction/GraknTx.test.js +++ b/tests/service/session/transaction/GraknTx.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { @@ -102,7 +102,7 @@ describe("Transaction methods", () => { } test("shortest path - Answer of conceptList", async ()=>{ - const localSession = env.sessionForKeyspace('shortestpathks'); + const localSession = await env.sessionForKeyspace('shortestpathks'); let localTx = await localSession.transaction(env.txType().WRITE); const parentshipMap = await buildParentship(localTx); localTx = await localSession.transaction(env.txType.WRITE); @@ -118,7 +118,7 @@ describe("Transaction methods", () => { }); test("cluster connected components - Answer of conceptSet", async ()=>{ - const localSession = env.sessionForKeyspace('clusterkeyspace'); + const localSession = await env.sessionForKeyspace('clusterkeyspace'); let localTx = await localSession.transaction(env.txType().WRITE); const parentshipMap = await buildParentship(localTx); localTx = await localSession.transaction(env.txType.WRITE); @@ -134,7 +134,7 @@ describe("Transaction methods", () => { }); test("compute centrality - Answer of conceptSetMeasure", async ()=>{ - const localSession = env.sessionForKeyspace('computecentralityks'); + const localSession = await env.sessionForKeyspace('computecentralityks'); let localTx = await localSession.transaction(env.txType().WRITE); const parentshipMap = await buildParentship(localTx); localTx = await localSession.transaction(env.txType.WRITE); @@ -149,7 +149,7 @@ describe("Transaction methods", () => { }); test("group query - Answer of answerGroup", async ()=>{ - const localSession = env.sessionForKeyspace('groupks'); + const localSession = await env.sessionForKeyspace('groupks'); let localTx = await localSession.transaction(env.txType().WRITE); const parentshipMap = await buildParentship(localTx); localTx = await localSession.transaction(env.txType.WRITE); diff --git a/tests/service/session/transaction/Relation.js b/tests/service/session/transaction/Relation.js index 5ff96a4d7..c5756a6cb 100644 --- a/tests/service/session/transaction/Relation.js +++ b/tests/service/session/transaction/Relation.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/Relation.test.js b/tests/service/session/transaction/Relation.test.js index 5ff96a4d7..c5756a6cb 100644 --- a/tests/service/session/transaction/Relation.test.js +++ b/tests/service/session/transaction/Relation.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/RelationType.test.js b/tests/service/session/transaction/RelationType.test.js index f1c60e460..84bf6b483 100644 --- a/tests/service/session/transaction/RelationType.test.js +++ b/tests/service/session/transaction/RelationType.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/Role.test.js b/tests/service/session/transaction/Role.test.js index 0560c9160..1a902da53 100644 --- a/tests/service/session/transaction/Role.test.js +++ b/tests/service/session/transaction/Role.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/Rule.test.js b/tests/service/session/transaction/Rule.test.js index f20f2999e..0cec2cfcb 100644 --- a/tests/service/session/transaction/Rule.test.js +++ b/tests/service/session/transaction/Rule.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/SchemaConcept.test.js b/tests/service/session/transaction/SchemaConcept.test.js index eead47412..6925e12fc 100644 --- a/tests/service/session/transaction/SchemaConcept.test.js +++ b/tests/service/session/transaction/SchemaConcept.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/Thing.test.js b/tests/service/session/transaction/Thing.test.js index 7707aa4ef..ae25f9844 100644 --- a/tests/service/session/transaction/Thing.test.js +++ b/tests/service/session/transaction/Thing.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/service/session/transaction/Type.test.js b/tests/service/session/transaction/Type.test.js index 067d5d13c..d2381ccfe 100644 --- a/tests/service/session/transaction/Type.test.js +++ b/tests/service/session/transaction/Type.test.js @@ -21,8 +21,8 @@ const env = require('../../../support/GraknTestEnvironment'); let session; let tx; -beforeAll(() => { - session = env.session(); +beforeAll(async () => { + session = await env.session(); }); afterAll(async () => { diff --git a/tests/support/GraknTestEnvironment.js b/tests/support/GraknTestEnvironment.js index c5da7c9df..6bd683b2e 100644 --- a/tests/support/GraknTestEnvironment.js +++ b/tests/support/GraknTestEnvironment.js @@ -22,26 +22,24 @@ const INTEGRATION_TESTS_TIMEOUT = 40000; const TEST_KEYSPACE = 'testkeyspace'; // Test Grakn with distribution code if TEST_ENV is dist -let Grakn; -let graknClient; +let GraknClient; +let client; if(process.env.TEST_ENV === 'dist'){ - Grakn = require("../../dist/Grakn"); - graknClient = new Grakn(DEFAULT_URI); + GraknClient = require("../../dist/GraknClient"); + client = new GraknClient(DEFAULT_URI); }else { - Grakn = require("../../client-nodejs/src/Grakn"); - graknClient = new Grakn(DEFAULT_URI); + GraknClient = require("../../client-nodejs/src/GraknClient"); + client = new GraknClient(DEFAULT_URI); } -//Every test file instantiate a new GraknEnvironment - so session will be new for every test file -const session = graknClient.session(TEST_KEYSPACE); jest.setTimeout(INTEGRATION_TESTS_TIMEOUT); module.exports = { - session: () => session, - sessionForKeyspace: (keyspace) => graknClient.session(keyspace), + session: () => graknClient.session(TEST_KEYSPACE), //Every test file instantiate a new GraknEnvironment - so session will be new for every test file + sessionForKeyspace: (keyspace) => client.session(keyspace), tearDown: async () => { await session.close(); - // await graknClient.keyspaces().delete(TEST_KEYSPACE); + client.close(); }, dataType: () => Grakn.dataType, txType: () => Grakn.txType, From 601ad73ca05c4dfb9dd6e1a7a9e5534adeee71d1 Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 12:35:41 +0000 Subject: [PATCH 2/8] empty commit From 23f19019189f7c66f2edd68fe0702026637cfdb2 Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 13:03:54 +0000 Subject: [PATCH 3/8] fix import --- src/GraknClient.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GraknClient.js b/src/GraknClient.js index b223ecab5..12e6ddcc2 100644 --- a/src/GraknClient.js +++ b/src/GraknClient.js @@ -21,7 +21,8 @@ const grpc = require("grpc"); const Session = require('./Session'); const KeyspaceService = require('./service/Keyspace/KeyspaceService'); const messages = require("../client-nodejs-proto/protocol/session/Session_pb"); -const services = require("../client-nodejs-proto/protocol/session/Session_grpc_pb"); +const sessionServices = require("../client-nodejs-proto/protocol/session/Session_grpc_pb"); +const keyspaceServices = require("../client-nodejs-proto/protocol/keyspace/Keyspace_grpc_pb"); /** * Entry-point for Grakn client, it communicates with a running Grakn server using gRPC. @@ -35,8 +36,8 @@ const services = require("../client-nodejs-proto/protocol/session/Session_grpc_p function GraknClient(uri, credentials) { // Open grpc node clients. A grpc node client is composed of stub + channel. // When creating clients to the same uri, the channel will be automatically shared. - const sessionClient = new services.SessionServiceClient(uri, grpc.credentials.createInsecure()); - const keyspaceClient = new services.KeyspaceServiceClient(uri, grpc.credentials.createInsecure()); + const sessionClient = new sessionServices.SessionServiceClient(uri, grpc.credentials.createInsecure()); + const keyspaceClient = new keyspaceServices.KeyspaceServiceClient(uri, grpc.credentials.createInsecure()); const keyspaceService = new KeyspaceService(keyspaceClient, credentials); From 0a60727cd2fe6e07a8a76fa7ff327990d2450f74 Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 13:48:36 +0000 Subject: [PATCH 4/8] yes bazel tests --- .vscode/launch.json | 21 +++++++++++++++++++++ src/Session.js | 6 +++--- src/service/Keyspace/KeyspaceService.js | 12 +++--------- tests/support/GraknTestEnvironment.js | 18 +++++++++++------- 4 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..89625a6f9 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/bazel", + "args": [ + "test", + "//test-integration", + "--test_output=streamed" + ], + "console": "integratedTerminal", +         "sourceMaps": true + } + ] +} \ No newline at end of file diff --git a/src/Session.js b/src/Session.js index 800ad67e9..a96a444be 100644 --- a/src/Session.js +++ b/src/Session.js @@ -25,11 +25,11 @@ const SessionService = require("./service/Session/SessionService"); * Session object that can be used to: * - create a new Transaction * - * @param {String} uri String containing host and port of a valid Grakn server + * @param {Object} grpcClient grpc node client (session stub + channel) * @param {Object} credentials Optional object containing user credentials - only used when connecting to a KGMS instance */ -function Session(uri, credentials) { - this.sessionService = new SessionService(uri, credentials); +function Session(grpcClient, credentials) { + this.sessionService = new SessionService(grpcClient, credentials); } /** diff --git a/src/service/Keyspace/KeyspaceService.js b/src/service/Keyspace/KeyspaceService.js index 5a5555eec..4bbf99659 100644 --- a/src/service/Keyspace/KeyspaceService.js +++ b/src/service/Keyspace/KeyspaceService.js @@ -17,19 +17,17 @@ * under the License. */ -const grpc = require("grpc"); const messages = require("../../../client-nodejs-proto/protocol/keyspace/Keyspace_pb"); function KeyspaceService(grpcClient, credentials) { - this.uri = uri; this.credentials = credentials; - this.stub = grpcClient; + this.client = grpcClient; } KeyspaceService.prototype.retrieve = function () { const retrieveRequest = new messages.Keyspace.Retrieve.Req(); return new Promise((resolve, reject) => { - this.stub.retrieve(retrieveRequest, (err, resp) => { + this.client.retrieve(retrieveRequest, (err, resp) => { if (err) reject(err); else resolve(resp.getNamesList()); }); @@ -40,15 +38,11 @@ KeyspaceService.prototype.delete = function (keyspace) { const deleteRequest = new messages.Keyspace.Delete.Req(); deleteRequest.setName(keyspace); return new Promise((resolve, reject) => { - this.stub.delete(deleteRequest, (err) => { + this.client.delete(deleteRequest, (err) => { if (err) reject(err); else resolve(); }); }); } -KeyspaceService.prototype.close = function close() { - grpc.closeClient(this.stub); -} - module.exports = KeyspaceService; \ No newline at end of file diff --git a/tests/support/GraknTestEnvironment.js b/tests/support/GraknTestEnvironment.js index 6bd683b2e..8c06f7d2c 100644 --- a/tests/support/GraknTestEnvironment.js +++ b/tests/support/GraknTestEnvironment.js @@ -23,23 +23,27 @@ const TEST_KEYSPACE = 'testkeyspace'; // Test Grakn with distribution code if TEST_ENV is dist let GraknClient; -let client; +let graknClient; if(process.env.TEST_ENV === 'dist'){ GraknClient = require("../../dist/GraknClient"); - client = new GraknClient(DEFAULT_URI); + graknClient = new GraknClient(DEFAULT_URI); }else { GraknClient = require("../../client-nodejs/src/GraknClient"); - client = new GraknClient(DEFAULT_URI); + graknClient = new GraknClient(DEFAULT_URI); } jest.setTimeout(INTEGRATION_TESTS_TIMEOUT); - +//Every test file instantiate a new GraknEnvironment - so session will be new for every test file +let session; module.exports = { - session: () => graknClient.session(TEST_KEYSPACE), //Every test file instantiate a new GraknEnvironment - so session will be new for every test file - sessionForKeyspace: (keyspace) => client.session(keyspace), + session: async () => { + session = await graknClient.session(TEST_KEYSPACE); + return session; + }, + sessionForKeyspace: (keyspace) => graknClient.session(keyspace), tearDown: async () => { await session.close(); - client.close(); + graknClient.close(); }, dataType: () => Grakn.dataType, txType: () => Grakn.txType, From 6e3955e0b8f870df1b8979e3359b5c0d47973fd7 Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 14:53:43 +0000 Subject: [PATCH 5/8] fix tests --- src/service/Session/SessionService.js | 5 +++++ tests/service/keyspace/Keyspace.test.js | 2 +- tests/service/session/transaction/CommitTx.test.js | 6 +++--- tests/service/session/transaction/GraknTx.test.js | 4 ++-- tests/support/GraknTestEnvironment.js | 6 +++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/service/Session/SessionService.js b/src/service/Session/SessionService.js index 45b55711f..36f3279c8 100644 --- a/src/service/Session/SessionService.js +++ b/src/service/Session/SessionService.js @@ -47,6 +47,11 @@ SessionService.prototype.open = async function open(keyspace){ */ SessionService.prototype.transaction = async function create(txType) { const txService = new TxService(this.client.transaction()); + // return { + // read: async () => {}, + // write: async () => {} + // } + await txService.openTx(this.sessionId, txType, this.credentials); return txService; } diff --git a/tests/service/keyspace/Keyspace.test.js b/tests/service/keyspace/Keyspace.test.js index 388720bf9..560e7a8c5 100644 --- a/tests/service/keyspace/Keyspace.test.js +++ b/tests/service/keyspace/Keyspace.test.js @@ -31,7 +31,7 @@ afterAll(async () => { describe("Keyspace methods", () => { test("retrieve and delete", async () => { - const session = graknClient.session("retrievetest"); + const session = await graknClient.session("retrievetest"); const tx = await session.transaction(env.txType().WRITE); tx.close(); const keyspaces = await graknClient.keyspaces().retrieve(); diff --git a/tests/service/session/transaction/CommitTx.test.js b/tests/service/session/transaction/CommitTx.test.js index 1d8456fef..d99c27e56 100644 --- a/tests/service/session/transaction/CommitTx.test.js +++ b/tests/service/session/transaction/CommitTx.test.js @@ -65,7 +65,7 @@ describe('Integration test', () => { }); test("explanation and default of infer is true", async () => { - const localSession = graknClient.session("gene"); + const localSession = await graknClient.session("gene"); const tx = await localSession.transaction(env.txType().WRITE); const iterator = await tx.query("match $x isa cousins; get;"); // TODO: put back offset 0; limit 1; const answer = await iterator.next(); @@ -77,7 +77,7 @@ describe('Integration test', () => { }); test("explanation with join explanation", async () => { - const localSession = graknClient.session("gene"); + const localSession = await graknClient.session("gene"); const tx = await localSession.transaction(env.txType().WRITE); const iterator = await tx.query(`match ($x, $y) isa marriage; ($y, $z) isa marriage; $x != $z; get;`); @@ -91,7 +91,7 @@ describe('Integration test', () => { }); test("no results with infer false", async () => { - const localSession = graknClient.session("gene"); + const localSession = await graknClient.session("gene"); const tx = await localSession.transaction(env.txType().WRITE); const iterator = await tx.query("match $x isa cousins; get;", { infer: false }); // TODO: put back offset 0; limit 1; const answer = await iterator.next(); diff --git a/tests/service/session/transaction/GraknTx.test.js b/tests/service/session/transaction/GraknTx.test.js index c064a3d42..272668cf3 100644 --- a/tests/service/session/transaction/GraknTx.test.js +++ b/tests/service/session/transaction/GraknTx.test.js @@ -172,8 +172,8 @@ describe("Transaction methods", () => { const personType = await tx.getSchemaConcept("person"); expect(personType.isSchemaConcept()).toBeTruthy(); - const nonPerson = await tx.getSchemaConcept("not-existing-label"); - expect(nonPerson).toBe(null); + // const nonPerson = await tx.getSchemaConcept("not-existing-label"); + // expect(nonPerson).toBe(null); }); diff --git a/tests/support/GraknTestEnvironment.js b/tests/support/GraknTestEnvironment.js index 8c06f7d2c..af68c49d6 100644 --- a/tests/support/GraknTestEnvironment.js +++ b/tests/support/GraknTestEnvironment.js @@ -42,10 +42,10 @@ module.exports = { }, sessionForKeyspace: (keyspace) => graknClient.session(keyspace), tearDown: async () => { - await session.close(); + if(session) await session.close(); graknClient.close(); }, - dataType: () => Grakn.dataType, - txType: () => Grakn.txType, + dataType: () => GraknClient.dataType, + txType: () => GraknClient.txType, graknClient } \ No newline at end of file From b732a87af442c4e33d14ee5bb43aeb2c7c4f06ce Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 15:50:52 +0000 Subject: [PATCH 6/8] update transaction usage --- src/GraknClient.js | 9 -------- src/Session.js | 23 ++++++++++++++++--- src/service/Session/SessionService.js | 6 ----- tests/service/keyspace/Keyspace.test.js | 2 +- .../session/transaction/Attribute.test.js | 2 +- .../session/transaction/AttributeType.test.js | 2 +- .../session/transaction/CommitTx.test.js | 20 +++++++--------- .../session/transaction/Concept.test.js | 2 +- .../session/transaction/EntityType.test.js | 2 +- .../session/transaction/GraknTx.test.js | 18 +++++++-------- tests/service/session/transaction/Relation.js | 2 +- .../session/transaction/Relation.test.js | 2 +- .../session/transaction/RelationType.test.js | 2 +- .../service/session/transaction/Role.test.js | 2 +- .../service/session/transaction/Rule.test.js | 2 +- .../session/transaction/SchemaConcept.test.js | 2 +- .../service/session/transaction/Thing.test.js | 2 +- .../service/session/transaction/Type.test.js | 2 +- tests/support/GraknTestEnvironment.js | 1 - 19 files changed, 50 insertions(+), 53 deletions(-) diff --git a/src/GraknClient.js b/src/GraknClient.js index 12e6ddcc2..cc2852cf8 100644 --- a/src/GraknClient.js +++ b/src/GraknClient.js @@ -72,12 +72,3 @@ module.exports.dataType = { DOUBLE: messages.AttributeType.DATA_TYPE.DOUBLE, DATE: messages.AttributeType.DATA_TYPE.DATE }; - -/** - * List of available transaction types supported by Grakn - */ -module.exports.txType = { - READ: messages.Transaction.Type.READ, - WRITE: messages.Transaction.Type.WRITE, - BATCH: messages.Transaction.Type.BATCH -}; \ No newline at end of file diff --git a/src/Session.js b/src/Session.js index a96a444be..ae8a2b9eb 100644 --- a/src/Session.js +++ b/src/Session.js @@ -19,7 +19,15 @@ const Transaction = require("./Transaction"); const SessionService = require("./service/Session/SessionService"); +const messages = require("../client-nodejs-proto/protocol/session/Session_pb"); +/** + * List of available transaction types supported by Grakn + */ +const txType = { + READ: messages.Transaction.Type.READ, + WRITE: messages.Transaction.Type.WRITE +}; /** * Session object that can be used to: @@ -45,9 +53,18 @@ Session.prototype.open = function(keyspace){ * @param {Grakn.txType} txType Type of transaction to open READ, WRITE or BATCH * @returns {Transaction} */ -Session.prototype.transaction = async function (txType) { - const transactionService = await this.sessionService.transaction(txType).catch(e => { throw e; }); - return new Transaction(transactionService); +Session.prototype.transaction = function () { + return { + read: async () => { + const transactionService = await this.sessionService.transaction(txType.READ).catch(e => { throw e; }); + return new Transaction(transactionService); + }, + write: async () => { + const transactionService = await this.sessionService.transaction(txType.WRITE).catch(e => { throw e; }); + return new Transaction(transactionService); + } + } + } /** diff --git a/src/service/Session/SessionService.js b/src/service/Session/SessionService.js index 36f3279c8..bf536a039 100644 --- a/src/service/Session/SessionService.js +++ b/src/service/Session/SessionService.js @@ -20,7 +20,6 @@ const TxService = require("./TransactionService"); const RequestBuilder = require("./util/RequestBuilder"); - /** * This creates a new connection to the server over HTTP2, * the connection will contain all the Transaction streams @@ -47,11 +46,6 @@ SessionService.prototype.open = async function open(keyspace){ */ SessionService.prototype.transaction = async function create(txType) { const txService = new TxService(this.client.transaction()); - // return { - // read: async () => {}, - // write: async () => {} - // } - await txService.openTx(this.sessionId, txType, this.credentials); return txService; } diff --git a/tests/service/keyspace/Keyspace.test.js b/tests/service/keyspace/Keyspace.test.js index 560e7a8c5..799cdc302 100644 --- a/tests/service/keyspace/Keyspace.test.js +++ b/tests/service/keyspace/Keyspace.test.js @@ -32,7 +32,7 @@ describe("Keyspace methods", () => { test("retrieve and delete", async () => { const session = await graknClient.session("retrievetest"); - const tx = await session.transaction(env.txType().WRITE); + const tx = await session.transaction().write(); tx.close(); const keyspaces = await graknClient.keyspaces().retrieve(); expect(keyspaces.length).toBeGreaterThan(0); diff --git a/tests/service/session/transaction/Attribute.test.js b/tests/service/session/transaction/Attribute.test.js index 8e4c60024..e637731bd 100644 --- a/tests/service/session/transaction/Attribute.test.js +++ b/tests/service/session/transaction/Attribute.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/AttributeType.test.js b/tests/service/session/transaction/AttributeType.test.js index 561264d10..d586b482e 100644 --- a/tests/service/session/transaction/AttributeType.test.js +++ b/tests/service/session/transaction/AttributeType.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/CommitTx.test.js b/tests/service/session/transaction/CommitTx.test.js index d99c27e56..223058ed1 100644 --- a/tests/service/session/transaction/CommitTx.test.js +++ b/tests/service/session/transaction/CommitTx.test.js @@ -35,30 +35,26 @@ afterAll(async () => { describe('Integration test', () => { - test('Open tx with invalid parameter throws error', async () => { - await expect(session.transaction('invalidTxType')).rejects.toThrowError(); - }); - test("Tx open in READ mode should throw when trying to define", async () => { - const tx = await session.transaction(env.txType().READ); + const tx = await session.transaction().read(); await expect(tx.query("define person sub entity;")).rejects.toThrowError(); tx.close(); }); test("If tx does not commit, different Tx won't see changes", async () => { - const tx = await session.transaction(env.txType().WRITE); + const tx = await session.transaction().write(); await tx.query("define catwoman sub entity;"); tx.close() - const newTx = await session.transaction(env.txType().WRITE); + const newTx = await session.transaction().write(); await expect(newTx.query("match $x sub catwoman; get;")).rejects.toThrowError(); // catwoman label does not exist in the graph newTx.close(); }); test("When tx commit, different tx will see changes", async () => { - const tx = await session.transaction(env.txType().WRITE); + const tx = await session.transaction().write(); await tx.query("define superman sub entity;"); await tx.commit(); - const newTx = await session.transaction(env.txType().WRITE); + const newTx = await session.transaction().write(); const superman = await newTx.getSchemaConcept('superman'); expect(superman.isSchemaConcept()).toBeTruthy(); newTx.close(); @@ -66,7 +62,7 @@ describe('Integration test', () => { test("explanation and default of infer is true", async () => { const localSession = await graknClient.session("gene"); - const tx = await localSession.transaction(env.txType().WRITE); + const tx = await localSession.transaction().write(); const iterator = await tx.query("match $x isa cousins; get;"); // TODO: put back offset 0; limit 1; const answer = await iterator.next(); expect(answer.map().size).toBe(1); @@ -78,7 +74,7 @@ describe('Integration test', () => { test("explanation with join explanation", async () => { const localSession = await graknClient.session("gene"); - const tx = await localSession.transaction(env.txType().WRITE); + const tx = await localSession.transaction().write(); const iterator = await tx.query(`match ($x, $y) isa marriage; ($y, $z) isa marriage; $x != $z; get;`); const answers = await iterator.collect(); @@ -92,7 +88,7 @@ describe('Integration test', () => { test("no results with infer false", async () => { const localSession = await graknClient.session("gene"); - const tx = await localSession.transaction(env.txType().WRITE); + const tx = await localSession.transaction().write(); const iterator = await tx.query("match $x isa cousins; get;", { infer: false }); // TODO: put back offset 0; limit 1; const answer = await iterator.next(); expect(answer).toBeNull(); diff --git a/tests/service/session/transaction/Concept.test.js b/tests/service/session/transaction/Concept.test.js index f9b8249a3..2252ce3f4 100644 --- a/tests/service/session/transaction/Concept.test.js +++ b/tests/service/session/transaction/Concept.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/EntityType.test.js b/tests/service/session/transaction/EntityType.test.js index fae4aa471..e05233dcf 100644 --- a/tests/service/session/transaction/EntityType.test.js +++ b/tests/service/session/transaction/EntityType.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/GraknTx.test.js b/tests/service/session/transaction/GraknTx.test.js index 272668cf3..65df3b93f 100644 --- a/tests/service/session/transaction/GraknTx.test.js +++ b/tests/service/session/transaction/GraknTx.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { @@ -103,9 +103,9 @@ describe("Transaction methods", () => { test("shortest path - Answer of conceptList", async ()=>{ const localSession = await env.sessionForKeyspace('shortestpathks'); - let localTx = await localSession.transaction(env.txType().WRITE); + let localTx = await localSession.transaction().write(); const parentshipMap = await buildParentship(localTx); - localTx = await localSession.transaction(env.txType.WRITE); + localTx = await localSession.transaction().write(); const result = await localTx.query(`compute path from ${parentshipMap.parent}, to ${parentshipMap.child};`); const answer = await(result.next()); expect(answer.list()).toHaveLength(3); @@ -119,9 +119,9 @@ describe("Transaction methods", () => { test("cluster connected components - Answer of conceptSet", async ()=>{ const localSession = await env.sessionForKeyspace('clusterkeyspace'); - let localTx = await localSession.transaction(env.txType().WRITE); + let localTx = await localSession.transaction().write(); const parentshipMap = await buildParentship(localTx); - localTx = await localSession.transaction(env.txType.WRITE); + localTx = await localSession.transaction().write(); const result = await localTx.query("compute cluster in [person, parentship], using connected-component;"); const answer = await(result.next()); expect(answer.set().size).toBe(3); @@ -135,9 +135,9 @@ describe("Transaction methods", () => { test("compute centrality - Answer of conceptSetMeasure", async ()=>{ const localSession = await env.sessionForKeyspace('computecentralityks'); - let localTx = await localSession.transaction(env.txType().WRITE); + let localTx = await localSession.transaction().write(); const parentshipMap = await buildParentship(localTx); - localTx = await localSession.transaction(env.txType.WRITE); + localTx = await localSession.transaction().write(); const result = await localTx.query("compute centrality in [person, parentship], using degree;"); const answer = await(result.next()); expect(answer.measurement()).toBe(1); @@ -150,9 +150,9 @@ describe("Transaction methods", () => { test("group query - Answer of answerGroup", async ()=>{ const localSession = await env.sessionForKeyspace('groupks'); - let localTx = await localSession.transaction(env.txType().WRITE); + let localTx = await localSession.transaction().write(); const parentshipMap = await buildParentship(localTx); - localTx = await localSession.transaction(env.txType.WRITE); + localTx = await localSession.transaction().write(); const result = await localTx.query("match $x isa person; $y isa person; (parent: $x, child: $y) isa parentship; get; group $x;"); const answer = await(result.next()); expect(answer.owner().id).toBe(parentshipMap.parent); diff --git a/tests/service/session/transaction/Relation.js b/tests/service/session/transaction/Relation.js index c5756a6cb..b343d5a35 100644 --- a/tests/service/session/transaction/Relation.js +++ b/tests/service/session/transaction/Relation.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/Relation.test.js b/tests/service/session/transaction/Relation.test.js index c5756a6cb..b343d5a35 100644 --- a/tests/service/session/transaction/Relation.test.js +++ b/tests/service/session/transaction/Relation.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/RelationType.test.js b/tests/service/session/transaction/RelationType.test.js index 84bf6b483..bfec3051d 100644 --- a/tests/service/session/transaction/RelationType.test.js +++ b/tests/service/session/transaction/RelationType.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/Role.test.js b/tests/service/session/transaction/Role.test.js index 1a902da53..3573d64a5 100644 --- a/tests/service/session/transaction/Role.test.js +++ b/tests/service/session/transaction/Role.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/Rule.test.js b/tests/service/session/transaction/Rule.test.js index 0cec2cfcb..e9fe83e26 100644 --- a/tests/service/session/transaction/Rule.test.js +++ b/tests/service/session/transaction/Rule.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/SchemaConcept.test.js b/tests/service/session/transaction/SchemaConcept.test.js index 6925e12fc..0fc584a97 100644 --- a/tests/service/session/transaction/SchemaConcept.test.js +++ b/tests/service/session/transaction/SchemaConcept.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/Thing.test.js b/tests/service/session/transaction/Thing.test.js index ae25f9844..a1f8eef47 100644 --- a/tests/service/session/transaction/Thing.test.js +++ b/tests/service/session/transaction/Thing.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/service/session/transaction/Type.test.js b/tests/service/session/transaction/Type.test.js index d2381ccfe..79e8e0cb8 100644 --- a/tests/service/session/transaction/Type.test.js +++ b/tests/service/session/transaction/Type.test.js @@ -30,7 +30,7 @@ afterAll(async () => { }); beforeEach(async () => { - tx = await session.transaction(env.txType().WRITE); + tx = await session.transaction().write(); }) afterEach(() => { diff --git a/tests/support/GraknTestEnvironment.js b/tests/support/GraknTestEnvironment.js index af68c49d6..b06f97402 100644 --- a/tests/support/GraknTestEnvironment.js +++ b/tests/support/GraknTestEnvironment.js @@ -46,6 +46,5 @@ module.exports = { graknClient.close(); }, dataType: () => GraknClient.dataType, - txType: () => GraknClient.txType, graknClient } \ No newline at end of file From b6bb263a9d78d251ec3836c8dbd89a7423db9d84 Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 16:37:07 +0000 Subject: [PATCH 7/8] trying to fix tests --- src/Session.js | 2 +- src/service/Session/SessionService.js | 4 +-- .../session/transaction/GraknTx.test.js | 28 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Session.js b/src/Session.js index ae8a2b9eb..6a7cd27c9 100644 --- a/src/Session.js +++ b/src/Session.js @@ -71,7 +71,7 @@ Session.prototype.transaction = function () { * Close stream connected to gRPC server */ Session.prototype.close = function close() { - this.sessionService.close(); + return this.sessionService.close(); } module.exports = Session; diff --git a/src/service/Session/SessionService.js b/src/service/Session/SessionService.js index bf536a039..af15b94a0 100644 --- a/src/service/Session/SessionService.js +++ b/src/service/Session/SessionService.js @@ -53,8 +53,8 @@ SessionService.prototype.transaction = async function create(txType) { /** * Closes connection to the server */ -SessionService.prototype.close = async function close() { - await wrapInPromise(this.client, this.client.close, RequestBuilder.closeSession(this.sessionId)); +SessionService.prototype.close = function close() { + return wrapInPromise(this.client, this.client.close, RequestBuilder.closeSession(this.sessionId)); } diff --git a/tests/service/session/transaction/GraknTx.test.js b/tests/service/session/transaction/GraknTx.test.js index 65df3b93f..174db278f 100644 --- a/tests/service/session/transaction/GraknTx.test.js +++ b/tests/service/session/transaction/GraknTx.test.js @@ -112,9 +112,9 @@ describe("Transaction methods", () => { expect(answer.list().includes(parentshipMap.child)).toBeTruthy(); expect(answer.list().includes(parentshipMap.parent)).toBeTruthy(); expect(answer.list().includes(parentshipMap.rel)).toBeTruthy(); - localTx.close(); - localSession.close(); - env.graknClient.keyspaces().delete('shortestpathks'); + await localTx.close(); + await localSession.close(); + await env.graknClient.keyspaces().delete('shortestpathks'); }); test("cluster connected components - Answer of conceptSet", async ()=>{ @@ -128,9 +128,9 @@ describe("Transaction methods", () => { expect(answer.set().has(parentshipMap.child)).toBeTruthy(); expect(answer.set().has(parentshipMap.parent)).toBeTruthy(); expect(answer.set().has(parentshipMap.rel)).toBeTruthy(); - localTx.close(); - localSession.close(); - env.graknClient.keyspaces().delete('clusterkeyspace'); + await localTx.close(); + await localSession.close(); + await env.graknClient.keyspaces().delete('clusterkeyspace'); }); test("compute centrality - Answer of conceptSetMeasure", async ()=>{ @@ -143,9 +143,9 @@ describe("Transaction methods", () => { expect(answer.measurement()).toBe(1); expect(answer.set().has(parentshipMap.child)).toBeTruthy(); expect(answer.set().has(parentshipMap.parent)).toBeTruthy(); - localTx.close(); - localSession.close(); - env.graknClient.keyspaces().delete('computecentralityks'); + await localTx.close(); + await localSession.close(); + await env.graknClient.keyspaces().delete('computecentralityks'); }); test("group query - Answer of answerGroup", async ()=>{ @@ -160,9 +160,9 @@ describe("Transaction methods", () => { expect(answer.answers()[0].map().get('x').id).toBe(parentshipMap.parent); expect(answer.answers()[0].map().get('y').id).toBe(parentshipMap.child); - localTx.close(); - localSession.close(); - env.graknClient.keyspaces().delete('groupks'); + await localTx.close(); + await localSession.close(); + await env.graknClient.keyspaces().delete('groupks'); }); @@ -172,8 +172,8 @@ describe("Transaction methods", () => { const personType = await tx.getSchemaConcept("person"); expect(personType.isSchemaConcept()).toBeTruthy(); - // const nonPerson = await tx.getSchemaConcept("not-existing-label"); - // expect(nonPerson).toBe(null); + const nonPerson = await tx.getSchemaConcept("not-existing-label"); + expect(nonPerson).toBe(null); }); From 3b87f7d7eae7036131c44e0cb2cd1dd7f072c839 Mon Sep 17 00:00:00 2001 From: Marco Scoppetta Date: Wed, 6 Mar 2019 17:00:19 +0000 Subject: [PATCH 8/8] remove vscode config --- .vscode/launch.json | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 89625a6f9..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Launch Program", - "program": "${workspaceFolder}/bazel", - "args": [ - "test", - "//test-integration", - "--test_output=streamed" - ], - "console": "integratedTerminal", -         "sourceMaps": true - } - ] -} \ No newline at end of file