Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RORDEV-1257] refactoring #11

Merged
merged 50 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9e1a957
wip
coutoPL Aug 16, 2024
1d194cf
Merge remote-tracking branch 'origin/master' into feature/RORDEV-1257
coutoPL Aug 28, 2024
4e24b13
wip
coutoPL Sep 2, 2024
2337a39
wip
coutoPL Sep 4, 2024
dc66a7c
check
coutoPL Sep 8, 2024
864f43e
check
coutoPL Sep 8, 2024
0b5e651
wip
coutoPL Sep 8, 2024
93203b7
wip
coutoPL Sep 8, 2024
1a1f877
Merge branch 'pipeline_fix_and_logging_improvement' into feature/RORD…
coutoPL Sep 8, 2024
d783cc3
wip
coutoPL Sep 14, 2024
25cae40
Merge remote-tracking branch 'origin/master' into feature/RORDEV-1257
coutoPL Sep 20, 2024
bc98106
fixes
coutoPL Sep 24, 2024
01299f7
wip
coutoPL Sep 24, 2024
beb972a
wip
coutoPL Sep 25, 2024
9022ffd
wip
coutoPL Sep 25, 2024
79ef7e0
wip
coutoPL Sep 26, 2024
35d421b
kibana ssl
coutoPL Sep 26, 2024
16e652e
wip
coutoPL Sep 28, 2024
b15373d
wip
coutoPL Sep 28, 2024
ec1fa1c
wip
coutoPL Sep 29, 2024
85a373b
wip
coutoPL Sep 30, 2024
448fadc
cy-task-verification
Dzuming Oct 1, 2024
7c0512c
fix issues
Dzuming Oct 1, 2024
ebc5869
improvements
coutoPL Oct 1, 2024
0945c0e
wip
coutoPL Oct 2, 2024
662e6ea
ECK test in gh actions
coutoPL Oct 3, 2024
37d248b
ECK test in gh actions
coutoPL Oct 3, 2024
4fe0ec5
fix
coutoPL Oct 3, 2024
1e540ca
ECK test in gh actions
coutoPL Oct 3, 2024
1055c0e
ECK test in gh actions
coutoPL Oct 3, 2024
c696f94
ECK test in gh actions
coutoPL Oct 3, 2024
6a12fef
ECK test in gh actions
coutoPL Oct 3, 2024
c28b5f2
ECK test in gh actions
coutoPL Oct 3, 2024
faceedd
ECK test in gh actions
coutoPL Oct 3, 2024
50d28ae
ECK test in gh actions
coutoPL Oct 3, 2024
dcbc776
ECK test in gh actions
coutoPL Oct 4, 2024
547174a
ECK test in gh actions
coutoPL Oct 4, 2024
6298845
ECK test in gh actions
coutoPL Oct 4, 2024
301e29c
ECK test in gh actions
coutoPL Oct 4, 2024
a54ca87
ECK test in gh actions
coutoPL Oct 4, 2024
4352ed4
ECK test in gh actions
coutoPL Oct 4, 2024
8422281
ECK test in gh actions
coutoPL Oct 5, 2024
57a5e40
cleanup
coutoPL Oct 5, 2024
0b47186
cleanup
coutoPL Oct 5, 2024
e78fd88
cleanup
coutoPL Oct 5, 2024
b71182f
cleanup
coutoPL Oct 5, 2024
d4dc8b0
clean up
coutoPL Oct 5, 2024
d0d1727
review fixes
coutoPL Oct 6, 2024
c1743f1
review fixes
coutoPL Oct 6, 2024
4fa7dae
lint
coutoPL Oct 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/trigger-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ jobs:
e2e-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: [8x, 7x]
version: ["8.15.2", "7.17.24"]
Dzuming marked this conversation as resolved.
Show resolved Hide resolved
env: [docker]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Run tests
run: ./run-${{ matrix.version }}.sh
run: ./run-env-and-tests.sh ${{ matrix.version }} ${{ matrix.env }}
env:
ROR_ACTIVATION_KEY: ${{ secrets.ROR_KBN_LICENSE }}
- name: S3 Upload Videos & show logs
Expand All @@ -27,4 +33,5 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws configure set region eu-west-1
aws s3 cp results/videos/ s3://readonlyrest-data/e2e-tests/build_${{ github.run_id }}/${{ matrix.version }}/ --recursive
aws s3 cp results/videos/ s3://readonlyrest-data/e2e-tests/build_${{ github.run_id }}/${{ matrix.env }}/${{ matrix.version }}/ --recursive

8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.DS_Store
elk-ror/elk-ror.log
**/.DS_Store
.idea
environments/**/*.log
environments/**/*.zip
environments/**/plugins
e2e-tests/node_modules
plugins/*
results/*
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Prerequisites:
To bootstrap a Docker-based test environment (ES with latest ROR + KBN with latest ROR) and run Cypress E2E tests run:

```bash
$ ./run-8x.sh
./run-env-and-tests.sh 8.15.2 docker
```

```bash
$ ./run-7x.sh
./run-env-and-tests.sh 7.17.24 docker
```

#### Tested environment & E2E tests separately
Expand All @@ -26,18 +26,18 @@ You can bootstrap the test env and run tests separately (to not build the ES+KBN

To run the env:
```bash
$ ./elk-ror/run.sh --es "8.10.0" --kbn "8.10.0"
./environments/elk-ror/start.sh --es "8.15.0" --kbn "8.15.2"
```

To run tests on the env:
```bash
$ ./e2e-tests/run.sh "8.10.0"
$ ./e2e-tests/run-tests.sh "8.15.2"
```

#### Cypress tests in interactive GUI

```bash
$ cd e2e-tests; yarn cypress open
$ cd e2e-tests; yarn cypress open --env kibanaVersion=[KBN_VERSION]
```

### In docker isolated environment
Expand All @@ -61,7 +61,7 @@ $ ./docker-based-ror-dev-env/runE2ETests7xInDocker.sh

### Test environment

The test environment is created with the Docker Compose. All code is located in the `elk-ror` folder. Currently, the latest version of ROR is downloaded for the sake of tests. In the future, we are going to improve it and build plugins from sources too.
The test environment is created with the Docker Compose. All code is located in the `environments/elk-ror` folder. Currently, the latest version of ROR is downloaded for the sake of tests. In the future, we are going to improve it and build plugins from sources too.

### Cypress tests

Expand Down
6 changes: 2 additions & 4 deletions docker-based-ror-dev-env/runInDocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ fi
docker run --rm $DIND_OPTIONS $DOCKER_RUN_OPTIONS \
-e ROR_ACTIVATION_KEY="$ROR_ACTIVATION_KEY" \
-v ./../e2e-tests:/app/e2e-tests \
-v ./../elk-ror:/app/elk-ror \
-v ./../enviroments/elk-ror:/app/enviroments/elk-ror \
-v ./../results:/app/results \
-v ./../run.sh:/app/run.sh \
-v ./../run-7x.sh:/app/run-7x.sh \
-v ./../run-8x.sh:/app/run-8x.sh \
-v ./../run-env-and-tests.sh:/app/run-env-and-tests.sh \
e2e-tests-dev-env:"$DOCKER_BASED_ROR_DEV_ENV_HASH" "$COMMAND"
4 changes: 2 additions & 2 deletions docker-based-ror-dev-env/src/processRorEnvCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ npm i -g yarn

case "$1" in
e2e-tests-7x )
/app/run-7x.sh
/app/run-env-and-tests.sh "7.17.24" "docker"
;;
e2e-tests-8x )
/app/run-8x.sh
/app/run-env-and-tests.sh "8.15.2" "docker"
;;
bash )
bash
Expand Down
8 changes: 4 additions & 4 deletions e2e-tests/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export default defineConfig({
login: 'admin',
password: 'dev',
kibanaVersion: 'KIBANA_VERSION_NOT_SET_YET',
elasticsearchUrl: 'http://localhost:19200',
elasticsearchUrl: 'https://localhost:9200',
enterpriseActivationKey: 'PROVIDE_YOUR_ACTIVATION_KEY',
kibanaUserCredentials: "kibana:kibana"
kibanaUserCredentials: 'kibana:kibana'
},
video: true,
screenshotOnRunFailure: true,
Expand All @@ -28,9 +28,9 @@ export default defineConfig({
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
// eslint-disable-next-line @typescript-eslint/no-var-requires,global-require
return require('./cypress/plugins/index.js')(on, config);
return require('./cypress/plugins/index.ts')(on, config);
},
baseUrl: 'http://localhost:5601',
baseUrl: 'https://localhost:5601',
videosFolder: '../results/videos',
screenshotsFolder: '../results/screenshots'
}
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/cypress/e2e/Activation-keys.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe.skip('Activation key', () => {

afterEach(() => {
cy.kbnPost({
endpoint: "api/ror/license?overwrite=true",
endpoint: 'api/ror/license?overwrite=true',
credentials: userCredentials,
payload: { license: `${Cypress.env().enterpriseActivationKey}` }
});
Expand Down
80 changes: 42 additions & 38 deletions e2e-tests/cypress/e2e/Direct-kibana-request.cy.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
import * as semver from 'semver';
import { getKibanaVersion, userCredentials } from '../support/helpers';
import { kbnApiAdvancedClient } from '../support/helpers/KbnApiAdvancedClient';
import { rorApiClient } from '../support/helpers/RorApiClient';

describe('Direct kibana request', () => {
const user = 'user1:dev';
const user1 = 'user1:dev';
const admin = 'admin:dev';

afterEach(() => {
const clearDirectKibanaRequestState = () => {
kbnApiAdvancedClient.deleteSavedObjects(user);
if (semver.gte(getKibanaVersion(), '8.0.0')) {
kbnApiAdvancedClient.deleteDataViews(user);
}
};
beforeEach(() => {
clearDirectKibanaRequestState();
rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml');
});

afterEach(() => {
clearDirectKibanaRequestState();
rorApiClient.configureRorIndexMainSettings('defaultSettings.yaml');
});

it('should check direct kibana request', () => {
const verifySavedObjects = () => {
kbnApiAdvancedClient.deleteSavedObjects(user);
kbnApiAdvancedClient.deleteSavedObjects(user1);

cy.log('Import saved objects for user1');
cy.kbnImport({
endpoint: "api/saved_objects/_import?overwrite=true",
credentials: user,
filename: 'cypress/fixtures/file.ndjson'
endpoint: 'api/saved_objects/_import?overwrite=true',
credentials: user1,
fixtureFilename: 'file.ndjson'
});

cy.log('Get imported saved objects for user1 Administrators group');
kbnApiAdvancedClient.getSavedObjects(user).then(result => {
kbnApiAdvancedClient.getSavedObjects(user1).then(result => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
})
expect(result.saved_objects).to.have.length(2);
});

cy.log('Get imported saved objects for admin Administrators group');
kbnApiAdvancedClient
.getSavedObjects(userCredentials)
.then(result => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(2);
});
kbnApiAdvancedClient.getSavedObjects(admin).then(result => {
expect(result.saved_objects[0].id).equal('my-pattern');
expect(result.saved_objects[1].id).equal('my-dashboard');
expect(result.saved_objects).to.have.length(2);
});

cy.log('Get imported saved objects for user1 infosec group');
kbnApiAdvancedClient.getSavedObjects(user, "infosec_group")
.then(result => {
const actual = result.saved_objects.some(
saved_object => saved_object.id === 'my-pattern' || saved_object.id === 'my-dashboard'
);
// eslint-disable-next-line no-unused-expressions
expect(actual).to.be.false;
});
kbnApiAdvancedClient.getSavedObjects(user1, 'infosec_group').then(result => {
const actual = result.saved_objects.some(
saved_object => saved_object.id === 'my-pattern' || saved_object.id === 'my-dashboard'
);
expect(actual).to.be.false;
});
};

const verifyDataViews = () => {
kbnApiAdvancedClient.deleteDataViews(user);
kbnApiAdvancedClient.deleteDataViews(user1);
cy.log('Create data_views for user1 Administrators group');
kbnApiAdvancedClient.createDataView(
{
Expand All @@ -64,22 +62,28 @@ describe('Direct kibana request', () => {
name: 'My Logstash Data View'
}
},
user
user1
);

cy.log('get all data_views for user1 infosec group');
kbnApiAdvancedClient
.getDataViews(userCredentials, "infosec_group")
.then(result => {
const actual = result.data_view.some(saved_object => saved_object.id === 'logstash');
// eslint-disable-next-line no-unused-expressions
expect(actual).to.be.false;
});
kbnApiAdvancedClient.getDataViews(userCredentials, 'infosec_group').then(result => {
const actual = result.data_view.some(saved_object => saved_object.id === 'logstash');
expect(actual).to.be.false;
});
};

verifySavedObjects();
if (semver.gte(getKibanaVersion(), '8.0.0')) {
verifyDataViews();
}
});

const clearDirectKibanaRequestState = () => {
kbnApiAdvancedClient.deleteSavedObjects(user1);
kbnApiAdvancedClient.deleteSavedObjects(admin);
if (semver.gte(getKibanaVersion(), '8.0.0')) {
kbnApiAdvancedClient.deleteDataViews(user1);
kbnApiAdvancedClient.deleteDataViews(admin);
}
};
});
4 changes: 2 additions & 2 deletions e2e-tests/cypress/e2e/Impersonate.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Login } from '../support/page-objects/Login';
import { Impersonate } from '../support/page-objects/Impersonate';
import { SecuritySettings } from '../support/page-objects/SecuritySettings';
import { KibanaNavigation } from '../support/page-objects/KibanaNavigation';
import { TestSettings } from '../support/page-objects/TestSettings';
import { Settings } from '../support/page-objects/Settings';
import { rorApiClient } from '../support/helpers/RorApiClient';

describe('impersonate', () => {
beforeEach(() => {
Expand All @@ -26,6 +25,7 @@ describe('impersonate', () => {
cy.log('should check service lists rendering');

Impersonate.setTestSettingsData();

TestSettings.open();
Impersonate.open();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { Login } from '../support/page-objects/Login';
import { Loader } from '../support/page-objects/Loader';
import { RorMenu } from '../support/page-objects/RorMenu';
import { Discover } from '../support/page-objects/Discover';
import defaultSettingsData from '../fixtures/defaultSettings.json';
import reportingSettingsData from '../fixtures/reportingSettings.json';
import { Settings } from '../support/page-objects/Settings';

describe('Reporting index', () => {
// todo: the test fails. Please fix me
describe.skip('Reporting index', () => {
Dzuming marked this conversation as resolved.
Show resolved Hide resolved
beforeEach(() => {
Settings.setSettingsData(reportingSettingsData);
Settings.setSettingsData('reportingSettings.yaml');
cy.visit(Cypress.config().baseUrl);
cy.on('url:changed', () => {
sessionStorage.setItem('ror:ignoreTrialInfo', 'true');
Expand All @@ -19,7 +18,7 @@ describe('Reporting index', () => {
});

afterEach(() => {
Settings.setSettingsData(defaultSettingsData);
Settings.setSettingsData('defaultSettings.yaml');
});

it('should correctly match index pattern when audit index_template contains .reporting', () => {
Expand Down
10 changes: 4 additions & 6 deletions e2e-tests/cypress/e2e/Sanity-check-ro-kibana-access.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Login } from '../support/page-objects/Login';
import { RoAndRoStrictKibanaAccessAssertions } from '../support/page-objects/RoAndRoStrictKibanaAccessAssertions';
import roSettings from '../fixtures/roSettings.json';
import { Settings } from '../support/page-objects/Settings';
import defaultSettings from '../fixtures/defaultSettings.json';
import { kbnApiClient, KbnApiClient } from '../support/helpers/KbnApiClient';
import { kbnApiClient } from '../support/helpers/KbnApiClient';
import { userCredentials } from '../support/helpers';

describe('sanity check ro kibana access', () => {
Expand All @@ -12,11 +10,11 @@ describe('sanity check ro kibana access', () => {
});

afterEach(() => {
Settings.setSettingsData(defaultSettings);
kbnApiClient.deleteSampleData("ecommerce", userCredentials, "template_group");
Settings.setSettingsData('defaultSettings.yaml');
kbnApiClient.deleteSampleData('ecommerce', userCredentials, 'template_group');
});

it('should verify that everything works', () => {
RoAndRoStrictKibanaAccessAssertions.runAssertions(roSettings);
RoAndRoStrictKibanaAccessAssertions.runAssertions('roSettings.yaml');
});
});
10 changes: 4 additions & 6 deletions e2e-tests/cypress/e2e/Sanity-check-ro_strict-kibana-access.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Login } from '../support/page-objects/Login';
import { RoAndRoStrictKibanaAccessAssertions } from '../support/page-objects/RoAndRoStrictKibanaAccessAssertions';
import roStrictSettings from '../fixtures/roStrictSettings.json';
import { Settings } from '../support/page-objects/Settings';
import defaultSettings from '../fixtures/defaultSettings.json';
import { kbnApiClient, KbnApiClient } from '../support/helpers/KbnApiClient';
import { kbnApiClient } from '../support/helpers/KbnApiClient';
import { userCredentials } from '../support/helpers';

describe('sanity check ro_strict kibana access', () => {
Expand All @@ -12,11 +10,11 @@ describe('sanity check ro_strict kibana access', () => {
});

afterEach(() => {
Settings.setSettingsData(defaultSettings);
kbnApiClient.deleteSampleData("ecommerce", userCredentials, "template_group");
Settings.setSettingsData('defaultSettings.yaml');
kbnApiClient.deleteSampleData('ecommerce', userCredentials, 'template_group');
});

it('should verify that everything works', () => {
RoAndRoStrictKibanaAccessAssertions.runAssertions(roStrictSettings);
RoAndRoStrictKibanaAccessAssertions.runAssertions('roStrictSettings.yaml');
});
});
8 changes: 4 additions & 4 deletions e2e-tests/cypress/e2e/Sanity-check.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { SampleData } from '../support/helpers/SampleData';

describe('sanity check', () => {
beforeEach(() => {
SampleData.createSampleData("sample_index", 1)
SampleData.createSampleData('sample_index', 1);
Login.initialization();
});

afterEach(() => {
esApiAdvancedClient.deleteIndex("sample_index");
kbnApiAdvancedClient.deleteSavedObjects("admin:dev");
kbnApiAdvancedClient.deleteSavedObjects("admin:dev", "infosec_group")
esApiAdvancedClient.deleteIndex('sample_index');
kbnApiAdvancedClient.deleteSavedObjects('admin:dev');
kbnApiAdvancedClient.deleteSavedObjects('admin:dev', 'infosec_group');
esApiAdvancedClient.pruneAllReportingIndices();
});

Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/cypress/e2e/Saved-objects.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Saved objects', () => {
});

afterEach(() => {
kbnApiAdvancedClient.deleteSavedObjects("admin:dev");
kbnApiAdvancedClient.deleteSavedObjects('admin:dev');
});

it('should display saved objects list', () => {
Expand Down
3 changes: 0 additions & 3 deletions e2e-tests/cypress/fixtures/defaultSettings.json

This file was deleted.

Loading
Loading