diff --git a/.drone.yml b/.drone.yml index f8c57b05b2..9ad2ef72c8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,19 +1,13 @@ +--- kind: pipeline -type: docker -name: openbas-tests-pull-request -concurrency: { - limit: 2 -} - -trigger: - event: - - pull_request +name: openbas-tests steps: - name: submodules image: alpine/git commands: - git submodule update --init --recursive + - name: api-tests image: maven:3.9.6-eclipse-temurin-21 environment: @@ -30,8 +24,12 @@ steps: - mvn test depends_on: - submodules + - name: frontend-tests - image: node:20.11.0-alpine3.18 + image: node:20-alpine + volumes: + - name: cache-node-frontend + path: /drone/src/openbas-front/node_modules commands: - cd openbas-front - yarn install @@ -41,141 +39,34 @@ steps: - yarn i18n-checker - NODE_OPTIONS=--max_old_space_size=8192 yarn test -services: - - name: minio - image: minio/minio:RELEASE.2023-12-02T10-51-33Z-cpuv1 - environment: - MINIO_ROOT_USER: minioadmin - MINIO_ROOT_PASSWORD: minioadmin - command: [ server, /data ] - - name: pgsql - image: postgres:16-alpine - environment: - POSTGRES_USER: openbas - POSTGRES_PASSWORD: openbas - POSTGRES_DB: openbas - ---- - -kind: pipeline -type: docker -name: openbas-e2e-tests-pull-request -concurrency: { - limit: 2 -} - -trigger: - event: - - pull_request - -steps: - - name: e2e-tests - image: node:20.11.0 + - name: frontend-e2e-tests + image: node:20.11.1 + volumes: + - name: cache-node-frontend-e2e + path: /drone/src/openbas-front/node_modules commands: - apt update - apt -y install netcat-traditional - - while ! nc -z app-start 8080 ; do sleep 1 ; done + - while ! nc -z app-e2e 8080 ; do sleep 1 ; done - cd openbas-front - yarn install - yarn playwright install --with-deps chromium - - APP_URL=http://app-start:8080 yarn test:e2e - -services: - - name: minio - image: minio/minio:RELEASE.2023-12-02T10-51-33Z-cpuv1 - environment: - MINIO_ROOT_USER: minioadmin - MINIO_ROOT_PASSWORD: minioadmin - command: [ server, /data ] - - name: pgsql - image: postgres:16-alpine - environment: - POSTGRES_USER: openbas - POSTGRES_PASSWORD: openbas - POSTGRES_DB: openbas - - name: app-start - image: maven:3.9.6-eclipse-temurin-21 - environment: - SPRING_DATASOURCE_URL: jdbc:postgresql://pgsql:5432/openbas - SPRING_DATASOURCE_USERNAME: openbas - SPRING_DATASOURCE_PASSWORD: openbas - MINIO_ENDPOINT: minio - MINIO_PORT: 9000 - MINIO_ACCESS_KEY: minioadmin - MINIO_ACCESS_SECRET: minioadmin - OPENBAS_ADMIN_EMAIL: admin@openbas.io - OPENBAS_ADMIN_PASSWORD: admin - OPENBAS_ADMIN_TOKEN: 0d17ce9a-f3a8-4c6d-9721-c98dc3dc023f - commands: - - apt update && apt install -y gnupg - - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - - - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list - - curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - - - apt update - - apt install -y yarn - - apt install -y nodejs - - apt install -y git - - git submodule update --init --recursive - - cd openbas-front - - yarn install - - yarn build - - cd .. - - mvn install -DskipTests=true - - java -jar openbas-api/target/openbas-api.jar - ---- - -kind: pipeline -type: docker -name: openbas-tests-master - -trigger: - branch: - - master - event: - exclude: - - pull_request - -steps: - - name: submodules - image: alpine/git - commands: - - git submodule update --init --recursive - - name: api-tests - image: maven:3.9.6-eclipse-temurin-21 - environment: - SPRING_DATASOURCE_URL: jdbc:postgresql://pgsql:5432/openbas - MINIO_ENDPOINT: minio - MINIO_PORT: 9000 - commands: - - mvn install -DskipTests - - cd openbas-api - - mvn test - - cd ../openbas-framework - - mvn test - - cd ../openbas-injectors - - mvn test + - APP_URL=http://app-e2e:8080 yarn test:e2e depends_on: - - submodules - - name: frontend-tests - image: node:20.11.0-alpine3.18 - commands: - - cd openbas-front - - yarn install - - yarn build - - yarn check-ts - - yarn lint - - yarn i18n-checker - - NODE_OPTIONS=--max_old_space_size=8192 yarn test + - frontend-tests + - name: codecov image: robertstettner/drone-codecov settings: token: - from_secret: CODECOV_TOKEN + from_secret: codecov_token files: - openbas-api/target/site/jacoco/jacoco.xml - openbas-framework/target/site/jacoco/jacoco.xml - openbas-injectors/openbas-caldera/target/site/jacoco/jacoco.xml + depends_on: + - api-tests + - name: build-circleci image: curlimages/curl commands: @@ -187,6 +78,11 @@ steps: event: exclude: - tag + depends_on: + - api-tests + - frontend-tests + - frontend-e2e-tests + - name: build-circleci-release image: curlimages/curl commands: @@ -197,6 +93,11 @@ steps: when: event: - tag + depends_on: + - api-tests + - frontend-tests + - frontend-e2e-tests + - name: slack image: plugins/slack settings: @@ -206,6 +107,10 @@ steps: channel: notifications when: status: [ success, failure ] + depends_on: + - api-tests + - frontend-tests + - frontend-e2e-tests services: - name: minio @@ -220,3 +125,55 @@ services: POSTGRES_USER: openbas POSTGRES_PASSWORD: openbas POSTGRES_DB: openbas + - name: minio-e2e + image: minio/minio:RELEASE.2023-12-02T10-51-33Z-cpuv1 + environment: + MINIO_ROOT_USER: minioadmin + MINIO_ROOT_PASSWORD: minioadmin + command: [ server, /data ] + - name: pgsql-e2e + image: postgres:16-alpine + environment: + POSTGRES_USER: openbas + POSTGRES_PASSWORD: openbas + POSTGRES_DB: openbas + - name: app-e2e + image: maven:3.9.6-eclipse-temurin-21 + environment: + SPRING_DATASOURCE_URL: jdbc:postgresql://pgsql-e2e:5432/openbas + SPRING_DATASOURCE_USERNAME: openbas + SPRING_DATASOURCE_PASSWORD: openbas + MINIO_ENDPOINT: minio-e2e + MINIO_PORT: 9000 + MINIO_ACCESS_KEY: minioadmin + MINIO_ACCESS_SECRET: minioadmin + OPENBAS_ADMIN_EMAIL: admin@openbas.io + OPENBAS_ADMIN_PASSWORD: admin + OPENBAS_ADMIN_TOKEN: 0d17ce9a-f3a8-4c6d-9721-c98dc3dc023f + commands: + - apt update && apt install -y gnupg + - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - + - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list + - curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - + - apt update + - apt install -y yarn + - apt install -y nodejs + - apt install -y git + - git submodule update --init --recursive + - cd openbas-front + - yarn install + - yarn build + - cd .. + - mvn install -DskipTests=true + - java -jar openbas-api/target/openbas-api.jar + +volumes: + - name: cache-node-frontend + host: + path: /tmp/cache-node-frontend + - name: cache-node-frontend-e2e + host: + path: /tmp/cache-node-frontend-e2e + - name: cache-python + host: + path: /tmp/cache-python \ No newline at end of file diff --git a/openbas-front/src/admin/components/nav/LeftBar.tsx b/openbas-front/src/admin/components/nav/LeftBar.tsx index 2fb79d33a3..7a46b9ad66 100644 --- a/openbas-front/src/admin/components/nav/LeftBar.tsx +++ b/openbas-front/src/admin/components/nav/LeftBar.tsx @@ -360,6 +360,7 @@ const LeftBar = () => { { OCTI @@ -229,7 +229,7 @@ const TopBar: React.FC = () => { - + OERM @@ -239,7 +239,7 @@ const TopBar: React.FC = () => { - + OMTD diff --git a/openbas-front/tests_e2e/tests/assets/create-asset.spec.ts b/openbas-front/tests_e2e/tests/assets/create-asset.spec.ts index 52447731cd..361ef9f8aa 100644 --- a/openbas-front/tests_e2e/tests/assets/create-asset.spec.ts +++ b/openbas-front/tests_e2e/tests/assets/create-asset.spec.ts @@ -1,17 +1,16 @@ import { expect } from '@playwright/test'; import { test } from '../../fixtures/baseFixtures'; import appUrl from '../../utils/url'; -import LeftMenuPage from '../../model/left-menu.page'; import AssetsPage from '../../model/assets/assets.page'; import AssetFormPage from '../../model/assets/asset-form.page'; import fillLinuxAssetBase from '../../fixtures/assetFixtures'; test('Create an asset', async ({ page }) => { // -- PREPARE -- - await page.goto(appUrl()); + await page.goto(`${appUrl()}/admin/assets`); - const leftMenuPage = new LeftMenuPage(page); - await leftMenuPage.goToAssets(); + // const leftMenuPage = new LeftMenuPage(page); + // await leftMenuPage.goToAssets(); // -- EXECUTE -- const assetsPage = new AssetsPage(page); diff --git a/openbas-front/tests_e2e/tests/assets/delete-asset.spec.ts b/openbas-front/tests_e2e/tests/assets/delete-asset.spec.ts index 8bb5b12cc1..f60f5b82f4 100644 --- a/openbas-front/tests_e2e/tests/assets/delete-asset.spec.ts +++ b/openbas-front/tests_e2e/tests/assets/delete-asset.spec.ts @@ -1,17 +1,16 @@ import { expect } from '@playwright/test'; import { test } from '../../fixtures/baseFixtures'; import appUrl from '../../utils/url'; -import LeftMenuPage from '../../model/left-menu.page'; import AssetsPage from '../../model/assets/assets.page'; import AssetFormPage from '../../model/assets/asset-form.page'; import fillLinuxAssetBase from '../../fixtures/assetFixtures'; test('Delete an asset', async ({ page }) => { // -- PREPARE -- - await page.goto(appUrl()); + await page.goto(`${appUrl()}/admin/assets`); - const leftMenuPage = new LeftMenuPage(page); - await leftMenuPage.goToAssets(); + // const leftMenuPage = new LeftMenuPage(page); + // await leftMenuPage.goToAssets(); const assetsPage = new AssetsPage(page); await assetsPage.getAddButton().click(); diff --git a/openbas-front/tests_e2e/tests/assets/update-asset.spec.ts b/openbas-front/tests_e2e/tests/assets/update-asset.spec.ts index e397d33046..f39e5fae69 100644 --- a/openbas-front/tests_e2e/tests/assets/update-asset.spec.ts +++ b/openbas-front/tests_e2e/tests/assets/update-asset.spec.ts @@ -1,17 +1,16 @@ import { expect } from '@playwright/test'; import { test } from '../../fixtures/baseFixtures'; import appUrl from '../../utils/url'; -import LeftMenuPage from '../../model/left-menu.page'; import AssetsPage from '../../model/assets/assets.page'; import AssetFormPage from '../../model/assets/asset-form.page'; import fillLinuxAssetBase from '../../fixtures/assetFixtures'; test('Update an asset', async ({ page }) => { // -- PREPARE -- - await page.goto(appUrl()); + await page.goto(`${appUrl()}/admin/assets`); - const leftMenuPage = new LeftMenuPage(page); - await leftMenuPage.goToAssets(); + // const leftMenuPage = new LeftMenuPage(page); + // await leftMenuPage.goToAssets(); const assetsPage = new AssetsPage(page); await assetsPage.getAddButton().click();