Pārlūkot izejas kodu

[bitnami/rabbitmq] Add RabbitMQ Helm Chart tests (#10102)

* Added antiflake pipeline

Signed-off-by: alukic <alukic@vmware.com>

* Diversified the pipeline

Signed-off-by: alukic <alukic@vmware.com>

* Make a change to trigger TKG

Signed-off-by: alukic <alukic@vmware.com>

* Replaced FIPS with normal AKS

Signed-off-by: alukic <alukic@vmware.com>

* Added Cypress tests. Goss tests still in progress

Signed-off-by: alukic <alukic@vmware.com>

* Changed runtime parameters to contain common user/pass'

Signed-off-by: alukic <alukic@vmware.com>

* Added changes to trigger VIB

Signed-off-by: alukic <alukic@vmware.com>

* Added Goss to the pipeline

Signed-off-by: alukic <alukic@vmware.com>

* Added 5 goss tests as well

Signed-off-by: alukic <alukic@vmware.com>

* Modify failing Goss test

Signed-off-by: alukic <alukic@vmware.com>

* Removed test pipeline

Signed-off-by: alukic <alukic@vmware.com>

* Removed extra files and spaces

Signed-off-by: alukic <alukic@vmware.com>

* Linter

Signed-off-by: alukic <alukic@vmware.com>

* Application name added to const

Signed-off-by: alukic <alukic@vmware.com>

* Handling flakiness by increasing command delay

Signed-off-by: alukic <alukic@vmware.com>

* Increased environment size and page load timeout

Signed-off-by: alukic <alukic@vmware.com>

* Log out test

Signed-off-by: alukic <alukic@vmware.com>

* Increased pageLoadtimeout a bit more, added a reload for the logout test

Signed-off-by: alukic <alukic@vmware.com>

* Undo changes that only belong to a fork

Signed-off-by: alukic <alukic@vmware.com>

* Fixing logout flakiness

Signed-off-by: alukic <alukic@vmware.com>

* Remove the reload

Signed-off-by: alukic <alukic@vmware.com>

* Fix a typo

Signed-off-by: alukic <alukic@vmware.com>

* Fixed a typo

Signed-off-by: alukic <alukic@vmware.com>

* Increased click delay and added additional assert for logout test

Signed-off-by: alukic <alukic@vmware.com>

* Addressing flakiness

Signed-off-by: alukic <alukic@vmware.com>

* Removing extra test data

Signed-off-by: alukic <alukic@vmware.com>

* Improved add exchange button for flakiness

Signed-off-by: alukic <alukic@vmware.com>

* Applied regex for versions

Signed-off-by: alukic <alukic@vmware.com>

* Wording

Signed-off-by: alukic <alukic@vmware.com>

* Improved Goss test, wording

Signed-off-by: alukic <alukic@vmware.com>

* Improved the second logint test as per CR

Signed-off-by: alukic <alukic@vmware.com>

* Improved table locator

Signed-off-by: alukic <alukic@vmware.com>

* Improved test name

Signed-off-by: alukic <alukic@vmware.com>

* Applied contains selector

Signed-off-by: alukic <alukic@vmware.com>

* Increased the timeout some more

Signed-off-by: alukic <alukic@vmware.com>

* Antiflake improvements

Signed-off-by: alukic <alukic@vmware.com>

* Decreased click delay, improved log out

Signed-off-by: alukic <alukic@vmware.com>

* Changed the size of the cluster

Signed-off-by: alukic <alukic@vmware.com>

* Improved the Regex as per PR suggestion

Signed-off-by: alukic <alukic@vmware.com>

* Adjunst runtime params and size

Signed-off-by: alukic <alukic@vmware.com>

* Added the right actions to publish pipeline

Signed-off-by: alukic <alukic@vmware.com>
superaleks 3 gadi atpakaļ
vecāks
revīzija
37a4389050

+ 9 - 0
.vib/rabbitmq/cypress/cypress.json

@@ -0,0 +1,9 @@
+{
+  "baseUrl": "http://localhost",
+  "pageLoadTimeout": 500000,
+  "defaultCommandTimeout": 90000,
+  "env": {
+    "username": "user",
+    "password": "ComplicatedPassword123!4"
+  }
+}

+ 7 - 0
.vib/rabbitmq/cypress/cypress/fixtures/admins.json

@@ -0,0 +1,7 @@
+{
+  "newAdmin": {
+    "userName": "Jane Doe Dev",
+    "password": "JanesSecurePassword",
+    "tags": "administrator"
+  }
+}

+ 1 - 0
.vib/rabbitmq/cypress/cypress/fixtures/broker-definitions.json

@@ -0,0 +1 @@
+{}

+ 7 - 0
.vib/rabbitmq/cypress/cypress/fixtures/exchanges.json

@@ -0,0 +1,7 @@
+{
+  "newExchange": {
+    "name": "testExchange",
+    "argument1": "A",
+    "argument2": "B"
+  }
+}

+ 5 - 0
.vib/rabbitmq/cypress/cypress/fixtures/messages.json

@@ -0,0 +1,5 @@
+{
+  "newMessage": {
+    "payload": "This is my first message"
+  }
+}

+ 7 - 0
.vib/rabbitmq/cypress/cypress/fixtures/queues.json

@@ -0,0 +1,7 @@
+{
+  "newQueue": {
+    "name": "testQue",
+    "argument1": "A",
+    "argument2": "B"
+  }
+}

+ 109 - 0
.vib/rabbitmq/cypress/cypress/integration/rabbitmq_spec.js

@@ -0,0 +1,109 @@
+/// <reference types="cypress" />
+import { random } from './utils';
+
+it('allows login/logout', () => {
+  cy.login();
+  cy.get('#versions')
+    .invoke('text')
+    .should('match', /RabbitMQ.*\d+\.\d+\.\d+/);
+  cy.contains('RabbitMQ Management');
+  cy.contains('Log out').click();
+  cy.contains('#login', 'Username');
+});
+
+it('allows uploading broker definitions', () => {
+  cy.login();
+  cy.contains('Import definitions').click();
+  cy.get('input[type="file"]').selectFile(
+    'cypress/fixtures/broker-definitions.json'
+  );
+  cy.contains('Upload broker definitions').click();
+  cy.get('.form-popup-warn').should('not.exist');
+  cy.contains('Your definitions were imported successfully');
+});
+
+it('allows publishing a message to a created exchange', () => {
+  cy.login();
+  cy.visit('#/exchanges');
+  cy.contains('Add a new exchange').click();
+  cy.fixture('exchanges').then((exchange) => {
+    cy.get('[name="name"]')
+      .scrollIntoView()
+      .type(`${exchange.newExchange.name}${random}`);
+    cy.get('#arguments_1_mfkey').type(exchange.newExchange.argument1);
+    cy.get('#arguments_1_mfvalue').type(exchange.newExchange.argument2);
+    cy.contains('Add exchange')
+      .scrollIntoView()
+      .should('be.enabled')
+      .click({ force: true });
+    cy.reload();
+    cy.get('table[class="list"]').should(
+      'contain',
+      `${exchange.newExchange.name}${random}`
+    );
+    cy.contains('a', `${exchange.newExchange.name}${random}`).click();
+  });
+  cy.contains('Publish message').click();
+  cy.fixture('messages').then((message) => {
+    cy.get('textarea')
+      .should('not.be.disabled')
+      .type(message.newMessage.payload);
+  });
+  cy.contains('input', 'Publish message').click();
+  cy.contains('Message published');
+});
+
+it('allows adding a new queue and binding/unbinding it to the exchange', () => {
+  cy.login();
+  cy.visit('#/queues');
+  cy.contains('Add a new queue').click();
+  cy.fixture('queues').then((queue) => {
+    cy.get('[name="name"]').type(`${queue.newQueue.name}${random}`);
+    cy.get('#arguments_1_mfkey').type(queue.newQueue.argument1);
+    cy.get('#arguments_1_mfvalue').type(queue.newQueue.argument2);
+    cy.contains('Add queue')
+      .scrollIntoView()
+      .should('be.enabled')
+      .click({ force: true });
+    cy.reload();
+    cy.contains('table', `${queue.newQueue.name}${random}`);
+  });
+  cy.visit('#/exchanges');
+  cy.contains('amq.direct').click();
+  cy.contains('Bindings').click();
+  cy.fixture('queues').then((queue) => {
+    cy.get('[name="destination"]').type(`${queue.newQueue.name}${random}`);
+    cy.contains('[type="submit"]', 'Bind').click();
+    cy.contains('.bindings-wrapper', `${queue.newQueue.name}${random}`);
+  });
+  cy.contains('Unbind').click();
+  cy.contains('no bindings');
+});
+
+it('allows adding a new admin and logging in as such', () => {
+  cy.login();
+  cy.visit('/#/users');
+  cy.contains('Add a user').click();
+  cy.fixture('admins').then((admin) => {
+    cy.get('[name="username"').type(`${admin.newAdmin.userName}${random}`);
+    cy.get('[name="password"]').type(`${admin.newAdmin.password}${random}`);
+    cy.get('[name="password_confirm"]').type(
+      `${admin.newAdmin.password}${random}`
+    );
+    cy.get('#tags').type(admin.newAdmin.tags);
+    cy.contains('input[type="submit"]', 'Add user').click();
+    cy.get('[class="updatable"]').should(
+      'contain',
+      `${admin.newAdmin.userName}${random}`
+    );
+    cy.contains('Log out').click();
+    cy.get('[alt="RabbitMQ logo"]');
+    cy.get('[name="username"]').type(`${admin.newAdmin.userName}${random}`);
+    cy.get('[name="password"]').type(`${admin.newAdmin.password}${random}`);
+    cy.contains('Login').click();
+    cy.get('#versions')
+      .invoke('text')
+      .should('match', /RabbitMQ\s\d+\.\d+\.\d+/);
+    cy.contains('Log out');
+  });
+});

+ 3 - 0
.vib/rabbitmq/cypress/cypress/integration/utils.js

@@ -0,0 +1,3 @@
+/// <reference types="cypress" />
+
+export let random = (Math.random() + 1).toString(36).substring(7);

+ 34 - 0
.vib/rabbitmq/cypress/cypress/support/commands.js

@@ -0,0 +1,34 @@
+const COMMAND_DELAY = 900;
+
+for (const command of ['click']) {
+  Cypress.Commands.overwrite(command, (originalFn, ...args) => {
+    const origVal = originalFn(...args);
+
+    return new Promise((resolve) => {
+      setTimeout(() => {
+        resolve(origVal);
+      }, COMMAND_DELAY);
+    });
+  });
+}
+
+Cypress.Commands.add(
+  'login',
+  (username = Cypress.env('username'), password = Cypress.env('password')) => {
+    cy.visit('/');
+    cy.get('[alt="RabbitMQ logo"]');
+    cy.get('[name="username"]').type(username);
+    cy.get('[name="password"]').type(password);
+    cy.contains('Login').click();
+  }
+);
+
+Cypress.on('uncaught:exception', (err, runnable) => {
+  // we expect a 3rd party library error with message 'list not defined'
+  // and don't want to fail the test so we return false
+  if (err.message.includes('Cannot read properties of undefined')) {
+    return false;
+  }
+  // we still want to ensure there are no other unexpected
+  // errors, so we let them fail the test
+});

+ 20 - 0
.vib/rabbitmq/cypress/cypress/support/index.js

@@ -0,0 +1,20 @@
+// ***********************************************************
+// This example support/index.js is processed and
+// loaded automatically before your test files.
+//
+// This is a great place to put global configuration and
+// behavior that modifies Cypress.
+//
+// You can change the location of this file or turn off
+// automatically serving support files with the
+// 'supportFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/configuration
+// ***********************************************************
+
+// Import commands.js using ES2015 syntax:
+import './commands';
+
+// Alternatively you can use CommonJS syntax:
+// require('./commands')

+ 31 - 0
.vib/rabbitmq/goss/goss.yaml

@@ -0,0 +1,31 @@
+command:
+  rabbmitmqctl-version:
+    exec: rabbitmqctl version | grep --quiet $APP_VERSION
+    exit-status: 0
+    stderr: [ ]
+    timeout: 20000
+  rabbitmqctl-add-vhost:
+    exec: rabbitmqctl add_vhost test-host
+    exit-status: 0
+    stderr: [ ]
+    stdout:
+      - 'Adding vhost'
+    timeout: 20000  
+  rabbitmqctl-list-global-params:
+    exec: rabbitmqctl list_global_parameters
+    exit-status: 0
+    stderr: [ ]
+    stdout:
+      - 'Listing global runtime parameters'
+    timeout: 20000
+  user-id-test:
+    exec: if [ "$(id -u)" -eq 0 ]; then exit 1; fi
+    exit-status: 0
+    stdout: []
+    stderr: []    
+file:
+  /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq.conf:
+    mode: "0644"
+    filetype: file
+    exists: true
+    group: root

+ 29 - 5
.vib/rabbitmq/vib-publish.json

@@ -22,11 +22,11 @@
           "url": "{SHA_ARCHIVE}",
           "path": "/bitnami/rabbitmq"
         },
-        "runtime_parameters": "ImF1dGgiOgogICJlcmxhbmdDb29raWUiOiAiUmpzcENDM25tNGtMdjRMaldGTmZGSFczeEx4Yjd6VEMiCiAgInBhc3N3b3JkIjogIlBIVkhkcXpyTWI5cyIKICAidXNlcm5hbWUiOiAidXNlciIKInNlcnZpY2UiOgogICJwb3J0cyI6CiAgICAibWFuYWdlciI6IDgwCiAgInR5cGUiOiAiTG9hZEJhbGFuY2VyIgo=",
+        "runtime_parameters": "YXV0aDoKICBlcmxhbmdDb29raWU6IFJqc3BDQzNubTRrTHY0TGpXRk5mRkhXM3hMeGI3elRDCiAgcGFzc3dvcmQ6IENvbXBsaWNhdGVkUGFzc3dvcmQxMjMhNAogIHVzZXJuYW1lOiB1c2VyCnNlcnZpY2U6CiAgcG9ydHM6CiAgICBtYW5hZ2VyOiA4MAogIHR5cGU6IExvYWRCYWxhbmNlcg==",
         "target_platform": {
           "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
           "size": {
-            "name": "S4"
+            "name": "M8"
           }
         }
       },
@@ -35,9 +35,7 @@
           "action_id": "trivy",
           "params": {
             "threshold": "CRITICAL",
-            "vuln_type": [
-              "OS"
-            ]
+            "vuln_type": ["OS"]
           }
         },
         {
@@ -46,9 +44,35 @@
             "endpoint": "lb-rabbitmq-http-stats",
             "app_protocol": "HTTP"
           }
+        },
+        {
+          "action_id": "cypress",
+          "params": {
+            "resources": {
+              "path": "/.vib/rabbitmq/cypress"
+            },
+            "endpoint": "lb-rabbitmq-http-stats",
+            "app_protocol": "HTTP",
+            "env": {
+              "username": "user",
+              "password": "ComplicatedPassword123!4"
+            }
+          }
+        },
+        {
+          "action_id": "goss",
+          "params": {
+            "resources": {
+              "path": "/.vib/rabbitmq/goss"
+            },
+            "remote": {
+              "workload": "sts-rabbitmq"
+            }
+          }
         }
       ]
     },
+
     "publish": {
       "actions": [
         {

+ 27 - 2
.vib/rabbitmq/vib-verify.json

@@ -22,11 +22,11 @@
           "url": "{SHA_ARCHIVE}",
           "path": "/bitnami/rabbitmq"
         },
-        "runtime_parameters": "ImF1dGgiOgogICJlcmxhbmdDb29raWUiOiAiUmpzcENDM25tNGtMdjRMaldGTmZGSFczeEx4Yjd6VEMiCiAgInBhc3N3b3JkIjogIlBIVkhkcXpyTWI5cyIKICAidXNlcm5hbWUiOiAidXNlciIKInNlcnZpY2UiOgogICJwb3J0cyI6CiAgICAibWFuYWdlciI6IDgwCiAgInR5cGUiOiAiTG9hZEJhbGFuY2VyIgo=",
+        "runtime_parameters": "YXV0aDoKICBlcmxhbmdDb29raWU6IFJqc3BDQzNubTRrTHY0TGpXRk5mRkhXM3hMeGI3elRDCiAgcGFzc3dvcmQ6IENvbXBsaWNhdGVkUGFzc3dvcmQxMjMhNAogIHVzZXJuYW1lOiB1c2VyCnNlcnZpY2U6CiAgcG9ydHM6CiAgICBtYW5hZ2VyOiA4MAogIHR5cGU6IExvYWRCYWxhbmNlcg==",
         "target_platform": {
           "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
           "size": {
-            "name": "S4"
+            "name": "M8"
           }
         }
       },
@@ -44,6 +44,31 @@
             "endpoint": "lb-rabbitmq-http-stats",
             "app_protocol": "HTTP"
           }
+        },
+        {
+          "action_id": "goss",
+          "params": {
+            "resources": {
+              "path": "/.vib/rabbitmq/goss"
+            },
+            "remote": {
+              "workload": "sts-rabbitmq"
+            }
+          }
+        },
+        {
+          "action_id": "cypress",
+          "params": {
+            "resources": {
+              "path": "/.vib/rabbitmq/cypress"
+            },
+            "endpoint": "lb-rabbitmq-http-stats",
+            "app_protocol": "HTTP",
+            "env": {
+              "username": "user",
+              "password": "ComplicatedPassword123!4"
+            }
+          }
         }
       ]
     }