metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmerri...@apache.org
Subject [metron] branch master updated: METRON-1958 Optimize Cypress to use best practices (sardell via merrimanr) closes apache/metron#1317
Date Thu, 03 Jan 2019 15:46:12 GMT
This is an automated email from the ASF dual-hosted git repository.

rmerriman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/metron.git


The following commit(s) were added to refs/heads/master by this push:
     new 74658e9  METRON-1958 Optimize Cypress to use best practices (sardell via merrimanr)
closes apache/metron#1317
74658e9 is described below

commit 74658e97a55aeac612a70689850d352d907adf96
Author: sardell <sardell@hortonworks.com>
AuthorDate: Thu Jan 3 09:40:57 2019 -0600

    METRON-1958 Optimize Cypress to use best practices (sardell via merrimanr) closes apache/metron#1317
---
 .../CURRENT/package/templates/alerts_ui.yml.j2     |  2 ++
 metron-interface/metron-alerts/alerts_ui.yml       |  2 ++
 .../{alerts_ui.yml => alerts_ui_cypress.yml}       |  6 ++--
 metron-interface/metron-alerts/cypress.json        |  3 +-
 .../cypress/integration/pcap/pcap.spec.js          | 38 ++++++++++++----------
 metron-interface/metron-alerts/package-lock.json   | 10 ++++++
 metron-interface/metron-alerts/package.json        |  6 ++--
 .../metron-alerts/scripts/alerts-server.js         |  6 ++--
 8 files changed, 48 insertions(+), 25 deletions(-)

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 a3e87cb..92a9510 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 4481fa9..343d883 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.yml b/metron-interface/metron-alerts/alerts_ui_cypress.yml
similarity index 95%
copy from metron-interface/metron-alerts/alerts_ui.yml
copy to metron-interface/metron-alerts/alerts_ui_cypress.yml
index 4481fa9..ddf663a 100644
--- a/metron-interface/metron-alerts/alerts_ui.yml
+++ b/metron-interface/metron-alerts/alerts_ui_cypress.yml
@@ -14,8 +14,10 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 #
-port: 4201
+port: 4200
 
 rest:
   host: localhost
-  port: 8080
+  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 7c0410d..da8aafb 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 58f7d26..835c714 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 f80f72b..3c11822 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 deb5ecf..c63c1fc 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 716f37b..e700dd1 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(){


Mime
View raw message