From 056b262ffc949a1da47d8dd58d490db5fa76d472 Mon Sep 17 00:00:00 2001 From: superaleks <47592680+superaleks@users.noreply.github.com> Date: Thu, 7 Apr 2022 13:12:38 +0200 Subject: [PATCH] [bitnami/thanos] Add Thanos Helm Chart tests (#9635) * Added the Thanos folder structure and some really basic tests Signed-off-by: alukic * Added more functional tests which also check for existing store Signed-off-by: alukic * Added the workflow for Thanos Signed-off-by: alukic * Tweaked the workflow Signed-off-by: alukic * Added the final version of the tests Signed-off-by: alukic * Remove previous version of the workflow Signed-off-by: alukic * Removed phpmyadmin folder Signed-off-by: alukic * Formatting the cypress.json file Signed-off-by: alukic * Formatted the cypress.json Signed-off-by: alukic * Remove unnecessary environment variables Signed-off-by: alukic * Removed extra shoulds Signed-off-by: alukic * New line Signed-off-by: alukic * New line removal Signed-off-by: alukic * Renamed the variable name, removed dark/light mode test Signed-off-by: alukic * Data query Signed-off-by: alukic * Improved query execution test Signed-off-by: alukic * Improved assertions Signed-off-by: alukic * Removed extra assertions Signed-off-by: alukic * Removed extra assertion Signed-off-by: alukic * Chaining selectors Signed-off-by: alukic * Removed chaning UI tests Signed-off-by: alukic * Applied code review suggestions Signed-off-by: alukic * Version information was missing Signed-off-by: alukic * A typo Signed-off-by: alukic * Implemented the suggestion related to the badge Signed-off-by: alukic * Applied code review suggestions Signed-off-by: alukic * Formatting, added more asserts Signed-off-by: alukic * Removed other extra asserts Signed-off-by: alukic * Changing the store endpoint assertion Signed-off-by: alukic * Removed extra be.visible assertion Signed-off-by: alukic * Formatting Signed-off-by: alukic * Undo unwanted formatting Signed-off-by: alukic * Formatting Signed-off-by: alukic * Change the name of the environment variable Signed-off-by: alukic * Increase click delay to prevent flakiness Signed-off-by: alukic * Changed the variable name to match the new one Signed-off-by: alukic * Added type delay to fix flakiness Signed-off-by: alukic * Adding back the ; Signed-off-by: alukic * Format consistency Signed-off-by: alukic * Formatting Signed-off-by: alukic * Last formatting after plugin config Signed-off-by: alukic --- .github/workflows/vib-thanos-bucketweb.yaml | 36 +++++++++++++ .../workflows/vib-thanos-queryfrontend.yaml | 36 +++++++++++++ .vib/thanos/bucketweb/cypress/cypress.json | 4 ++ .../integration/thanos_bucketweb_spec.js | 19 +++++++ .../cypress/cypress/support/commands.js | 13 +++++ .../cypress/cypress/support/index.js | 20 ++++++++ .../thanos/bucketweb/vib-platform-verify.json | 51 +++++++++++++++++++ .../thanos/queryfrontend/cypress/cypress.json | 4 ++ .../integration/thanos_queryfrontend_spec.js | 42 +++++++++++++++ .../cypress/cypress/support/commands.js | 26 ++++++++++ .../cypress/cypress/support/index.js | 20 ++++++++ .../queryfrontend/vib-platform-verify.json | 51 +++++++++++++++++++ 12 files changed, 322 insertions(+) create mode 100644 .github/workflows/vib-thanos-bucketweb.yaml create mode 100644 .github/workflows/vib-thanos-queryfrontend.yaml create mode 100644 .vib/thanos/bucketweb/cypress/cypress.json create mode 100644 .vib/thanos/bucketweb/cypress/cypress/integration/thanos_bucketweb_spec.js create mode 100644 .vib/thanos/bucketweb/cypress/cypress/support/commands.js create mode 100644 .vib/thanos/bucketweb/cypress/cypress/support/index.js create mode 100644 .vib/thanos/bucketweb/vib-platform-verify.json create mode 100644 .vib/thanos/queryfrontend/cypress/cypress.json create mode 100644 .vib/thanos/queryfrontend/cypress/cypress/integration/thanos_queryfrontend_spec.js create mode 100644 .vib/thanos/queryfrontend/cypress/cypress/support/commands.js create mode 100644 .vib/thanos/queryfrontend/cypress/cypress/support/index.js create mode 100644 .vib/thanos/queryfrontend/vib-platform-verify.json diff --git a/.github/workflows/vib-thanos-bucketweb.yaml b/.github/workflows/vib-thanos-bucketweb.yaml new file mode 100644 index 0000000000..8d8379033f --- /dev/null +++ b/.github/workflows/vib-thanos-bucketweb.yaml @@ -0,0 +1,36 @@ +name: 'vib' +on: # rebuild any PRs and main branch changes + pull_request_target: + branches: + - master + paths: + - 'bitnami/thanos/*' +env: + CSP_API_URL: https://console.cloud.vmware.com + CSP_API_TOKEN: ${{ secrets.CSP_API_TOKEN }} + VIB_PUBLIC_URL: https://cp.bromelia.vmware.com +jobs: + vib-k8s-verify: # verify in multiple target platforms + runs-on: ubuntu-latest + environment: vmware-image-builder + strategy: + matrix: + include: + - target-platform: gke + target-platform-id: 91d398a2-25c4-4cda-8732-75a3cfc179a1 + - target-platform: aks + target-platform-id: 7b13a7bb-011c-474f-ad71-8152fc321b9e + - target-platform: tkg + target-platform-id: 7ddab896-2e4e-4d58-a501-f79897eba3a0 + fail-fast: false + name: K8s verify ${{ matrix.target-platform}} + steps: + - uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: vmware-labs/vmware-image-builder-action@main + with: + pipeline: thanos/bucketweb/vib-platform-verify.json + env: + VIB_ENV_TARGET_PLATFORM: ${{ matrix.target-platform-id }} diff --git a/.github/workflows/vib-thanos-queryfrontend.yaml b/.github/workflows/vib-thanos-queryfrontend.yaml new file mode 100644 index 0000000000..c8f0acaafe --- /dev/null +++ b/.github/workflows/vib-thanos-queryfrontend.yaml @@ -0,0 +1,36 @@ +name: 'vib' +on: # rebuild any PRs and main branch changes + pull_request_target: + branches: + - master + paths: + - 'bitnami/thanos/*' +env: + CSP_API_URL: https://console.cloud.vmware.com + CSP_API_TOKEN: ${{ secrets.CSP_API_TOKEN }} + VIB_PUBLIC_URL: https://cp.bromelia.vmware.com +jobs: + vib-k8s-verify: # verify in multiple target platforms + runs-on: ubuntu-latest + environment: vmware-image-builder + strategy: + matrix: + include: + - target-platform: gke + target-platform-id: 91d398a2-25c4-4cda-8732-75a3cfc179a1 + - target-platform: aks + target-platform-id: 7b13a7bb-011c-474f-ad71-8152fc321b9e + - target-platform: tkg + target-platform-id: 7ddab896-2e4e-4d58-a501-f79897eba3a0 + fail-fast: false + name: K8s verify ${{ matrix.target-platform}} + steps: + - uses: actions/checkout@v2 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: vmware-labs/vmware-image-builder-action@main + with: + pipeline: thanos/queryfrontend/vib-platform-verify.json + env: + VIB_ENV_TARGET_PLATFORM: ${{ matrix.target-platform-id }} diff --git a/.vib/thanos/bucketweb/cypress/cypress.json b/.vib/thanos/bucketweb/cypress/cypress.json new file mode 100644 index 0000000000..ca7dfecb44 --- /dev/null +++ b/.vib/thanos/bucketweb/cypress/cypress.json @@ -0,0 +1,4 @@ +{ + "baseUrl": "http://localhost", + "defaultCommandTimeout": 40000 +} diff --git a/.vib/thanos/bucketweb/cypress/cypress/integration/thanos_bucketweb_spec.js b/.vib/thanos/bucketweb/cypress/cypress/integration/thanos_bucketweb_spec.js new file mode 100644 index 0000000000..f764400b62 --- /dev/null +++ b/.vib/thanos/bucketweb/cypress/cypress/integration/thanos_bucketweb_spec.js @@ -0,0 +1,19 @@ +/// + +it('allows to see runtime & build information', () => { + cy.visit('/'); + cy.contains('.dropdown-toggle', 'Status').click(); + cy.contains('[class="dropdown-item"]', 'Runtime & Build Information').click(); + cy.contains('Runtime Information'); + cy.get('h2').contains('Build Information'); + cy.contains('.capitalize-title', 'version').siblings().should('not.be.empty'); //check if there is value for app and Go Version + cy.contains('.capitalize-title', 'goVersion') + .siblings() + .should('not.be.empty'); +}); + +it('allows to see the Blocks page', () => { + cy.visit('/'); + cy.get('.nav-link').contains('Blocks').click(); + cy.contains('No blocks found.'); +}); diff --git a/.vib/thanos/bucketweb/cypress/cypress/support/commands.js b/.vib/thanos/bucketweb/cypress/cypress/support/commands.js new file mode 100644 index 0000000000..f29beb28c5 --- /dev/null +++ b/.vib/thanos/bucketweb/cypress/cypress/support/commands.js @@ -0,0 +1,13 @@ +const COMMAND_DELAY = 1300; + +for (const command of ['click']) { + Cypress.Commands.overwrite(command, (originalFn, ...args) => { + const origVal = originalFn(...args); + + return new Promise((resolve) => { + setTimeout(() => { + resolve(origVal); + }, COMMAND_DELAY); + }); + }); +} diff --git a/.vib/thanos/bucketweb/cypress/cypress/support/index.js b/.vib/thanos/bucketweb/cypress/cypress/support/index.js new file mode 100644 index 0000000000..d68db96df2 --- /dev/null +++ b/.vib/thanos/bucketweb/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') diff --git a/.vib/thanos/bucketweb/vib-platform-verify.json b/.vib/thanos/bucketweb/vib-platform-verify.json new file mode 100644 index 0000000000..b1560ca726 --- /dev/null +++ b/.vib/thanos/bucketweb/vib-platform-verify.json @@ -0,0 +1,51 @@ +{ + "phases": { + "package": { + "context": { + "resources": { + "url": "{SHA_ARCHIVE}", + "path": "/bitnami/thanos" + } + }, + "actions": [ + { + "action_id": "helm-package" + } + ] + }, + "verify": { + "context": { + "resources": { + "url": "{SHA_ARCHIVE}", + "path": "/bitnami/thanos" + }, + "runtime_parameters": "b2Jqc3RvcmVDb25maWc6IHwtCiAgdHlwZTogRklMRVNZU1RFTQogIGNvbmZpZzoKICAgIGRpcmVjdG9yeTogIi8iCgpidWNrZXR3ZWI6CiAgZW5hYmxlZDogdHJ1ZQogIHNlcnZpY2U6CiAgICB0eXBlOiBMb2FkQmFsYW5jZXIKICAgIHBvcnRzOgogICAgICBodHRwOiA4MA==", + "target_platform": { + "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", + "size": { + "name": "M4" + } + } + }, + "actions": [ + { + "action_id": "health-check", + "params": { + "endpoint": "lb-thanos-bucketweb-http", + "app_protocol": "HTTP" + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/thanos/bucketweb/cypress" + }, + "endpoint": "lb-thanos-bucketweb-http", + "app_protocol": "HTTP" + } + } + ] + } + } + } diff --git a/.vib/thanos/queryfrontend/cypress/cypress.json b/.vib/thanos/queryfrontend/cypress/cypress.json new file mode 100644 index 0000000000..8184308823 --- /dev/null +++ b/.vib/thanos/queryfrontend/cypress/cypress.json @@ -0,0 +1,4 @@ +{ + "baseUrl": "http://localhost/", + "defaultCommandTimeout": 40000 +} diff --git a/.vib/thanos/queryfrontend/cypress/cypress/integration/thanos_queryfrontend_spec.js b/.vib/thanos/queryfrontend/cypress/cypress/integration/thanos_queryfrontend_spec.js new file mode 100644 index 0000000000..4ae8e34e63 --- /dev/null +++ b/.vib/thanos/queryfrontend/cypress/cypress/integration/thanos_queryfrontend_spec.js @@ -0,0 +1,42 @@ +/// + +it('allows to see runtime & build information', () => { + cy.visit('/'); + cy.contains('.dropdown-toggle', 'Status').click(); + cy.contains('[class="dropdown-item"]', 'Runtime & Build Information').click(); + cy.contains('Runtime Information'); + cy.contains('h2', 'Build Information'); + + cy.contains('.capitalize-title', 'version').siblings().should('not.be.empty'); //check if there is value for app and Go Version + cy.contains('.capitalize-title', 'goVersion') + .siblings() + .should('not.be.empty'); +}); + +it('allows the execution of a query', () => { + const QUERY_ALERT = 'No data queried yet'; + const QUERY_KEYWORD = 'vector'; + const QUERY_VALUE = '3000'; + + cy.visit('/graph'); + cy.contains('.alert', QUERY_ALERT); + cy.get('.cm-line') + .type(QUERY_KEYWORD, '{enter}') + .type(`(${QUERY_VALUE})`) + .click(); + cy.get('.execute-btn').click(); + cy.contains('.tab-content', QUERY_VALUE); +}); + +it('allows listing all installed stores', () => { + cy.visit('/'); + cy.contains('[class="nav-link"]', 'Stores').click(); + cy.get('[data-testid="endpoint"]').should('not.be.empty'); + cy.get('[data-testid="health"]').contains('UP'); +}); + +it('allows adding a graph', () => { + cy.visit('/'); + cy.contains('button', 'Add Panel').click(); + cy.get('.execute-btn').should('have.length', 2); +}); diff --git a/.vib/thanos/queryfrontend/cypress/cypress/support/commands.js b/.vib/thanos/queryfrontend/cypress/cypress/support/commands.js new file mode 100644 index 0000000000..c64f030fb3 --- /dev/null +++ b/.vib/thanos/queryfrontend/cypress/cypress/support/commands.js @@ -0,0 +1,26 @@ +const CLICK_DELAY = 1300; +const TYPE_DELAY = 300; + +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 ['type']) { + Cypress.Commands.overwrite(command, (originalFn, ...args) => { + const origVal = originalFn(...args); + + return new Promise((resolve) => { + setTimeout(() => { + resolve(origVal); + }, TYPE_DELAY); + }); + }); +} diff --git a/.vib/thanos/queryfrontend/cypress/cypress/support/index.js b/.vib/thanos/queryfrontend/cypress/cypress/support/index.js new file mode 100644 index 0000000000..37a498fb5b --- /dev/null +++ b/.vib/thanos/queryfrontend/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') diff --git a/.vib/thanos/queryfrontend/vib-platform-verify.json b/.vib/thanos/queryfrontend/vib-platform-verify.json new file mode 100644 index 0000000000..9e259a02cd --- /dev/null +++ b/.vib/thanos/queryfrontend/vib-platform-verify.json @@ -0,0 +1,51 @@ +{ + "phases": { + "package": { + "context": { + "resources": { + "url": "{SHA_ARCHIVE}", + "path": "/bitnami/thanos" + } + }, + "actions": [ + { + "action_id": "helm-package" + } + ] + }, + "verify": { + "context": { + "resources": { + "url": "{SHA_ARCHIVE}", + "path": "/bitnami/thanos" + }, + "runtime_parameters": "b2Jqc3RvcmVDb25maWc6IHwtCiAgdHlwZTogRklMRVNZU1RFTQogIGNvbmZpZzoKICAgIGRpcmVjdG9yeTogIi8iCgpxdWVyeUZyb250ZW5kOgogIGVuYWJsZWQ6IHRydWUKICBzZXJ2aWNlOgogICAgdHlwZTogTG9hZEJhbGFuY2VyCiAgICBwb3J0czoKICAgICAgaHR0cDogODAKCnN0b3JlZ2F0ZXdheToKICBlbmFibGVkOiB0cnVlCg==", + "target_platform": { + "target_platform_id": "{VIB_ENV_TARGET_PLATFORM}", + "size": { + "name": "M4" + } + } + }, + "actions": [ + { + "action_id": "health-check", + "params": { + "endpoint": "lb-thanos-query-frontend-http", + "app_protocol": "HTTP" + } + }, + { + "action_id": "cypress", + "params": { + "resources": { + "path": "/.vib/thanos/queryfrontend/cypress" + }, + "endpoint": "lb-thanos-query-frontend-http", + "app_protocol": "HTTP" + } + } + ] + } + } + }