-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-9790. Add tests for Overview page #6983
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
Conversation
|
@ivandika3 Could you please take a look at this. |
|
Thanks @devabhishekpal for the patch and @ArafatKhan2198 for the review request. This is a good step to enable automated testing on UI and something I personally look forward to. Once UI unit tests is done, we can consider to enable UI e2e testing (using things like puppeteer / cypress / playwright). I'm still trying to read the relevant documentations regarding the unit test frameworks since I'm not familiar with UI unit tests before, so I might need some more time. @ArafatKhan2198 @dombizita @smitajoshi12 @devmadhuu Meanwhile, I think it's good to start familiarizing ourselves with the UI unit tests (and UI in general) so that we can review the related tests meaningful. |
That's a great point @ivandika3. It is absolutely necessary to go through them. |
|
Thanks @devabhishekpal for taking this initiative. Thanks @ivandika3 for patching me. Let me get some idea about this patch and test library. |
devmadhuu
left a comment
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.
@devabhishekpal , few basic doubts:
-
As I understand these UI tests and the framework for Recon pages are unit tests which mocks the API calls and mainly we are testing 2 assertions with each card on page, one is if card is visible and another if mocked intercepted data is matching with data on card, so can we also expand the tests on this page for negative scenarios like:
a. If API fails to provide data , what the page behaviour should be. -
For UI tests, we also need to mainly deal with how the look & feel including color, width, height dimensions etc. E.g. if we have multiple components on a single page, how they will together be laid out and not overlapping or any other UI related issue like tooltip overlapping etc. This layout testing is very important part of our UI test because we have observed in past that with some PR change, it has broken layout settings or impacted on some other component. We should prioritise this.
-
Does this test framework will cover pnpm build failure before actually being tested in CI. Currently we have seen that pnpm version and compatibility issues arise out in CI once changes being pushed.
-
Are we still pushing static pnpm lock file ? If yes, t hen can we prioritise this to be built dynamically as part of CI build. This we discussed with @smitajoshi12 few months back.
-
Basic smoke tests for UI should be given priority first based on config flags , whether that is broken due to any UI PR change or not like if some nav item to be visible or not etc.
|
Hi @devmadhuu, thanks a lot for asking:
|
|
ivandika3
left a comment
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.
@devabhishekpal Thanks for kickstarting the UI unit test initiative. Overall looks good. Left a few comments.
...ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/Overview.test.tsx
Outdated
Show resolved
Hide resolved
...ne/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/locators/locators.ts
Show resolved
Hide resolved
...ces/webapps/recon/ozone-recon-web/src/__tests__/mocks/overviewMocks/overviewResponseMocks.ts
Outdated
Show resolved
Hide resolved
...p-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/vitest.setup.ts
Show resolved
Hide resolved
|
Hello, it took me some time to get back to introducing these tests. Sorry for the delay. @ivandika3 Thanks for pointing out the issues. @devmadhuu I have parameterized the tests to run on both positive as well as negative scenario. Please do take another look and let me know your inputs. Thanks a lot for taking the time to review this PR. |
ivandika3
left a comment
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 update. LGTM overall, left few more comments.
...ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/Overview.test.tsx
Outdated
Show resolved
Hide resolved
...p-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/vitest.setup.ts
Outdated
Show resolved
Hide resolved
...ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/Overview.test.tsx
Outdated
Show resolved
Hide resolved
|
Thanks for the review @ivandika3 Addressed the issues you pointed out. |
ivandika3
left a comment
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.
@devabhishekpal Thanks for the patch. LGTM +1.
|
@devabhishekpal Thanks for the patch, @devmadhuu @ArafatKhan2198 for the reviews. |
* master: (50 commits) HDDS-11331. Fix Datanode unable to report for a long time (apache#7090) HDDS-11346. FS CLI gives incorrect recursive volume deletion prompt (apache#7102) HDDS-11349. Add NullPointer handling when volume/bucket tables are not initialized (apache#7103) HDDS-11209. Avoid insufficient EC pipelines in the container pipeline cache (apache#6974) HDDS-11284. refactor quota repair non-blocking while upgrade (apache#7035) HDDS-9790. Add tests for Overview page (apache#6983) HDDS-10904. [hsync] Enable PutBlock piggybacking and incremental chunk list by default (apache#7074) HDDS-11322. [hsync] Block ECKeyOutputStream from calling hsync and hflush (apache#7098) HDDS-11325. Intermittent failure in TestBlockOutputStreamWithFailures#testContainerClose (apache#7099) HDDS-11340. Avoid extra PubBlock call when a full block is closed (apache#7094) HDDS-11155. Improve Volumes page UI (apache#7048) HDDS-11324. Negative value preOpLatencyMs in DN audit log (apache#7093) HDDS-11246. [Recon] Use optional chaining instead of explicit undefined check for Objects in Container and Pipeline Module. (apache#7037) HDDS-11323. Mark TestLeaseRecovery as flaky HDDS-11338. Bump zstd-jni to 1.5.6-4 (apache#7085) HDDS-11337. Bump Spring Framework to 5.3.39 (apache#7084) HDDS-11327. [hsync] Revert config default ozone.fs.hsync.enabled to false (apache#7079) HDDS-11325. Mark testWriteMoreThanMaxFlushSize as flaky HDDS-11336. Bump slf4j to 2.0.16 (apache#7086) HDDS-11335. Bump exec-maven-plugin to 3.4.1 (apache#7087) ... Conflicts: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
* master: (50 commits) HDDS-11331. Fix Datanode unable to report for a long time (apache#7090) HDDS-11346. FS CLI gives incorrect recursive volume deletion prompt (apache#7102) HDDS-11349. Add NullPointer handling when volume/bucket tables are not initialized (apache#7103) HDDS-11209. Avoid insufficient EC pipelines in the container pipeline cache (apache#6974) HDDS-11284. refactor quota repair non-blocking while upgrade (apache#7035) HDDS-9790. Add tests for Overview page (apache#6983) HDDS-10904. [hsync] Enable PutBlock piggybacking and incremental chunk list by default (apache#7074) HDDS-11322. [hsync] Block ECKeyOutputStream from calling hsync and hflush (apache#7098) HDDS-11325. Intermittent failure in TestBlockOutputStreamWithFailures#testContainerClose (apache#7099) HDDS-11340. Avoid extra PubBlock call when a full block is closed (apache#7094) HDDS-11155. Improve Volumes page UI (apache#7048) HDDS-11324. Negative value preOpLatencyMs in DN audit log (apache#7093) HDDS-11246. [Recon] Use optional chaining instead of explicit undefined check for Objects in Container and Pipeline Module. (apache#7037) HDDS-11323. Mark TestLeaseRecovery as flaky HDDS-11338. Bump zstd-jni to 1.5.6-4 (apache#7085) HDDS-11337. Bump Spring Framework to 5.3.39 (apache#7084) HDDS-11327. [hsync] Revert config default ozone.fs.hsync.enabled to false (apache#7079) HDDS-11325. Mark testWriteMoreThanMaxFlushSize as flaky HDDS-11336. Bump slf4j to 2.0.16 (apache#7086) HDDS-11335. Bump exec-maven-plugin to 3.4.1 (apache#7087) ... Conflicts: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeConfiguration.java hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
…an-on-error * HDDS-10239-container-reconciliation: (428 commits) HDDS-11081. Use thread-local instance of FileSystem in Freon tests (apache#7091) HDDS-11333. Avoid hard-coded current version in upgrade/xcompat tests (apache#7089) Mark TestPipelineManagerMXBean#testPipelineInfo as flaky Mark TestAddRemoveOzoneManager#testForceBootstrap as flaky HDDS-11352. HDDS-11353. Mark TestOzoneManagerHAWithStoppedNodes as flaky HDDS-11354. Mark TestOzoneManagerSnapshotAcl#testLookupKeyWithNotAllowedUserForPrefixAcl as flaky HDDS-11355. Mark TestMultiBlockWritesWithDnFailures#testMultiBlockWritesWithIntermittentDnFailures as flaky HDDS-11227. Use server default key provider to encrypt/decrypt keys from multiple OMs. (apache#7081) HDDS-11316. Improve Create Key and Chunk IO Dashboards (apache#7075) HDDS-11239. Fix KeyOutputStream's exception handling when calling hsync concurrently (apache#7047) HDDS-11254. Reconcile commands should be handled by datanode ReplicationSupervisor (apache#7076) HDDS-11331. Fix Datanode unable to report for a long time (apache#7090) HDDS-11346. FS CLI gives incorrect recursive volume deletion prompt (apache#7102) HDDS-11349. Add NullPointer handling when volume/bucket tables are not initialized (apache#7103) HDDS-11209. Avoid insufficient EC pipelines in the container pipeline cache (apache#6974) HDDS-11284. refactor quota repair non-blocking while upgrade (apache#7035) HDDS-9790. Add tests for Overview page (apache#6983) HDDS-10904. [hsync] Enable PutBlock piggybacking and incremental chunk list by default (apache#7074) HDDS-11322. [hsync] Block ECKeyOutputStream from calling hsync and hflush (apache#7098) HDDS-11325. Intermittent failure in TestBlockOutputStreamWithFailures#testContainerClose (apache#7099) ... Conflicts: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainerCheck.java hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java
…rrupt-files * HDDS-10239-container-reconciliation: (61 commits) HDDS-11081. Use thread-local instance of FileSystem in Freon tests (apache#7091) HDDS-11333. Avoid hard-coded current version in upgrade/xcompat tests (apache#7089) Mark TestPipelineManagerMXBean#testPipelineInfo as flaky Mark TestAddRemoveOzoneManager#testForceBootstrap as flaky HDDS-11352. HDDS-11353. Mark TestOzoneManagerHAWithStoppedNodes as flaky HDDS-11354. Mark TestOzoneManagerSnapshotAcl#testLookupKeyWithNotAllowedUserForPrefixAcl as flaky HDDS-11355. Mark TestMultiBlockWritesWithDnFailures#testMultiBlockWritesWithIntermittentDnFailures as flaky HDDS-11227. Use server default key provider to encrypt/decrypt keys from multiple OMs. (apache#7081) HDDS-11316. Improve Create Key and Chunk IO Dashboards (apache#7075) HDDS-11239. Fix KeyOutputStream's exception handling when calling hsync concurrently (apache#7047) HDDS-11254. Reconcile commands should be handled by datanode ReplicationSupervisor (apache#7076) HDDS-11331. Fix Datanode unable to report for a long time (apache#7090) HDDS-11346. FS CLI gives incorrect recursive volume deletion prompt (apache#7102) HDDS-11349. Add NullPointer handling when volume/bucket tables are not initialized (apache#7103) HDDS-11209. Avoid insufficient EC pipelines in the container pipeline cache (apache#6974) HDDS-11284. refactor quota repair non-blocking while upgrade (apache#7035) HDDS-9790. Add tests for Overview page (apache#6983) HDDS-10904. [hsync] Enable PutBlock piggybacking and incremental chunk list by default (apache#7074) HDDS-11322. [hsync] Block ECKeyOutputStream from calling hsync and hflush (apache#7098) HDDS-11325. Intermittent failure in TestBlockOutputStreamWithFailures#testContainerClose (apache#7099) ... Conflicts: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java
What changes were proposed in this pull request?
HDDS-9790. Add tests for Overview page
Please describe your PR in detail:
-Currently we don't have any tests for Recon UI. This increases manual effort for validating UI fixes/changes.
Reference for quick overview on the frameworks:
ReactTestingLibrary
React Testing Library is a lightweight testing library built on top of the DOM Testing Library for React components.
It focuses on the functionality of the component in contrast to the actual implementation of the component. This ensures that no matter how we implement our components and no matter the changes, we can ensure a consistent functionality.
It can work with any test runner, but we are using Jest as the preferred runner in this case.
Vitest
Vitest is a testing framework which also acts as a runner for our tests, allowing us to implement various testing methods and provide a way to interact with the virtual DOM to verify and assert conditions. It also has many built in features like mocking functions, generating coverage etc. allowing us to focus on the testing, rather than the implementation.
MSW
Mock Service Worker is a API mocking library that allows us to intercept API calls, and provide mocks for the same. It is independent of the client, framework and environment - this means we can run it anywhere independently.
How are we setting up our tests?
The main configuration for our tests start with configuring Vitest, this will be added under the vite.config.ts file's
testsection.Under this test section we are calling the vitest.setup.ts file to run initially to import missing Window functions as jsdom doesn't provide them as a part of the virtual DOM and also we are importing the jest-dom vitest types which allows us to use jest assertions like
toBeVisible(),toHaveTextContent()etc in our tests.Reference Documentations for reading:
Vitest: https://v1.vitest.dev/
React Testing Library: https://testing-library.com/docs/react-testing-library/intro/
MSW: https://mswjs.io/docs/getting-started
How to run the tests
In order to run the tests we follow the below steps:
pnpm installin the project root (this will install all the test dependencies)pnpm test(this will call thevitestcommand and run the tests)How to add new tests
We can add any other tests to the
__tests__folder inside the src directory.Follow the naming convention of
<component-name>.test.tsxAny requests or API calls can be mocked using MSW and can be called to start listening in the beforeAll() method for the tests. This will allow it to intercept any API calls and return a mock data for the same.
Make sure to stop the listener in the cleanup function i.e. afterAll() in this case
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-9790
How was this patch tested?
This patch was tested manually
