You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by be...@apache.org on 2017/06/27 18:50:23 UTC

[incubator-openwhisk-package-cloudant] branch master updated: Add HOST_MACHINE and HOST_INDEX env vars (remove ACTIVE) (#106)

This is an automated email from the ASF dual-hosted git repository.

berstler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-cloudant.git


The following commit(s) were added to refs/heads/master by this push:
     new 5b58923  Add HOST_MACHINE and HOST_INDEX env vars (remove ACTIVE) (#106)
5b58923 is described below

commit 5b58923785f2818feb2523ef8426d8b3246333ae
Author: Jason Peterson <ja...@us.ibm.com>
AuthorDate: Tue Jun 27 14:50:21 2017 -0400

    Add HOST_MACHINE and HOST_INDEX env vars (remove ACTIVE) (#106)
---
 provider/lib/active.js                                            | 5 ++---
 provider/lib/utils.js                                             | 6 +++---
 .../test/scala/system/redundancy/CloudantRedundancyTests.scala    | 8 ++++----
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/provider/lib/active.js b/provider/lib/active.js
index be9ee88..66efdcd 100644
--- a/provider/lib/active.js
+++ b/provider/lib/active.js
@@ -9,6 +9,7 @@ module.exports = function(logger, utils) {
         var response = {
             worker: utils.worker,
             host: utils.host,
+            hostMachine: utils.hostMachine,
             active: utils.host === utils.activeHost
         };
 
@@ -29,9 +30,7 @@ module.exports = function(logger, utils) {
                     .then(() => {
                         response.active = 'swapping';
                         utils.redisClient.publish(utils.redisHash, activeHost);
-                        var msg = 'Active host swap in progress';
-                        logger.info(method, msg);
-                        response.message = msg;
+                        logger.info(method, 'Active host swap in progress');
                         res.send(response);
                     })
                     .catch(err => {
diff --git a/provider/lib/utils.js b/provider/lib/utils.js
index e184f4d..b31d84a 100644
--- a/provider/lib/utils.js
+++ b/provider/lib/utils.js
@@ -1,7 +1,7 @@
 var _ = require('lodash');
 var request = require('request');
-var constants = require('./constants.js');
 var HttpStatus = require('http-status-codes');
+var constants = require('./constants.js');
 
 module.exports = function(
   logger,
@@ -13,7 +13,8 @@ module.exports = function(
     this.endpointAuth = process.env.ENDPOINT_AUTH;
     this.routerHost = process.env.ROUTER_HOST || 'localhost';
     this.worker = process.env.WORKER || "worker0";
-    this.host = process.env.ACTIVE !== undefined && process.env.ACTIVE.toLowerCase() === 'false' ? 'host1' : 'host0';
+    this.host = process.env.HOST_INDEX || 'host0';
+    this.hostMachine = process.env.HOST_MACHINE;
     this.activeHost = 'host0'; //default value on init (will be updated for existing redis)
     this.redisClient = redisClient;
     this.redisHash = triggerDB.config.db + '_' + this.worker;
@@ -22,7 +23,6 @@ module.exports = function(
     var retryAttempts = constants.RETRY_ATTEMPTS;
     var ddname = constants.DESIGN_DOC_NAME;
     var filter = constants.FILTER_FUNCTION;
-
     var utils = this;
 
     // Add a trigger: listen for changes and dispatch.
diff --git a/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala b/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala
index 5279d8d..2c13b9e 100644
--- a/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala
+++ b/tests/src/test/scala/system/redundancy/CloudantRedundancyTests.scala
@@ -28,8 +28,8 @@ import system.CloudantUtil
 /**
  * These tests verify that a cloudant redundancy (master/slave) configuration
  * works as expected.  They will only run properly in an environment with two
- * cloudant containers running concurrently and env var ACTIVE set to true in
- * one container and false in the other.  This test also assumes that redis and
+ * cloudant containers running concurrently and env var HOST_INDEX set to host0 in
+ * one container and host1 in the other.  This test also assumes that redis and
  * the active endpoint authorization are configured.  For the auth set the
  * ENDPOINT_AUTH env var in your containers to match the testing.auth property
  * found in your whisk.properties.  To configure redis simply set the REDIS_URL
@@ -46,7 +46,7 @@ class CloudantRedundancyTests
     val wskprops = WskProps()
     val wsk = new Wsk
     val myCloudantCreds = CloudantUtil.Credential.makeFromVCAPFile("cloudantNoSQLDB", this.getClass.getSimpleName)
-    var edgeHost = WhiskProperties.getEdgeHost()
+    var edgeHost = WhiskProperties.getEdgeHost
     val auth = WhiskProperties.getBasicAuth
     val user = auth.fst
     val password = auth.snd
@@ -182,7 +182,7 @@ class CloudantRedundancyTests
                 get(endpointURL)
         assert(response.statusCode() == 200)
         var result = response.body.asString.parseJson.asJsObject
-        JsObject(result.fields - "message") shouldBe expectedResult
+        JsObject(result.fields - "hostMachine") shouldBe expectedResult
     }
 
     override def afterAll() {

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].