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

#1722 - E2E Tests for assessment gateway #1822

Merged
merged 14 commits into from
Mar 22, 2023

Conversation

dheepak-aot
Copy link
Collaborator

@dheepak-aot dheepak-aot commented Mar 21, 2023

E2E Tests for Assessment Gateway

Assessment Gateway testing strategy

The assessment gateway workflow's primary responsibility is to obtain the necessary details of a student assessment w.r.t it's instance and validate the details to ensure the business process is followed and through a sequence of steps.

Ignoring the process of obtaining and updating the data, we are going to validate the orchestration of assessment gateway in the E2E Tests as per the student assessment and application details provided to the workflow.

E2E Scenarios tested

  • Assessment gateway on original assessment for a single independent student with no application exceptions and PIR not required.
  • Assessment gateway on student appeal(reassessment) for a single independent student.

Both the above scenarios are tested for all given program years.

How do we validate the workflow output

Assessment gateway output on Original assessment:

image

The highlighted blocks are verified in the e2e tests.

image

Assessment gateway output on Student appeal:

image

The highlighted blocks are verified in the e2e tests(the ones which are crossed out is verified as NOT to be passed through).

image

@dheepak-aot dheepak-aot changed the title E2e tests/camunda assessment gateway #1722 - E2E Tests for assessment gateway Mar 21, 2023
@dheepak-aot dheepak-aot self-assigned this Mar 21, 2023
@dheepak-aot dheepak-aot marked this pull request as ready for review March 21, 2023 07:42
zeebeClientProvider = ZeebeMockedClient.getMockedZeebeInstance();
});

it("Should follow the expected workflow path when student single and independent without application exception and PIR.", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

when student is single and independent without?

programYear: string,
): AssessmentConsolidatedData {
const [, programEndYear] = programYear.split("-");
const assessmentConsolidatedData =
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a qn here, next if we want to test a different set of info, for eg, TEST a "full time" assessment with a "dependent" status application, are we planning to make this method generic for all FT tests or are we planning to create "createFakeConsolidatedSOMETHINGFT". do we have a plan? or we are planning to figure it out on the way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The plan should be for e.g. TEST a "full time" assessment with a "dependent" if required only at a test case level, then it will be prepared at test case by using generic method and modifying it. Same if it is required at e2e test file level, then it can be prepared at beforeAll(), or else if it is required for multiple test files then createFakeConsolidatedSOMETHINGFT will be created at factory level.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, there is nothing against creating a new createFakeAssessmentConsolidatedData with some initial data as a baseline, for instance.

  • createFakeAssessmentConsolidatedDataForTwoParents
  • createFakeAssessmentConsolidatedDataWithDependents
  • createFakeAssessmentConsolidatedDataWithPartner
  • createFakeAssessmentConsolidatedDataForPIR
    Or have all of them as options on the createFakeAssessmentConsolidatedData
createFakeAssessmentConsolidatedData(options: {
    includeParent1SupportingData: boolean,
    includeParent2SupportingData: boolean,
    includePartnerSupportingData: boolean,
    generateDependents: numbers
})

// Based on this variable load consolidated data worker will
// return the application exception status.
[E2E_APPLICATION_EXCEPTION_STATUS]:
ApplicationExceptionStatus.Approved,
Copy link
Contributor

Choose a reason for hiding this comment

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

mm.. this is a happy path scenario, right? so why do we want to set this status? I may be missing something

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As we discussed, this is to simulate the happy path returned by the actual worker.

});
// Workflow instance expected to pass through associate workflow instance worker.
expect(
assessmentGatewayResponse.variables[Workers.AssociateWorkflowInstance],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would not mind having these ones created at the lib level and shared between the worker's application also.

@ZeebeWorker(Workers.AssociateWorkflowInstance

@@ -5,7 +5,7 @@ services:
environment:
- ZEEBE_BROKER_DATA_DISKUSAGECOMMANDWATERMARK=0.998
- ZEEBE_BROKER_DATA_DISKUSAGEREPLICATIONWATERMARK=0.999
- "JAVA_TOOL_OPTIONS=-Xms256m -Xmx256m"
- "JAVA_TOOL_OPTIONS=-Xms512m -Xmx512m"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it to reduce the memory consumption on the dev machine or GitHub action machines?
Can you please clarify which was the motivation around it?

Copy link
Collaborator Author

@dheepak-aot dheepak-aot Mar 22, 2023

Choose a reason for hiding this comment

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

When I created the docker-compose exclusively for testing, provided 256m to keep it light. But considering the number of workflow scenarios now tested and will be tested in future, increased it to 512m to ensure stability.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the other PR I would comment on that. I don't know how it was possible to run that with only 256m 😄

{
taskType: Workers.LoadAssessmentConsolidatedData,
taskHandler: (job) =>
job.complete(getMockConsolidatedData(job.variables)),
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot Mar 21, 2023

Choose a reason for hiding this comment

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

In general, what if we allow the assessment workflow to receive the completed mocked object to be returned by the worker?
For instance, if load-assessment-consolidated-data is supposed to return:

{
    "someVariable1": 123,
    "someVariable2": 444,
    "someVariableN": 555,
}

We can start the workflow with the payload as:

{
    "assessmentId": 1,
    "e2eLoadAssessmentConsolidatedDataResult": {
        "someVariable1": 123,
        "someVariable2": 444,
        "someVariableN": 555,
    }
}

The work from the worker method would be just to return the workflow variable e2eLoadAssessmentConsolidatedDataResult, thoughts?
In this example, we can still use the getMockConsolidatedData to support the data creation, but this would be part of the Arrange area of each test as needed.

The only point will be how we can handle mocks for jobs that are reused, for instance, income verification for the student and his parents. In this scenario, the job probably has some information about the id of the invoked worker task that can be used to differentiate one from another.

});
// Workflow instance expected to pass through associate workflow instance worker.
expect(
assessmentGatewayResponse.variables[Workers.AssociateWorkflowInstance],
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot Mar 21, 2023

Choose a reason for hiding this comment

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

Some workers are reused and then have the same task name, for instance, update-application-status can be called multiple times during the workflow execution. We can maybe use the service tasks id (also available on worker jobs object) to execute the asserts.

There are other cases where, for instance, a worker like create-income-request-task can be invoked by 1 to 3 tasks (Student+Parent1+Parent2). For this scenario, we may need to add something to the worker header, which will be a minor bpmn change, but with a great benefit IMO.

// as this is a reassessment.
expect(
assessmentGatewayResponse.variables[Workers.UpdateApplicationStatus],
).toBeUndefined();
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

import { Duration, ZBClient, ZBWorkerConfig } from "zeebe-node";
import { ApplicationExceptionStatus, ProgramInfoStatus } from "@sims/sims-db";
import { Workers } from "../constants/worker-constants";

Copy link
Contributor

@ann-aot ann-aot Mar 21, 2023

Choose a reason for hiding this comment

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

mm, I need a walk-through of this file logic

@@ -0,0 +1,18 @@
export enum WorkflowServiceTasks {
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

},
requestTimeout: PROCESS_INSTANCE_CREATE_TIMEOUT,
});
expectToPassthroughServiceTasks(
Copy link
Contributor

Choose a reason for hiding this comment

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

expectToPassThroughServiceTasks?

* @param workflowResultVariables workflow result variables
* @param serviceTasks service tasks to verify.
*/
export function expectNotToPassthroughServiceTasks(
Copy link
Contributor

@ann-aot ann-aot Mar 22, 2023

Choose a reason for hiding this comment

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

caps expectNotToPassThroughServiceTasks

Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

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

just 2 minor comments. Look Great and awesome work 👍 and thanks for the walkthrough

assessmentTriggerType: AssessmentTriggerType.OriginalAssessment,
...createFakeSingleIndependentStudentData(),
// Application with no exception.
applicationExceptionStatus: ApplicationExceptionStatus.Approved,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this data not expected to be mocked on verify-application-exceptions-task-result?

Copy link
Collaborator

@andrepestana-aot andrepestana-aot left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the explanation in the sync up meeting!

@@ -5,7 +5,7 @@ services:
environment:
- ZEEBE_BROKER_DATA_DISKUSAGECOMMANDWATERMARK=0.998
- ZEEBE_BROKER_DATA_DISKUSAGEREPLICATIONWATERMARK=0.999
- "JAVA_TOOL_OPTIONS=-Xms256m -Xmx256m"
- "JAVA_TOOL_OPTIONS=-Xms512m -Xmx512m"
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the other PR I would comment on that. I don't know how it was possible to run that with only 256m 😄

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot 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 doing the changes and for the nice conversations and ideas exchanged during the development. A really great achievement for the project.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.99% ( 1947 / 10822 )
Methods: 8.19% ( 115 / 1404 )
Lines: 20.67% ( 1703 / 8238 )
Branches: 10.93% ( 129 / 1180 )

@github-actions
Copy link

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 56.72% ( 308 / 543 )
Methods: 46.38% ( 32 / 69 )
Lines: 59.48% ( 276 / 464 )
Branches: 0% ( 0 / 10 )

@github-actions
Copy link

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 30.87% ( 163 / 528 )
Methods: 20.51% ( 16 / 78 )
Lines: 37.66% ( 145 / 385 )
Branches: 3.08% ( 2 / 65 )

@github-actions
Copy link

E2E SIMS API Coverage Report

Totals Coverage
Statements: 36.26% ( 2429 / 6699 )
Methods: 27.7% ( 241 / 870 )
Lines: 41.89% ( 2093 / 4997 )
Branches: 11.42% ( 95 / 832 )

@dheepak-aot dheepak-aot merged commit 7e084e3 into main Mar 22, 2023
@dheepak-aot dheepak-aot temporarily deployed to DEV March 22, 2023 22:34 — with GitHub Actions Inactive
@dheepak-aot dheepak-aot temporarily deployed to DEV March 22, 2023 22:34 — with GitHub Actions Inactive
@dheepak-aot dheepak-aot temporarily deployed to DEV March 22, 2023 22:45 — with GitHub Actions Inactive
@dheepak-aot dheepak-aot deleted the e2e-tests/camunda-assessment-gateway branch March 23, 2023 17:11
guru-aot pushed a commit that referenced this pull request Mar 28, 2023
E2E Tests for assessment gateway
guru-aot pushed a commit that referenced this pull request Mar 28, 2023
E2E Tests for assessment gateway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants