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

Added integrations tests for checking workflow creation and update sc… #1

Open
wants to merge 4 commits into
base: composite-workflow
Choose a base branch
from

Conversation

stevanbz
Copy link

…enario

Signed-off-by: Stevan Buzejic buzejic.stevan@gmail.com

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.

…enario

Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com>
Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com>
Copy link
Owner

@eirsep eirsep left a 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 {
Copy link
Owner

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.

Copy link
Author

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

Copy link
Owner

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

Copy link
Author

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)
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

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

can this be uncommented?

Copy link
Author

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) }
Copy link
Owner

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?

Copy link
Owner

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"

Copy link
Author

@stevanbz stevanbz Feb 23, 2023

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
Copy link
Owner

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.

Copy link
Author

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`() {
Copy link
Owner

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`() {
Copy link
Owner

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`() {
Copy link
Owner

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`() {
Copy link
Owner

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

Copy link
Author

@stevanbz stevanbz Feb 23, 2023

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

@stevanbz
Copy link
Author

Thanks for the changes Stevan.

Took an initial look. Plz address these comments while I take a deeper look.

Tnx Will do so. Tnx for constructive feedback

…nitor index is not initialized yet. Added workflow crud test cases

Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com>
…e workflow

Signed-off-by: Stevan Buzejic <buzejic.stevan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants