-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added integrations tests for checking workflow creation and update sc… #1
base: composite-workflow
Are you sure you want to change the base?
Added integrations tests for checking workflow creation and update sc… #1
Conversation
…enario Signed-off-by: Stevan Buzejic <[email protected]>
Signed-off-by: Stevan Buzejic <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes Stevan.
Took an initial look. Plz address these comments while I take a deeper look.
@@ -1,4 +1,3 @@ | |||
package org.opensearch.alerting.model.workflow | |||
|
|||
data class WorkflowRunResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should return list of monitor run results within this class with info from each delegate monitor run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should return list of monitor run results within this class with info from each delegate monitor run.
Yeah - I agree. That's in another PR that contains execution of the workflow changes. Check it out here
import org.opensearch.rest.RestStatus | ||
import org.opensearch.tasks.Task | ||
import org.opensearch.transport.TransportService | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add java docs for classes and comments for methods having complicated logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. This class is pretty much obvious and the methods inside it are pretty much descriptive. So probably for indexing the workflow
|
||
val user = readUserFromThreadContext(client) | ||
val deleteRequest = DeleteRequest(ScheduledJob.SCHEDULED_JOBS_INDEX, transformedRequest.workflowId) | ||
.setRefreshPolicy(transformedRequest.refreshPolicy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz remove refresh policy
we will always choose to refresh immediately.
|
||
if (canDelete) { | ||
val deleteResponse = deleteWorkflow(workflow) | ||
// TODO - uncomment once the workflow metadata is added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be uncommented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well no - because the workflow metadata are not added still
} | ||
|
||
private suspend fun deleteWorkflow(workflow: Workflow): DeleteResponse { | ||
return client.suspendUntil { delete(deleteRequest, it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are we handling failure in deletion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add debug logs "deleted monitor $monitorId"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how are we handling failure in deletion?
Well we are calling delete(deleteRequest, it) as a lambda. You can see that second parameter of delete function call is it -> which is ActionListener forwarded to a delete function.
Something similar we are doing here
suspend fun validateRequest(request: IndexWorkflowRequest, listener: ActionListener<IndexWorkflowResponse>) { | ||
val compositeInput = request.workflow.inputs.get(0) as CompositeInput | ||
suspend fun validateRequest(request: IndexWorkflowRequest) { | ||
val compositeInput = request.workflow.inputs[0] as CompositeInput |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets first validate that the input is a composite input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
assertEquals("Delegate1 id not correct", monitorResponse1.id, delegate1.monitorId) | ||
} | ||
|
||
fun `test get workflow`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test get workflow for invalid id?
assertEquals("Delegate id not correct", monitorResponse.id, delegate.monitorId) | ||
} | ||
|
||
fun `test delete workflow`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test delete workflow for invalid id
} | ||
} | ||
|
||
fun `test create workflow duplicate delegate failure`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test update for all these failure cases
} | ||
} | ||
|
||
fun `test create workflow chained findings order not correct failure`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test delete monitor before workflow is deleted and this monitor is delegate in that sequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. will test that. will also need to update a logic on the side of monitor deletion
Tnx Will do so. Tnx for constructive feedback |
…nitor index is not initialized yet. Added workflow crud test cases Signed-off-by: Stevan Buzejic <[email protected]>
…e workflow Signed-off-by: Stevan Buzejic <[email protected]>
…enario
Signed-off-by: Stevan Buzejic [email protected]
Issue #, if available:
Description of changes:
CheckList:
[ ] Commits are signed per the DCO using --signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.