Fix for BDD multiple servers 49/44649/1
authorilanap <ilanap@amdocs.com>
Wed, 25 Apr 2018 10:39:19 +0000 (13:39 +0300)
committerilanap <ilanap@amdocs.com>
Wed, 25 Apr 2018 10:39:19 +0000 (13:39 +0300)
Change-Id: Ibfc9813e471d4ac2509ee5e62828a07661cc704e
Issue-ID: SDC-1262
Signed-off-by: ilanap <ilanap@amdocs.com>
openecomp-bdd/.gitignore
openecomp-bdd/config.json
openecomp-bdd/plugins/README.md
openecomp-bdd/pom.xml
openecomp-bdd/resources/jenkinsConfig.json [new file with mode: 0644]
openecomp-bdd/stepDefinitions/Collaboration_Steps.js
openecomp-bdd/stepDefinitions/Utils.js
openecomp-bdd/stepDefinitions/VF_steps.js
openecomp-bdd/stepDefinitions/world.js

index ce33f66..316e398 100644 (file)
@@ -8,3 +8,4 @@ node_modules
 .npmrc
 npm-debug.log
 devConfig.json
+jenkinsConfig.json
index e1907a2..c28bc9d 100644 (file)
@@ -3,14 +3,20 @@
 
   "onboarding" : {
     "port" : 8285,
-    "prefix" : "sdc1/feProxy/onboarding-api/v1.0"
+    "prefix" : "sdc1/feProxy/onboarding-api/v1.0",
+    "server" : "onboarding.server",
+    "user" : "user"
   },
   "vf" : {
     "port" : 8285,
-    "prefix" : "sdc1/feProxy/rest/v1"
+    "prefix" : "sdc1/feProxy/rest/v1",
+    "server" : "vf.server",
+    "user" : "user"
   },
   "activity_spec" : {
     "port" : 8080,
-    "prefix" : "activity-spec-api/v1.0"
+    "prefix" : "activity-spec-api/v1.0",
+    "server" : "activity_spec.server",
+    "user" : "user"
   }
-}
\ No newline at end of file
+}
index 118e029..956fe77 100644 (file)
@@ -3,13 +3,9 @@
 This is the documentation for using the BDD testing framework for SDC.<br>
 The Modules on the left contains all steps for particalar aress and/or explanations of what they do.<br>
 <br><br>
-<h3>How to set the server</h3>
-<li> Create a "devConfig.json" file under the openecomp-bdd directory with the following content and replace the placeholders:
-{
-  "server": "[YOUR_SERVER]",
-  "user": "[USER_ID_FOR_APPLICATION]"
-}
-<li> Or set the SERVER and USER environment variables and it will override the configuration file
+<h3>How to set the server configuration</h3>
+<li> Copy the config.json to devConfig.json
+<li> Replace the server and user values with the correct values
 <h3>How to run with Maven</h3>
 <li>"mvn install" will install npm if needed, download all modules and create the documentation under the "docs" folder
 <li>"mvn test-and-report" will run all  tests in the features folder and create an HTML report under the "reports" folder
index 69eadf3..e73bb69 100644 (file)
                                   <include>**/*</include>
                                 </includes>
                               </fileset>
+                                <fileset>
+                                    <directory>${basedir}</directory>
+                                    <includes>
+                                        <include>jenkinsConfig.json</include>
+                                    </includes>
+                                </fileset>
+
                             </filesets>
                         </configuration>
                     </execution>
                 </executions>
             </plugin>
 
+            <plugin>
+                <artifactId>maven-resources-plugin</artifactId>
+                <version>2.6</version>
+                <executions>
+                    <execution>
+                        <id>copy-config</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${basedir}</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>${basedir}/resources</directory>
+                                    <includes>
+                                        <include>jenkinsConfig.json</include>
+                                    </includes>
+                                    <filtering>true</filtering>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
         </plugins>
     </build>
 
diff --git a/openecomp-bdd/resources/jenkinsConfig.json b/openecomp-bdd/resources/jenkinsConfig.json
new file mode 100644 (file)
index 0000000..02ae0da
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "onboarding" : {
+    "user": "${onboardingUser}",
+    "server": "${onboardingServer}"
+  },
+  "vf" : {
+    "user": "${vfUser}",
+    "server": "${vfServer}"
+  },
+  "activity_spec" : {
+    "user": "${activitySpecUser}",
+    "server": "${activitySpecServer}"
+  }
+}
index 5b5062c..c4de758 100644 (file)
@@ -109,5 +109,5 @@ When('I want to get the permissions for this Item', function()  {
  * @step I want to set the user to {string}
  **/
 When('I want to set the user to {string}', function(string)  {
-       this.context.headers.USER_ID = string;
+       this.context.headers['onboarding'].USER_ID = string;
 });
index 4653407..66e959f 100644 (file)
@@ -23,7 +23,7 @@ function _request(context, method, path, data, isBinary=false, type='onboarding'
        let options = {
                method: method,
                url: server + path,
-               headers: context.headers
+               headers: context.headers[type]
        };
        console.log('--> Calling REST ' + options.method +' url: ' + options.url);
 
@@ -106,7 +106,7 @@ function download(context, path, filePath,  callback, type='onboarding') {
        let options = {
                        method: 'GET',
                        url: server + path,
-                       headers: context.headers
+                       headers: context.headers[type]
                };
        console.log('--> Calling REST download url: ' + options.url);
 
index 268c371..3411a25 100644 (file)
@@ -29,7 +29,7 @@ Then('I want to create a VF for this Item', function () {
        return util.request(this.context, 'GET', '/vendor-software-products/' + this.context.item.id + '/versions/' + this.context.item.versionId).then(result => {
                this.context.inputData = util.getJSONFromFile('resources/json/createVF.json');
                // start replacing stuff
-               this.context.inputData.contactId = this.context.headers["USER_ID"];
+               this.context.inputData.contactId = this.context.headers['vf']["USER_ID"];
                this.context.inputData.categories[0].uniqueId = result.data.category;
                this.context.inputData.categories[0].subcategories[0].uniqueId = result.data.subCategory;
                this.context.inputData.description = result.data.description;
index 75f93af..0ffcc8e 100644 (file)
  * limitations under the License.
  */
 const { setWorldConstructor } = require('cucumber');
-const config = require('../config.json');
-let localDevConfig = {};
+const _ = require('lodash');
+
+let config = require('../config.json');
+let localConfig = {};
 try {
-       localDevConfig = require('../devConfig.json');
-} catch (e) {}
+       localConfig = require('../devConfig.json');
+} catch (e) {
+       try {
+               localConfig = require('../jenkinsConfig.json');
+       } catch (e) {
+               console.error("no env configuration was found!");
+       }
+}
+
+config = _.merge(config, localConfig);
 var {setDefaultTimeout} = require('cucumber');
 
+
 /**
  * @module Context
  * @description Context that is used per feature file and can be accessed as 'this.context' in all steps.<Br>
@@ -38,15 +49,12 @@ class CustomWorld {
        constructor(options) {
                this.context = {};
                this.context.headers = {};
-               if (localDevConfig.user) {
-                       this.context.headers['USER_ID'] = localDevConfig.user;
-               } else {
-                       this.context.headers['USER_ID'] = process.env.USER;
-               }
-               if (localDevConfig.server) {
-                       this.context.server = localDevConfig.server;
-               } else {
-                       this.context.server = process.env.SERVER;
+               let typeName;
+               for (typeName in config) {
+                       this.context.headers[typeName] = {};
+                       if (config[typeName].user) {
+                               this.context.headers[typeName]['USER_ID'] = config[typeName].user;
+                       }
                }
 
                this.context.vlm = {id: null, versionId: null};
@@ -69,7 +77,7 @@ class CustomWorld {
                        return function(type) {
                                let typeData = _config[type];
                                let _url = _config.protocol + '://' +
-                                       _server + ':' +
+                                       typeData.server + ':' +
                                        typeData.port + '/' +
                                        typeData.prefix;
                                return _url;