Skip to content

Commit

Permalink
[integration] Unified parallel testing everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Mar 10, 2024
1 parent 63add05 commit 8c096dc
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 145 deletions.
217 changes: 87 additions & 130 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand All @@ -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: [email protected]
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:
Expand All @@ -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:
Expand All @@ -197,6 +93,11 @@ steps:
when:
event:
- tag
depends_on:
- api-tests
- frontend-tests
- frontend-e2e-tests

- name: slack
image: plugins/slack
settings:
Expand All @@ -206,6 +107,10 @@ steps:
channel: notifications
when:
status: [ success, failure ]
depends_on:
- api-tests
- frontend-tests
- frontend-e2e-tests

services:
- name: minio
Expand All @@ -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: [email protected]
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
1 change: 1 addition & 0 deletions openbas-front/src/admin/components/nav/LeftBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ const LeftBar = () => {
</MenuItem>
</StyledTooltip>
<MenuItem
aria-label="Assets"
ref={anchors.assets}
href='assets'
selected={!navOpen && location.pathname.includes('/admin/assets')}
Expand Down
6 changes: 3 additions & 3 deletions openbas-front/src/admin/components/nav/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const TopBar: React.FC = () => {
<Tooltip title={settings.xtm_opencti_enable && settings.xtm_opencti_url ? t('Platform connected') : t('Get OpenCTI now')}>
<a className={classes.xtmItem}
href={settings.xtm_opencti_enable && settings.xtm_opencti_url ? settings.xtm_opencti_url : 'https://filigran.io'}
target="_blank" rel="noreferrer"
target="_blank" rel="noreferrer" onClick={handleCloseXtm}
>
<Badge variant="dot" color={settings.xtm_opencti_enable && settings.xtm_opencti_url ? 'success' : 'warning'}>
<img style={{ width: 40 }} src={theme.palette.mode === 'dark' ? octiDark : octiLight} alt="OCTI" />
Expand All @@ -229,7 +229,7 @@ const TopBar: React.FC = () => {
</Grid>
<Grid item={true} xs={6}>
<Tooltip title={t('Platform under construction, subscribe to update!')}>
<a className={classes.xtmItem} href="https://filigran.io" target="_blank" rel="noreferrer">
<a className={classes.xtmItem} href="https://filigran.io" target="_blank" rel="noreferrer" onClick={handleCloseXtm}>
<Badge variant="dot" color="info">
<img style={{ width: 40 }} src={theme.palette.mode === 'dark' ? oermDark : oermLight} alt="OERM" />
</Badge>
Expand All @@ -239,7 +239,7 @@ const TopBar: React.FC = () => {
</Grid>
<Grid item={true} xs={6}>
<Tooltip title={t('Platform under construction, subscribe to update!')}>
<a className={classes.xtmItem} href="https://filigran.io" target="_blank" rel="noreferrer">
<a className={classes.xtmItem} href="https://filigran.io" target="_blank" rel="noreferrer" onClick={handleCloseXtm}>
<Badge variant="dot" color="info">
<img style={{ width: 40 }} src={theme.palette.mode === 'dark' ? omtdDark : omtdLight} alt="OMTD" />
</Badge>
Expand Down
7 changes: 3 additions & 4 deletions openbas-front/tests_e2e/tests/assets/create-asset.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
7 changes: 3 additions & 4 deletions openbas-front/tests_e2e/tests/assets/delete-asset.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
7 changes: 3 additions & 4 deletions openbas-front/tests_e2e/tests/assets/update-asset.spec.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down

0 comments on commit 8c096dc

Please sign in to comment.