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

PHOENIX-7081 : Replace /tmp with {java.io.tmpdir} in tests #1808

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Divneet18
Copy link
Contributor

No description provided.

@@ -89,6 +89,7 @@

@Category(ParallelStatsDisabledTest.class)
public class CreateTableIT extends ParallelStatsDisabledIT {
private static final String filePath = System.getProperty("java.io.tmpdir");
Copy link
Contributor

Choose a reason for hiding this comment

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

This name is not descriptive.
tmpPath would be better (in each file)

@@ -1557,7 +1558,7 @@ public void testCoprocessorsForCreateIndexOnOldImplementation() throws Exception
// Now roll back to the old indexing
IndexUpgradeTool iut =
new IndexUpgradeTool(ROLLBACK_OP, tableName, null,
"/tmp/index_upgrade_" + UUID.randomUUID().toString(), false, null,
filePath + "/index_upgrade_" + UUID.randomUUID().toString(), false, null,
Copy link
Contributor

Choose a reason for hiding this comment

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

In the Hadoop Tools, path parameters are some times HDFS paths, so that is a case where simple "/tmp" is the right solution.
Those are also separate HDFS file systems, so there is no danger of coliision.

Have you checked that all of these instances are used as local paths, as opposed to HadoopFS paths ?

(I have checked this one, and this is correct, as this is a local FS path)

@Divneet18 Divneet18 requested a review from stoty February 2, 2024 20:37
@@ -62,7 +62,7 @@ public class CsvBulkLoadToolIT extends BaseOwnClusterIT {

private static Connection conn;
private static String zkQuorum;
private static final String filePath = System.getProperty("java.io.tmpdir");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a HDFS path. not a local path.
This should NOT use java.io.tmpdir.

Please check each changed test to make sure that only local paths use java.io.tmpdir, and not HadoopFS paths.

@@ -739,7 +740,7 @@ private int startIndexRebuilds(HashMap<String, IndexInfo> indexInfos,
String tenantId = indexInfo.getTenantId();
String baseTable = indexInfo.getBaseTable();
String schema = indexInfo.getSchemaName();
String outFile = "/tmp/index_rebuild_" +schema+"_"+ indexName +
String outFile = tmpPath + "/index_rebuild_" +schema+"_"+ indexName +
Copy link
Contributor

Choose a reason for hiding this comment

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

This one eventually becomes an HadoopFS path.

Copy link
Contributor

@stoty stoty left a comment

Choose a reason for hiding this comment

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

Please fix IndexUpgradeTool

Copy link
Contributor

@stoty stoty left a comment

Choose a reason for hiding this comment

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

Please verify EACH path instance, as I wrote above.

@@ -249,7 +250,7 @@ private int loadData(Configuration conf, CommandLine cmdLine) throws Exception {
if (cmdLine.hasOption(OUTPUT_PATH_OPT.getOpt())) {
outputPath = new Path(cmdLine.getOptionValue(OUTPUT_PATH_OPT.getOpt()));
} else {
outputPath = new Path("/tmp/" + UUID.randomUUID());
outputPath = new Path(tmpPath + "/" + UUID.randomUUID());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check EACH PATH manually.
This is another obvious HadoopFS path, the type is org.apache.hadoop.fs.Path. It is defined just a few lines above.

Copy link
Contributor

@stoty stoty left a comment

Choose a reason for hiding this comment

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

Please revert the files that only have whitespace changes, so that it is immediately apparent which files were changed.

@Divneet18 Divneet18 requested a review from stoty February 13, 2024 21:50
Copy link
Contributor

@stoty stoty left a comment

Choose a reason for hiding this comment

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

+1 LGTM.
I will address my nits on commit.

@@ -167,9 +167,9 @@ public static synchronized void setup(
//Maybe we're gonna have to refactor the namespace
if(clusterInitialized) {
tearDownMiniCluster(0);
System.setProperty("java.io.tmpdir", tmpDir);
System.setProperty("java.io.tmpdir", tmpPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

The old variable name is better here.
This is not used a base for paths, it's only used for saving the value of the system property.

Copy link
Contributor

Choose a reason for hiding this comment

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

and the old variable name reflects this better.

Copy link
Contributor

@stoty stoty left a comment

Choose a reason for hiding this comment

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

Come to think of it, this is initaiizing the path variables too early.
MiniCluster DOES change "java.io.tmpdir" , and there is no guarantee that the miniCluster used for the tests is already running when the test is loaded.

We should take tmpdir value from after the miniCluster initialization, i.e. either

  • in a @before method
  • At the end of @BeforeClass (for @NeedsOwnCluster tests)
  • or in the test itself.

@@ -87,9 +87,9 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {
private static final String [] TABLE_LIST_NAMESPACE_SIMPLIFIED = new String[1];

private static final String [] TRANSACTIONAL_TABLE_LIST = new String[1];

private static String tmpPath = System.getProperty("java.io.tmpdir");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is supposed to be value of tmpdir after minicluster has been started.
(But it is not, see my previous commenft()

@@ -115,7 +114,7 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {

@BeforeClass
public static synchronized void saveTmp () throws Exception {
tmpDir = System.getProperty("java.io.tmpdir");
tmpPath = System.getProperty("java.io.tmpdir");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the value of tmpDir before starting the minicluster.
It should only be used for restoring its value, and not be used in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could you elaborate on this please since all i did here was change the variable name?

Copy link
Contributor

@stoty stoty Feb 27, 2024

Choose a reason for hiding this comment

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

See the comment above.
the tmpdir values originally set, and re-set by minicluster must be kept separate.

Using the same tmpPath name we use elsewhere for constructing the test paths for saving the value leads to misunderstanding and errors like the one above.

You could keep the tmpDir name here, or use something like originalTmpDir.

private static String INPUT_LIST = "";
private static final String INPUT_FILE = "/tmp/input_file_index_upgrade.csv";
private static final String INPUT_FILE = tmpPath + "/input_file_index_upgrade.csv";
Copy link
Contributor

Choose a reason for hiding this comment

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

This is where you use the the saved tmpdir.

You should instead use tmpPath which is read AFTER minicluster is started, which can be a different value (depending onm HBase / Hadoop version)

@@ -115,7 +114,7 @@ public class ParameterizedIndexUpgradeToolIT extends BaseTest {

@BeforeClass
public static synchronized void saveTmp () throws Exception {
tmpDir = System.getProperty("java.io.tmpdir");
tmpPath = System.getProperty("java.io.tmpdir");
Copy link
Contributor

@stoty stoty Feb 27, 2024

Choose a reason for hiding this comment

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

See the comment above.
the tmpdir values originally set, and re-set by minicluster must be kept separate.

Using the same tmpPath name we use elsewhere for constructing the test paths for saving the value leads to misunderstanding and errors like the one above.

You could keep the tmpDir name here, or use something like originalTmpDir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants