-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Frontend] unit tests for node server #2745
[Frontend] unit tests for node server #2745
Conversation
Hi @eterna2. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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'll look into details later, but your efforts are really appreciated.
Thanks a lot!
/ok-to-test
359cb17
to
c28391f
Compare
I need break up the big |
@eterna2 Thanks, that sounds reasonable. Note that there are some ongoing work on https://github.com/kubeflow/pipelines/pull/2690/files which also touches node server. Beware of that and I recommend don't do too much refactoring that may conflict with it. |
383160b
to
46c31f4
Compare
Summary of changes:
Impacts on other PRs
TODOs (in future PR?)
|
I updated And updated This shld fix the docker build errors. |
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.
Looks good overall.
Left some minor comments.
frontend/server/app.ts
Outdated
app: Application; | ||
httpServer?: Server; | ||
|
||
constructor(public readonly options: IConfigs) { |
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 not familiar with node common patterns, is using constructor with heavy initialization logic common?
I'd personally prefer using a pure function, e.g. initUIServer(options)
to create an instance of UIServer. Extra benefit is that, the creator function can be async too (I guess it's arguable whether we need this or not).
This is just discussion. What do you think?
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.
classes are just syntactic sugars in js. I think there are no right common patterns (as in it is fine either way).
The main reason I did this is so that I write less code in my unit test. It is easier for me to do the setup and teardown if I only need to track a single object. But I probably can do the same with httpServer
thou.
But I think this is perfectly fine too.
const app = initUIServer(options);
const server = app.listen(options.port, ()=>console.info(`listening to port:${port}.`);
server.close();
/test kubeflow-pipeline-sample-test |
…n be written more easily.
aebd6ff
to
82fef67
Compare
|
kubeflow-pipeline-sample-test test is flaky, we can retry later |
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 contribution! Having these tests in place will raise confidence and productivity of future development of this node server. Thanks for filling in the missing piece!
I finished the thorough review and left some (mostly minor) comments. Feel free to argue back as you see reasonable.
@eterna2 Here's how to integrate these tests in our CI. This is the entrypoint for kubeflow-pipeline-frontend-test: pipelines/frontend/package.json Line 60 in 488805c
You can add an entry for calling server unit tests. It's fine doing it without coverage report. I can add coverage data later. |
Resolved all ur comments. Rewrote pod logs handler to be more functional. And added corresponding unit tests. Also updated test:prow. |
Awesome, I will review today |
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 contribution again!
/lgtm
/approve
frontend/server/minio-helper.test.ts
Outdated
(awsInstanceProfileCredentials.ok as jest.Mock).mockClear(); | ||
(MinioClient as any).mockReset(); | ||
(awsInstanceProfileCredentials.getCredentials as jest.Mock).mockReset(); | ||
(awsInstanceProfileCredentials.ok as jest.Mock).mockReset(); |
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 you use https://jestjs.io/docs/en/jest-object#jestresetallmocks instead?
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.
ok fixed all the tests.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Bobgy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold |
/test kubeflow-pipeline-e2e-test |
/hold cancel |
/lgtm |
* Add unit tests for aws-helper and minio-helper. * Break up server.ts into app.ts and handlers/*.ts so that unit test can be written more easily. * update @types/node because of microsoft/TypeScript#32333 * upgrade kubernete-client version to be compatible with new @types/node version * fix bug: AWSInstanceProfileCredentials.profile() returns a promise not a string * remove I prefix from interfaces. minor fixes on lint errors. * fix format errors * Added more unit tests, and minor fixes. * Fix comment: GKS should be GKE * use jest.resetAllMocks instead of reset each mock individually * fix format for helper test
WIP: Adding basic unit tests for frontend node server.
PS: I noted some errors inside because seems like my new deployment cannot access the pod logs from my S3 buckets. Writing some unit tests to narrow down where are the bugs (could be my deployment issue also - cuz it worked last time, stop working after I upgrade the version).
See #2407
cc: @Bobgy
This change is