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

ROR_INTR_001 #3

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

Conversation

lodyczekoladowe
Copy link

@lodyczekoladowe lodyczekoladowe commented Aug 14, 2024

Added test for generating rapports form data.

Task description

@lodyczekoladowe lodyczekoladowe marked this pull request as draft August 14, 2024 21:35
@lodyczekoladowe lodyczekoladowe marked this pull request as ready for review August 14, 2024 21:36
elk-ror/conf/kbn/kibana.yml Outdated Show resolved Hide resolved
elk-ror/conf/es/readonlyrest.yml Outdated Show resolved Hide resolved
e2e-tests/cypress.config.ts Show resolved Hide resolved
e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
e2e-tests/cypress/support/page-objects/Login.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,109 @@
// report-generation.spec.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I run the single test in cypress UI I got: "Invalid Version: NOT_SET_YET". I recall you had this problem. Could you please tell us how to solve it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use $ cd e2e-tests; yarn cypress open --env kibanaVersion=[kbnVersion], for example $ cd e2e-tests; yarn cypress open --env kibanaVersion=7.17.22.

README.md file

Cypress tests in interactive GUI

$ cd e2e-tests; yarn cypress open

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run it locally (8.14.3) and I got sth like this:
Screenshot 2024-09-02 at 18 40 46

@Dzuming could you please check on your side?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked for KBN 7.17.22 and it works. So it seems the problem is related to KBN 8.x

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can confirm. Seems that the test code should be adjusted to the Kibana 8.x -> We should change 8.4.3 to the 8.5.0 version since it's the newest supported version.

Report Generation -- should generate and verify reports for user2, and user3 should not see them (failed)

Report Generation -- should generate and verify reports for user2, and user3 should not see them (failed) (attempt 2)

Report Generation -- should generate and verify reports for user2, and user3 should not see them (failed) (attempt 3)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dzuming you meant 8.14.3 to 8.15.0? I will change it on the master branch
@lodyczekoladowe so, please take a look at the problem with this test in case of 8.x

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you meant 8.14.3 to 8.15.0?

Yes, exactly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in Fixes for new version of es

Copy link
Collaborator

@Dzuming Dzuming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments but looks promising

e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
e2e-tests/cypress/support/commands.ts Outdated Show resolved Hide resolved
e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
cy.get('tr[data-test-subj="reportJobRow"]').should('not.exist');
}

static deleteAllReports(reportTitle: string = 'Untitled discover search') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic seems super complicated and fragile based on the Kibana version. Maybe we can just use the curl command to remove the reporting index?
image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that it is not possible to delete these reports using the curl command.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lodyczekoladowe What about this comment?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that it is not possible to delete these reports using the curl command.

It should be possible (but also complicated). My proposal, was, to delete the reporting index by the Kibana Api
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html, thanks to it, all existing reports will be cleared

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That command delate index but don't delate reports. There is no curl command that deletes reports.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you remove an ..reporting index that stores reports, you also remove reports :)

@Dzuming
Copy link
Collaborator

Dzuming commented Aug 30, 2024

@lodyczekoladowe I can see that you resolved all comments, the good practice is to let resolve a comment from the person who started a conversation. Thanks to it it's easier to track if changes were applied or discuss further. If you resolve an issue, you can leave a message in a thread (for example "resolved"), and I, as a reviewer, will know that I can re-review this specific change. Also, as I see, some changes were not applied, without any comment. Could you leave some comments?

@lodyczekoladowe
Copy link
Author

@lodyczekoladowe I can see that you resolved all comments, the good practice is to let resolve a comment from the person who started a conversation. Thanks to it it's easier to track if changes were applied or discuss further. If you resolve an issue, you can leave a message in a thread (for example "resolved"), and I, as a reviewer, will know that I can re-review this specific change. Also, as I see, some changes were not applied, without any comment. Could you leave some comments?

Okay, I'll leave comments.

@lodyczekoladowe
Copy link
Author

@lodyczekoladowe I can see that you resolved all comments, the good practice is to let resolve a comment from the person who started a conversation. Thanks to it it's easier to track if changes were applied or discuss further. If you resolve an issue, you can leave a message in a thread (for example "resolved"), and I, as a reviewer, will know that I can re-review this specific change. Also, as I see, some changes were not applied, without any comment. Could you leave some comments?

Okay, I'll leave comments.

OK, it's done

}
}

static generateCsvReport(timeout: number = 50000) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently, we know nothing about the timeout unit. When you use a type that doesn't support it, it's a good practise to add a hint in the param name e.g. timeoutSeconds

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted

} else {
triger = 'CSV created for';
}
// Attempt to find the "Created report for" message within the timeout
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it should work a little bit differently. In this test, we want to check if many reports running at the same time are going to work as expected. In the past, we have a problem with it. When we run reports one by one (waiting for one finish before starting another) everything was OK. But when we run many reports (and the reports generation was scheduled by Kibana to be executed by a different node than the node where the report was scheduled on), there was a problem. This is what we want to test in this task.

So, we want to run many reports one after another. Then we should go to the view where the reports are shown (management sth view) and wait there for the generation finish. When at least one fails, the test should fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not possible with such a small amount of data—the tests finish too quickly. Since a toast notification pops up every time a report is added to the queue, we have to either remove it or wait for it to disappear, because soon the number of these notifications will block our access to generating new reports.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we talked:

  1. let's generate huge number of docs
  2. let's cut off the services resources

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in Self-generate invoices data, checking report generation process

@@ -0,0 +1,109 @@
// report-generation.spec.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can confirm. Seems that the test code should be adjusted to the Kibana 8.x -> We should change 8.4.3 to the 8.5.0 version since it's the newest supported version.

Report Generation -- should generate and verify reports for user2, and user3 should not see them (failed)

Report Generation -- should generate and verify reports for user2, and user3 should not see them (failed) (attempt 2)

Report Generation -- should generate and verify reports for user2, and user3 should not see them (failed) (attempt 3)

cy.get('tr[data-test-subj="reportJobRow"]').should('not.exist');
}

static deleteAllReports(reportTitle: string = 'Untitled discover search') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lodyczekoladowe What about this comment?

e2e-tests/cypress/e2e/Report-generation.cy.ts Outdated Show resolved Hide resolved
lodyczekoladowe and others added 10 commits September 21, 2024 20:34
# organization: beshu-tech
# username: ${{ github.actor }}
# token: ${{ secrets.GITHUB_TOKEN }}
pull_request:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see changes from my branch. For sure sth is wrong here.

items.forEach((item: any) => {
const createResult = item.create;
if (createResult.status === 201) {
console.log(`Invoice ${createResult._id} created successfully.`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to add it? It spams the console with not relevant information



before(() => {
dataPut(1000000, indexName, 600, 200);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dataPut" doesn't tell much about what it does


export async function dataPut(count: number, indexName: string, chunkSize: number, threads: number): Promise<void> {
count = count / 2;
if (typeof cy.kbnPut !== 'function') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we have to check it?

@@ -0,0 +1,177 @@
// invoices.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have SampleData class. Maybe we should add a function that generates invoices in some index there?

});
}

function createIndex(indexName: string): Cypress.Chainable<void> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ES API endpoint Typescript-cypress wrappers should be added in EsApiClient.ts

}).then((response: any) => {
console.log('Response:', response);
if (response) {
if (response.error && response.error.type === 'resource_already_exists_exception') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need to do this. We should just assert that the response returned 2xx.

const chunks = chunkArray(invoices, chunkSize);

const processChunk = async (chunk: any[], index: number) => {
cy.esPost({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the same - should be moved to EsApiClient

import { Reports } from "../support/page-objects/management/Reports";
import { dataPut } from "../support/page-objects/invoices";

describe('Report Generation', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the test - it's way too SLOOOOW.
Do we need so much data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants