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

[Security GenAI] Fix and un-skip Knowledge Base Integration Tests #198558

Closed
wants to merge 7 commits into from

Conversation

e40pud
Copy link
Contributor

@e40pud e40pud commented Oct 31, 2024

Summary

This is a followup to #198178 where we skipped KB integration tests. We enable it with this PR.

Since it takes a lot of time to setup all Security Labs docs, the idea is to call the setup KB route without waiting it to finish the whole job. Instead we would monitor the KB status and wait for inference endpoint (model) to be deployed. For that we monitor elser_exists status attribute which I updated to hold is model deployed instead of is model installed state. confirmed with @patrykkopycinski that that is a more accurate representation of the KB readiness.

@e40pud e40pud added release_note:skip Skip the PR/issue when compiling release notes v9.0.0 Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Security Generative AI Security Generative AI v8.16.0 backport:version Backport to applied version labels v8.17.0 labels Oct 31, 2024
@e40pud e40pud self-assigned this Oct 31, 2024
const setupAvailable = await kbDataClient.isSetupAvailable();
const isModelDeployed = await kbDataClient.isModelDeployed();

const body: ReadKnowledgeBaseResponse = {
elser_exists: modelExists,
elser_exists: isModelDeployed,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use elser_exists to see the KB readiness and is model deployed represents that more accurate than is model installed state.

@e40pud e40pud marked this pull request as ready for review October 31, 2024 16:12
@e40pud e40pud requested review from a team as code owners October 31, 2024 16:12
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

await waitFor(
async () => {
const status = await getKnowledgeBaseStatus(supertest, log);
return !!status.elser_exists;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here we wait for the KB to be ready to receive entry API calls.

before(async () => {
await installTinyElser(ml);
await setupKnowledgeBase(supertest, log);
setupKnowledgeBase(supertest, log);
await waitForKnowledgeBaseModelToBeDeployed(supertest, log);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does waiting for the knowledge base setup take up to 10 minutes? If so, I think we should find a way to not install all of the security docs for this test. Perhaps there is a way to use the test framework to mock the directory where the documents are installed from, and only install one document?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that will be a good option as well. I will explore this.

Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, below this there is an afterEach with clearKnowledgeBase that deletes all of the knowledge base documents, so it is extra silly to wait 10 minutes to install them. And setupKnowledgeBase only happens once

@e40pud
Copy link
Contributor Author

e40pud commented Nov 4, 2024

Closing in favour of #198861

@e40pud e40pud closed this Nov 4, 2024
@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 4, 2024

💔 Build Failed

Failed CI Steps

Metrics [docs]

✅ unchanged

History

cc @e40pud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.16.0 v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants