-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(tests): refactor sinkMain
and create tests
#897
base: main
Are you sure you want to change the base?
Conversation
8bd3057
to
50b681c
Compare
1e7ba2c
to
52525cd
Compare
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.
This all looks good to me. I think having someone with more experience/context with OS should add a final approval though.
@@ -13,18 +13,9 @@ | |||
}, |
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.
This is great, I assumed we were using most of these packages.
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.
Agreed, this is some great cleanup
@@ -1,14 +1,8 @@ | |||
import { Handler } from "aws-lambda"; | |||
import { KafkaRecord, opensearch } from "shared-types"; | |||
import { KafkaEvent } from "shared-types"; |
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.
combine this with the above import?
await handler( | ||
{ | ||
eventSource: "SelfManagedKafka", | ||
bootstrapServers: "b-1.master-msk.zf7e0q.c7.kafka.us-east-1.amazonaws.com:9094", |
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.
are these real endpoints? lets take these out if they're not needed
cc: @13bfrancis
@@ -0,0 +1,87 @@ | |||
import { describe, it, expect, vi, afterEach } from "vitest"; |
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'm wondering if we could use a function for the handler setup. Something like-
function createHandlerEvent(record) {
return {
eventSource: "SelfManagedKafka",
bootstrapServers: "kafka",
records: { [`"${record}"`]: [] },
};
}
and then in the tests-
await handler(createHandlerEvent("aws.onemac.migration.cdc-0"), expect.anything(), vi.fn());
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.
Overall I think this looks great. Some great refactoring to make it more testable, great removal of unused code and dependencies, and good tests. Like Tyler, I'll likely defer to someone with more familiarity with this part of the app for final approval, but this looks like great work to me.
kafkaRecords: KafkaRecord[], | ||
topicPartition: string, | ||
) => { | ||
const officers = async (kafkaRecords: KafkaRecord[], topicPartition: string) => { |
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.
Just curious, where does this const get its name from? Is "officers" a Kafka term, or does it have a OneMAC-specific meaning?
@@ -82,17 +82,45 @@ const prettyPrintJsonInObject = (obj: any): any => { | |||
return obj; | |||
}; | |||
|
|||
/** | |||
* Returns the `osDomain` and `indexNamespace` env variables. Passing `baseIndex` appends the arg to the `index` variable |
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.
Loving this documentation!
@@ -13,18 +13,9 @@ | |||
}, |
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.
Agreed, this is some great cleanup
Purpose
Improve
sinkMain
logic and write testsLinked Issues to Close
https://jiraent.cms.gov/browse/OY2-31425
Approach