[bitnami/magento] Add Magento Helm Chart tests (#11055)

* 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 extra workflow for Grafana Loki

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

* Changed the pipeline

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

* Modified the workflow

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

* Removed Grafana Loki

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

* Add Cypress tests and created first pipeline

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

* Set target ip for remote execution

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

* Trigger VIB on fork to see the outcome

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

* Slowed down test execution

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

* Trigger vib

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

* Keep working on the tests

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

* Added Magento tests

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

* Tweak the waiting time to check for changes

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

* Increase delay

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

* Add a small change to the test

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

* Improved the Cypress tests

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

* Replaced hardcoded ip with template

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

* Improved one Cypress tests

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

* Added one more goss tests

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

* Corrected a typo

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

* Fixed a flaky test

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

* Template instead of IP

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

* Improved the last Cypress test

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

* Removed test files

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

* Remove antiflake

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

* Remove changes

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

* Trying to fix the loader

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

* Try to solve the loading issue

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

* Undo fix for last test

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

* Added publishing change

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

* Remove filetype from fixtures

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

* Added back the proper action delay

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

* Remove the dot

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

* Added logout to before, separated admin test from customer test

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

* Added image upload test

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

* Add image upload test

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

* Improved Commands selector

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

* Improved Goss tests per PR suggestions

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

* Variable instead of hardcoded value

Signed-off-by: alukic <alukic@vmware.com>
This commit is contained in:
superaleks
2022-07-13 18:17:40 +02:00
committed by GitHub
parent 377e784f73
commit 8b64d5d6f1
14 changed files with 372 additions and 3 deletions

View File

@@ -0,0 +1,11 @@
{
"env": {
"username": "user",
"password": "ComplicatedPassword123!4"
},
"hosts": {
"vmware-magento.my": "{{ TARGET_IP }}"
},
"defaultCommandTimeout": 50000,
"pageLoadTimeout": 500000
}

View File

@@ -0,0 +1,8 @@
{
"newCustomer": {
"firstName": "Marcus",
"lastName": "Aurelius",
"email": "emperor@romanmail.com",
"password": "stoicLife124"
}
}

View File

@@ -0,0 +1,6 @@
{
"newDiscount": {
"ruleName": "WELCOME",
"amount": "35"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -0,0 +1,5 @@
{
"newPage": {
"pageTitle": "Stoic shop"
}
}

View File

@@ -0,0 +1,6 @@
{
"newProduct": {
"productName": "Kolevka",
"price": "99.99"
}
}

View File

@@ -0,0 +1,110 @@
/// <reference types="cypress" />
import { random, allowDataUsage } from './utils';
before(() => {
cy.login();
allowDataUsage();
cy.logout();
});
it('allows admin to add a product to the store', () => {
cy.login();
cy.get('#menu-magento-catalog-catalog').click();
cy.get('.item-catalog-products').click();
cy.contains('Salable Quantity');
cy.get('#add_new_product-button').click();
cy.fixture('products').then((product) => {
cy.get('[name="product[name]"]').type(
`${product.newProduct.productName}.${random}`
);
cy.get('[name="product[price]"]').type(product.newProduct.price);
});
cy.contains('Images And Videos').click();
cy.get('#fileupload').selectFile('cypress/fixtures/images/image.png', {
force: true,
});
cy.get('.product-image');
cy.get('#save-button').click();
cy.contains('You saved the product');
cy.get('#menu-magento-catalog-catalog').click();
cy.get('.item-catalog-products').click();
cy.fixture('products').then((product) => {
cy.contains(`${product.newProduct.productName}.${random}`);
});
});
it('allows user to create a customer account', () => {
cy.visit('/');
cy.contains('Create an Account').click();
cy.fixture('customers').then((customer) => {
cy.get('.field-name-firstname').type(
`${customer.newCustomer.firstName}.${random}`
);
cy.get('#lastname').type(`${customer.newCustomer.lastName}.${random}`);
cy.get('#email_address').type(`${random}.${customer.newCustomer.email}`);
cy.get('#password').type(customer.newCustomer.password);
cy.get('#password-confirmation').type(customer.newCustomer.password);
});
cy.contains('button', 'Create an Account').click();
cy.contains('Thank you for registering');
cy.fixture('customers').then((customer) => {
cy.get('.logged-in').contains(
`${customer.newCustomer.firstName}.${random}`
);
});
});
it('allows customer to subscribe to newsletter', () => {
cy.visit('/');
cy.fixture('customers').then((customer) => {
cy.get('#newsletter').type(`${random}.${customer.newCustomer.email}`);
});
cy.contains('Subscribe').click();
cy.contains('Thank you for your subscription.');
cy.login();
cy.get('#menu-magento-backend-marketing').click();
cy.get('.item-newsletter-subscriber').click();
cy.fixture('customers').then((customer) => {
cy.contains(`${random}.${customer.newCustomer.email}`);
});
});
it('allows admin to add a discount', () => {
cy.login();
cy.get('#menu-magento-backend-marketing').click();
cy.get('.item-promo-catalog').click();
cy.get('#add').click({ force: true });
cy.fixture('discounts').then((discount) => {
cy.get('[name="name"]').type(`${discount.newDiscount.ruleName}.${random}`);
cy.get('.admin__actions-switch-text').click({ force: true });
cy.get('[class="admin__control-multiselect"]')
.first()
.select('Main Website');
cy.get('[class="admin__control-multiselect"]').last().select('General');
cy.get('#save').click();
cy.get('[name="discount_amount"]').type(discount.newDiscount.amount);
cy.get('#save').click();
});
cy.contains('You saved the rule');
cy.get('#apply_rules').click();
cy.contains('Updated rules applied');
});
it('allows admin to customize the home page', () => {
cy.login();
cy.get('#menu-magento-backend-content').click();
cy.get('.item-cms-page').click();
cy.get('.page-main-actions');
cy.get('[data-role="grid-wrapper"]').within(() => {
cy.contains('td', 'home').siblings().last().click();
cy.get('[class="action-menu _active"]').within(() => {
cy.contains('Edit').click({ force: true });
});
});
cy.fixture('pages').then((page) => {
cy.get('input[name="title"]').type(`${page.newPage.pageTitle}.${random}`, {
force: true,
});
});
});

View File

@@ -0,0 +1,12 @@
/// <reference types="cypress" />
export let random = (Math.random() + 1).toString(36).substring(7);
export let allowDataUsage = () => {
cy.contains('Average Order');
cy.get('body').then(($body) => {
if ($body.find('[class="admin__fieldset"]').is(':visible')) {
cy.contains('.action-primary', 'Allow').click({ force: true });
}
});
};

View File

@@ -0,0 +1,62 @@
const CLICK_DELAY = 1000;
const GET_DELAY = 1000;
const BASE_URL = 'http://vmware-magento.my';
for (const command of ['click']) {
Cypress.Commands.overwrite(command, (originalFn, ...args) => {
const origVal = originalFn(...args);
return new Promise((resolve) => {
setTimeout(() => {
resolve(origVal);
}, CLICK_DELAY);
});
});
}
for (const command of ['get']) {
Cypress.Commands.overwrite(command, (originalFn, ...args) => {
const origVal = originalFn(...args);
return new Promise((resolve) => {
setTimeout(() => {
resolve(origVal);
}, GET_DELAY);
});
});
}
// Due to a bug when using "hosts" in Cypress, we cannot set a "baseUrl" in the
// cypress.json file. Workaround this by modifying the "visit" command to preprend
// the base URL.
//
// Further details: https://github.com/cypress-io/cypress/issues/20647
Cypress.Commands.overwrite('visit', (originalFn, url, options) => {
return originalFn(`${BASE_URL}${url}`, options);
});
Cypress.Commands.add(
'login',
(username = Cypress.env('username'), password = Cypress.env('password')) => {
cy.visit('/admin');
cy.get('#username').type(username);
cy.get('#login').type(password);
cy.get('.action-login').click();
cy.contains('.page-title', 'Dashboard');
}
);
Cypress.Commands.add('logout', () => {
cy.get('[title="My Account"]').click();
cy.contains('Sign Out').click();
});
Cypress.on('uncaught:exception', (err, runnable) => {
// we expect an application error with message 'rendering locks'
// and don't want to fail the test so we return false
if (err.message.includes('renderingLocks')) {
return false;
}
// we still want to ensure there are no other unexpected
// errors, so we let them fail the test
});

View File

@@ -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')

View File

@@ -0,0 +1,40 @@
command:
user-id-test:
exec: if [ "$(id -u)" -eq 0 ]; then exit 1; fi
exit-status: 0
stdout: []
stderr: []
magento-store-list:
exec: magento store:list
exit-status: 0
stdout:
- "Default Store View"
- "Admin"
stderr: []
timeout: 0
magento-uri:
exec: magento info:adminuri
exit-status: 0
stdout:
- {{ printf "%s" .Env.MAGENTO_ADMIN_URL_PREFIX }}
stderr: []
timeout: 0
apache-running:
exec: ps aux | grep apache
exit-status: 0
stdout:
- /opt/bitnami/apache/bin/httpd
stderr: []
timeout: 0
file:
/opt/bitnami/magento:
filetype: symlink
linked-to: /bitnami/magento
exists: true
/bitnami/magento/setup/config/modules.config.php:
filetype: file
exists: true
contains:
- "Setup"
- "Di"
- "Router"

View File

@@ -17,14 +17,57 @@
]
},
"verify": {
"context": {
"resources": {
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/magento"
},
"runtime_parameters": "bWFnZW50b1VzZXJuYW1lOiB1c2VyCm1hZ2VudG9QYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0Cm1hZ2VudG9Ib3N0OiB2bXdhcmUtbWFnZW50by5teQptYWdlbnRvQWRtaW5Vcmk6IGFkbWluCnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAptYXJpYWRiOgogIGVuYWJsZWQ6IHRydWUKICBhdXRoOgogICAgcm9vdFBhc3N3b3JkOiBDb21wbGljYXRlZG1hcmlhUGFzc3dvcmQxMjMhNAo=",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
"name": "L4"
}
}
},
"actions": [
{
"action_id": "trivy",
"params": {
"threshold": "CRITICAL",
"vuln_type": [
"OS"
]
"vuln_type": ["OS"]
}
},
{
"action_id": "health-check",
"params": {
"endpoint": "lb-magento-http",
"app_protocol": "HTTP"
}
},
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib/magento/goss"
},
"remote": {
"workload": "deploy-magento"
}
}
},
{
"action_id": "cypress",
"params": {
"resources": {
"path": "/.vib/magento/cypress"
},
"endpoint": "lb-magento-http",
"app_protocol": "HTTP",
"env": {
"username": "user",
"password": "ComplicatedPassword123!4"
}
}
}
]

View File

@@ -17,6 +17,19 @@
]
},
"verify": {
"context": {
"resources": {
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/magento"
},
"runtime_parameters": "bWFnZW50b1VzZXJuYW1lOiB1c2VyCm1hZ2VudG9QYXNzd29yZDogQ29tcGxpY2F0ZWRQYXNzd29yZDEyMyE0Cm1hZ2VudG9Ib3N0OiB2bXdhcmUtbWFnZW50by5teQptYWdlbnRvQWRtaW5Vcmk6IGFkbWluCnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAptYXJpYWRiOgogIGVuYWJsZWQ6IHRydWUKICBhdXRoOgogICAgcm9vdFBhc3N3b3JkOiBDb21wbGljYXRlZG1hcmlhUGFzc3dvcmQxMjMhNAo=",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
"name": "L4"
}
}
},
"actions": [
{
"action_id": "trivy",
@@ -24,6 +37,38 @@
"threshold": "CRITICAL",
"vuln_type": ["OS"]
}
},
{
"action_id": "health-check",
"params": {
"endpoint": "lb-magento-http",
"app_protocol": "HTTP"
}
},
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib/magento/goss"
},
"remote": {
"workload": "deploy-magento"
}
}
},
{
"action_id": "cypress",
"params": {
"resources": {
"path": "/.vib/magento/cypress"
},
"endpoint": "lb-magento-http",
"app_protocol": "HTTP",
"env": {
"username": "user",
"password": "ComplicatedPassword123!4"
}
}
}
]
}