Implement UnderFileSystemFactoryRegistryRule

Description

In unit tests, you may see code patterns like this (e.g., in tests/src/test/java/alluxio/master/file/ConcurrentFileSystemMasterCreateTest.java)

This purpose of this code block is to register a Factory before the test, and remove it after the tests. UnderFileSystemFactoryRegistry is a singleton and requires developers to be extra careful to setup and tear down. Otherwise, the state will be carried over to the next test.

This JIRA aims to make it cleaner by following the pattern of alluxio.LoginUserRule (core/common/src/test/java/alluxio/LoginUserRule.java), which is better / recommended way in Java unit tests to set and restore a static global value during this tests.
This JIRA proposes to create UnderFileSystemFactoryRegistryRule like LoginUserRule that add a new factory, and later on remove this factory.

The implementation of UnderFileSystemFactoryRegistryRule should be similar to https://github.com/Alluxio/alluxio/pull/5686/

Environment

None
Your pinned fields
Click on the next to a field label to start pinning.

Assignee

Mingdi Mao

Reporter

Bin Fan

Labels