examples executors

Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/671af04b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/671af04b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/671af04b

Branch: refs/heads/ignite-7777
Commit: 671af04bafcc2bab4b7456d170ad54f2f3f15fde
Parents: 2c39948
Author: ekaterina-nbl <[email protected]>
Authored: Sat May 19 00:55:49 2018 +0300
Committer: ekaterina-nbl <[email protected]>
Committed: Sat May 19 00:55:49 2018 +0300

----------------------------------------------------------------------
 .../platforms/nodejs/examples/AuthTlsExample.js |  8 ++--
 .../nodejs/examples/CachePutGetExample.js       |  2 +-
 modules/platforms/nodejs/examples/SqlExample.js |  2 +-
 .../nodejs/examples/SqlQueryEntriesExample.js   |  2 +-
 modules/platforms/nodejs/package.json           |  4 +-
 .../platforms/nodejs/spec/ExamplesExecutor.js   | 11 ++++++
 modules/platforms/nodejs/spec/TestingHelper.js  | 14 +++++++
 .../nodejs/spec/examples/AuthExample.spec.js    | 28 ++++++++++++++
 .../nodejs/spec/examples/Examples.spec.js       | 40 ++++++++++++++++++++
 .../platforms/nodejs/spec/support/jasmine.json  |  3 +-
 10 files changed, 105 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/examples/AuthTlsExample.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/examples/AuthTlsExample.js 
b/modules/platforms/nodejs/examples/AuthTlsExample.js
index 4c958e0..b47df61 100644
--- a/modules/platforms/nodejs/examples/AuthTlsExample.js
+++ b/modules/platforms/nodejs/examples/AuthTlsExample.js
@@ -28,9 +28,9 @@ const ENDPOINT = 'localhost:10800';
 const USER_NAME = 'ignite';
 const PASSWORD = 'ignite';
 
-const TLS_KEY_FILE_NAME = './certs/client.key';
-const TLS_CERT_FILE_NAME = './certs/client.crt';
-const TLS_CA_FILE_NAME = './certs/ca.crt';
+const TLS_KEY_FILE_NAME = __dirname + '/certs/client.key';
+const TLS_CERT_FILE_NAME = __dirname + '/certs/client.crt';
+const TLS_CA_FILE_NAME = __dirname + '/certs/ca.crt';
 
 const CACHE_NAME = 'AuthTlsExample_cache';
 
@@ -66,7 +66,7 @@ class AuthTlsExample {
             await igniteClient.destroyCache(CACHE_NAME);
         }
         catch (err) {
-            console.log(err.message);
+            console.log('ERROR: ' + err.message);
         }
         finally {
             igniteClient.disconnect();

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/examples/CachePutGetExample.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/examples/CachePutGetExample.js 
b/modules/platforms/nodejs/examples/CachePutGetExample.js
index 8ea642e..94060bd 100644
--- a/modules/platforms/nodejs/examples/CachePutGetExample.js
+++ b/modules/platforms/nodejs/examples/CachePutGetExample.js
@@ -91,7 +91,7 @@ class CachePutGetExample {
             await igniteClient.destroyCache(CACHE_NAME);
         }
         catch (err) {
-            console.log(err.message);
+            console.log('ERROR: ' + err.message);
         }
         finally {
             igniteClient.disconnect();

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/examples/SqlExample.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/examples/SqlExample.js 
b/modules/platforms/nodejs/examples/SqlExample.js
index 3d47d55..92f59d7 100644
--- a/modules/platforms/nodejs/examples/SqlExample.js
+++ b/modules/platforms/nodejs/examples/SqlExample.js
@@ -63,7 +63,7 @@ class SqlExample {
             await igniteClient.destroyCache(DUMMY_CACHE_NAME);
         }
         catch (err) {
-            console.log(err.message);
+            console.log('ERROR: ' + err.message);
         }
         finally {
             igniteClient.disconnect();

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js 
b/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js
index 43eaad3..ecbcbd5 100644
--- a/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js
+++ b/modules/platforms/nodejs/examples/SqlQueryEntriesExample.js
@@ -96,7 +96,7 @@ class SqlQueryEntriesExample {
             await igniteClient.destroyCache(PERSON_CACHE_NAME);
         }
         catch (err) {
-            console.log(err.message);
+            console.log('ERROR: ' + err.message);
         }
         finally {
             igniteClient.disconnect();

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/package.json
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/package.json 
b/modules/platforms/nodejs/package.json
index 41a29ca..4ffb809 100644
--- a/modules/platforms/nodejs/package.json
+++ b/modules/platforms/nodejs/package.json
@@ -13,7 +13,9 @@
     "decimal.js": "latest"
   },
   "scripts": {
-    "test": "jasmine"
+    "test": "jasmine",
+    "test:examples": "node ./spec/ExamplesExecutor.js Examples",
+    "test:auth_example": "node ./spec/ExamplesExecutor.js AuthExample"
   },
   "devDependencies": {
     "jasmine": "latest",

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/spec/ExamplesExecutor.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/ExamplesExecutor.js 
b/modules/platforms/nodejs/spec/ExamplesExecutor.js
new file mode 100644
index 0000000..7f263d9
--- /dev/null
+++ b/modules/platforms/nodejs/spec/ExamplesExecutor.js
@@ -0,0 +1,11 @@
+const Jasmine = require('jasmine');
+
+const jasmine = new Jasmine();
+jasmine.loadConfig({
+    'spec_dir': 'spec',
+    'spec_files': [
+        `examples/${process.argv[2]}.spec.js`
+    ],
+    "random": false
+});
+jasmine.execute();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/spec/TestingHelper.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/TestingHelper.js 
b/modules/platforms/nodejs/spec/TestingHelper.js
index 88edffc..b8e5003 100644
--- a/modules/platforms/nodejs/spec/TestingHelper.js
+++ b/modules/platforms/nodejs/spec/TestingHelper.js
@@ -21,6 +21,7 @@ require('jasmine-expect');
 const JasmineReporters = require('jasmine-reporters');
 
 const Util = require('util');
+const exec = require('child_process').exec;
 const config = require('./config');
 const IgniteClient = require('apache-ignite-client');
 const IgniteClientConfiguration = IgniteClient.IgniteClientConfiguration;
@@ -210,6 +211,19 @@ class TestingHelper {
         }
     }
 
+    static executeExample(name, outputChecker) {
+        return new Promise((resolve, reject) => {
+                exec('node ' + name, (error, stdout, stderr) => {
+                    TestingHelper.logDebug(stdout);
+                    resolve(stdout);
+                })
+            }).
+            then(output => {
+                expect(output).not.toMatch('ERROR:');
+                expect(output).toMatch('Client is started');
+            });
+    }
+
     static checkOperationError(error, done) {
         TestingHelper.checkError(error, Errors.OperationError, done)
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/spec/examples/AuthExample.spec.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/examples/AuthExample.spec.js 
b/modules/platforms/nodejs/spec/examples/AuthExample.spec.js
new file mode 100644
index 0000000..3fb9205
--- /dev/null
+++ b/modules/platforms/nodejs/spec/examples/AuthExample.spec.js
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+const TestingHelper = require('../TestingHelper');
+
+describe('execute auth example >', () => {
+    it('AuthTlsExample', (done) => {
+        TestingHelper.executeExample('examples/AuthTlsExample.js').
+            then(done).
+            catch(error => done.fail(error));
+    });
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/spec/examples/Examples.spec.js
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/examples/Examples.spec.js 
b/modules/platforms/nodejs/spec/examples/Examples.spec.js
new file mode 100644
index 0000000..c8dce3c
--- /dev/null
+++ b/modules/platforms/nodejs/spec/examples/Examples.spec.js
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+const TestingHelper = require('../TestingHelper');
+
+describe('execute examples >', () => {
+    it('CachePutGetExample', (done) => {
+        TestingHelper.executeExample('examples/CachePutGetExample.js').
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('SqlExample', (done) => {
+        TestingHelper.executeExample('examples/SqlExample.js').
+            then(done).
+            catch(error => done.fail(error));
+    });
+
+    it('SqlQueryEntriesExample', (done) => {
+        TestingHelper.executeExample('examples/SqlQueryEntriesExample.js').
+            then(done).
+            catch(error => done.fail(error));
+    });
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/671af04b/modules/platforms/nodejs/spec/support/jasmine.json
----------------------------------------------------------------------
diff --git a/modules/platforms/nodejs/spec/support/jasmine.json 
b/modules/platforms/nodejs/spec/support/jasmine.json
index 01d30e2..8ba68ba 100644
--- a/modules/platforms/nodejs/spec/support/jasmine.json
+++ b/modules/platforms/nodejs/spec/support/jasmine.json
@@ -1,7 +1,8 @@
 {
   "spec_dir": "spec",
   "spec_files": [
-    "**/*[sS]pec.js"
+    "cache/**/*[sS]pec.js",
+    "query/**/*[sS]pec.js"
   ],
   "helpers": [
     "helpers/**/*.js"

Reply via email to