You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metron.apache.org by GitBox <gi...@apache.org> on 2019/01/03 15:46:24 UTC

[GitHub] asfgit closed pull request #1317: METRON-1958: Optimize Cypress to use best practices

asfgit closed pull request #1317: METRON-1958: Optimize Cypress to use best practices
URL: https://github.com/apache/metron/pull/1317
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/templates/alerts_ui.yml.j2 b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/templates/alerts_ui.yml.j2
index a3e87cb7b8..92a951016b 100644
--- a/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/templates/alerts_ui.yml.j2
+++ b/metron-deployment/packaging/ambari/metron-mpack/src/main/resources/common-services/METRON/CURRENT/package/templates/alerts_ui.yml.j2
@@ -21,3 +21,5 @@ port: {{metron_alerts_ui_port}}
 rest:
   host: {{metron_rest_host}}
   port: {{metron_rest_port}}
+
+dirPath: alerts-ui
diff --git a/metron-interface/metron-alerts/alerts_ui.yml b/metron-interface/metron-alerts/alerts_ui.yml
index 4481fa96ba..343d8834d8 100644
--- a/metron-interface/metron-alerts/alerts_ui.yml
+++ b/metron-interface/metron-alerts/alerts_ui.yml
@@ -19,3 +19,5 @@ port: 4201
 rest:
   host: localhost
   port: 8080
+
+dirPath: alerts-ui
\ No newline at end of file
diff --git a/metron-interface/metron-alerts/alerts_ui_cypress.yml b/metron-interface/metron-alerts/alerts_ui_cypress.yml
new file mode 100644
index 0000000000..ddf663a9ba
--- /dev/null
+++ b/metron-interface/metron-alerts/alerts_ui_cypress.yml
@@ -0,0 +1,23 @@
+#
+#  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.
+#
+port: 4200
+
+rest:
+  host: localhost
+  port: 4200
+
+dirPath: dist
\ No newline at end of file
diff --git a/metron-interface/metron-alerts/cypress.json b/metron-interface/metron-alerts/cypress.json
index 7c0410d245..da8aafbb95 100644
--- a/metron-interface/metron-alerts/cypress.json
+++ b/metron-interface/metron-alerts/cypress.json
@@ -3,5 +3,6 @@
   "viewportHeight": 850,
   "video": false,
   "supportFile": false,
-  "pluginsFile": false
+  "pluginsFile": false,
+  "baseUrl": "http://localhost:4200"
 }
\ No newline at end of file
diff --git a/metron-interface/metron-alerts/cypress/integration/pcap/pcap.spec.js b/metron-interface/metron-alerts/cypress/integration/pcap/pcap.spec.js
index 58f7d26b41..835c714dea 100644
--- a/metron-interface/metron-alerts/cypress/integration/pcap/pcap.spec.js
+++ b/metron-interface/metron-alerts/cypress/integration/pcap/pcap.spec.js
@@ -25,8 +25,13 @@ context('PCAP Tab', () => {
       url: '/api/v1/user',
       response: 'user'
     });
+    cy.route({
+      method: 'POST',
+      url: 'logout',
+      response: []
+    });
 
-    cy.route('GET', 'config', 'fixture:config.json');
+    cy.route('GET', '/api/v1/global/config', 'fixture:config.json');
     cy.route('POST', 'search', 'fixture:search.json');
 
     cy.route({
@@ -34,15 +39,14 @@ context('PCAP Tab', () => {
       url: '/api/v1/pcap?state=*',
       response: []
     }).as('runningJobs');
-    
-    cy.visit('http://localhost:4200/login');
+
+    cy.visit('login');
     cy.get('[name="user"]').type('user');
     cy.get('[name="password"]').type('password');
     cy.contains('LOG IN').click();
   });
 
   afterEach(() => {
-    cy.get('.logout-link').click();
   });
 
   it('checking running jobs on navigating to PCAP tab', () => {
@@ -62,7 +66,7 @@ context('PCAP Tab', () => {
     cy.get('[data-qe-id="protocol"]').type('24');
     cy.get('[data-qe-id="include-reverse"]').check();
     cy.get('[data-qe-id="packet-filter"]').type('filter');
-    
+
     cy.get('[data-qe-id="submit-button"]').click();
 
     cy.wait('@postingPcapJob').then((xhr) => {
@@ -82,7 +86,7 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@jobStatusCheck').its('url').should('include', '/api/v1/pcap/job_1537878471649_0001');
   });
 
@@ -92,7 +96,7 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@jobStatusCheck');
 
     cy.contains('75%').should('be.visible');
@@ -105,7 +109,7 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@statusCheck');
 
     cy.wait('@gettingPdml').its('url').should('include', '/api/v1/pcap/job_1537878471649_0001/pdml?page=1');
@@ -119,7 +123,7 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@statusCheck');
 
     cy.wait('@gettingPdml');
@@ -135,7 +139,7 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@statusCheck');
     cy.wait('@gettingPdml');
 
@@ -143,7 +147,7 @@ context('PCAP Tab', () => {
     cy.contains('General information').should('not.be.visible');
 
     cy.get(':nth-child(3) > .timestamp').click();
-    
+
     cy.contains('General information').should('be.visible');
     cy.get('[data-qe-id="proto"]').should('have.length', 6);
   });
@@ -155,12 +159,12 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@statusCheck');
     cy.wait('@gettingPdml');
 
     cy.contains('Page 1 of 2').should('be.visible');
-    
+
     cy.get('.fa-chevron-right').click();
 
     cy.wait('@gettingPdml').its('url').should('include', '?page=2');
@@ -174,7 +178,7 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@statusCheck');
     cy.wait('@gettingPdml');
 
@@ -194,7 +198,7 @@ context('PCAP Tab', () => {
 
     cy.contains('PCAP').click();
     cy.get('[data-qe-id="submit-button"]').click();
-    
+
     cy.wait('@jobStatusCheck');
 
     cy.get('[data-qe-id="pcap-cancel-query-button"]').click();
@@ -210,7 +214,7 @@ context('PCAP Tab', () => {
     cy.get('[data-qe-id="ip-dst-addr"]').type('ccc.ddd.222.000');
     cy.get('[data-qe-id="ip-src-port"]').type('99999');
     cy.get('[data-qe-id="ip-dst-port"]').type('aaaa');
-    
+
     cy.get('.pcap-search-validation-errors').should('be.visible');
     cy.get('.pcap-search-validation-errors li').should('have.length', 4);
   });
@@ -221,7 +225,7 @@ context('PCAP Tab', () => {
     cy.get('[data-qe-id="end-time"]').click();
     cy.get('.pika-select-year').select('2015');
     cy.get('[data-day="11"] > .pika-button').click();
-    
+
     cy.get('.pcap-search-validation-errors').should('be.visible');
     cy.get('.pcap-search-validation-errors li').should('have.length', 1);
   });
diff --git a/metron-interface/metron-alerts/package-lock.json b/metron-interface/metron-alerts/package-lock.json
index f80f72bbb1..3c118222c4 100644
--- a/metron-interface/metron-alerts/package-lock.json
+++ b/metron-interface/metron-alerts/package-lock.json
@@ -20591,6 +20591,16 @@
       "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
       "dev": true
     },
+    "yamljs": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/yamljs/-/yamljs-0.3.0.tgz",
+      "integrity": "sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==",
+      "dev": true,
+      "requires": {
+        "argparse": "^1.0.7",
+        "glob": "^7.0.5"
+      }
+    },
     "yargs": {
       "version": "7.1.0",
       "resolved": "https://registry.npmjs.org/yargs/-/yargs-7.1.0.tgz",
diff --git a/metron-interface/metron-alerts/package.json b/metron-interface/metron-alerts/package.json
index deb5ecf638..c63c1fc804 100644
--- a/metron-interface/metron-alerts/package.json
+++ b/metron-interface/metron-alerts/package.json
@@ -13,7 +13,8 @@
     "e2e": "protractor-flake --protractor-path=./node_modules/.bin/protractor --max-attempts=3 -- ./protractor.conf.js",
     "cypress:run": "cypress run",
     "cypress:open": "cypress open",
-    "cypress:ci": "run-p --race start cypress:run"
+    "cypress:ci": "ng build --prod && run-p --race start:ci cypress:run",
+    "start:ci": "node ./scripts/alerts-server.js -c alerts_ui_cypress.yml"
   },
   "private": true,
   "dependencies": {
@@ -75,6 +76,7 @@
     "serve-static": "^1.13.2",
     "ssh2": "^0.5.5",
     "tslint": "~5.0.0",
-    "typescript": "~2.9.2"
+    "typescript": "~2.9.2",
+    "yamljs": "^0.3.0"
   }
 }
diff --git a/metron-interface/metron-alerts/scripts/alerts-server.js b/metron-interface/metron-alerts/scripts/alerts-server.js
index 716f37b4cd..e700dd1065 100644
--- a/metron-interface/metron-alerts/scripts/alerts-server.js
+++ b/metron-interface/metron-alerts/scripts/alerts-server.js
@@ -60,15 +60,15 @@ var restUrl = 'http://' + uiConfig.rest.host + ':' + uiConfig.rest.port;
 app.use('/api/v1', proxy(restUrl));
 app.use('/logout', proxy(restUrl));
 
-app.use(favicon(path.join(__dirname, '../alerts-ui/favicon.ico')));
+app.use(favicon(path.join(__dirname, '../' + uiConfig.dirPath + '/favicon.ico')));
 
-app.use(serveStatic(path.join(__dirname, '../alerts-ui'), {
+app.use(serveStatic(path.join(__dirname, '../' + uiConfig.dirPath), {
   maxAge: '1d',
   setHeaders: setCustomCacheControl
 }));
 
 app.get('*', function(req, res){
-  res.sendFile(path.join(__dirname, '../alerts-ui/index.html'));
+  res.sendFile(path.join(__dirname, '../' + uiConfig.dirPath + '/index.html'));
 });
 
 app.listen(uiConfig.port, function(){


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services