Skip to content

Fixing Java unit tests in storm-core to run under Windows (1.x branch) - #2414

Closed
lawrencecraft wants to merge 1 commit into
apache:1.x-branchfrom
lawrencecraft:WindowsTestFix-1.x
Closed

Fixing Java unit tests in storm-core to run under Windows (1.x branch)#2414
lawrencecraft wants to merge 1 commit into
apache:1.x-branchfrom
lawrencecraft:WindowsTestFix-1.x

Conversation

@lawrencecraft

Copy link
Copy Markdown
Contributor

While fixing STORM-2797 I noticed a bunch of the storm-core tests didn't run under Windows.

I've fixed them up to use Windows-friendly asserts. All are done in a generic way through framework classes except one particular case where the behavior actually differs based on operating system. I only modified tests, not any actual application code. I tested this change on Windows, OS X, and Linux: all pass. On Windows, I still have to run Maven as administrator as some of the tests write to temp folders in AppData.

I'll follow up with a pull request for STORM-2797. There are still some Clojure tests failing but a lot of them are around the logviewer, which will be fixed by my next PR.

@srdosrdo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lawrencecraft Thanks for the contribution. I agree that we should change the tests to be Windows compatible, left some suggestions.

Please open a new issue on jira to track this, and open a PR against master as well. We need all fixes to go into master first. This is so we can be sure not to "lose" fixes in later releases.

final String confKey = topoId + "-stormconf.ser";
final String stormLocal = "/tmp/storm-local/";
final String stormRoot = stormLocal+topoId+"/";
final String stormLocalAbsolutePath = new File("/tmp/storm-local/").getAbsolutePath();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use Files.createTempFile instead of /tmp.

private static final String DOUBLE_SEP = File.separator + File.separator;
static String asAbsPath(String ... parts) {
return (File.separator + PATH_JOIN.join(parts)).replace(DOUBLE_SEP, File.separator);
String path = (File.separator + PATH_JOIN.join(parts)).replace(DOUBLE_SEP, File.separator);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think starting a path with / or \ is inherently going to be fragile on Windows. It might be better to remove the initial file separator from here, and throw an exception if the first path part is File.separator . Then you can probably also get rid of the DOUBLE_SEP replacement. Same check should be in asPath. In order to work on Windows, paths should start from e.g. java.io.tmpdir or the current working directory instead of the filesystem root I think.

@@ -370,7 +370,7 @@ public void testLaunch() throws Exception {
final String workerConf = ContainerTest.asAbsPath(log4jdir, "worker.xml");

@srdosrdoNov 12, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you start the paths from Files.createTempFile instead of tmp for stormHome and stormLocal, you should be able to get rid of the prependFilePrefixIfOnWindows method.

@lawrencecraft

Copy link
Copy Markdown
ContributorAuthor

Thanks Stig, will do.

I might submit a fix for STORM-2797 (the LogViewer issue) first, if that's alright, as I've got that almost ready to go. I can track the fixing of the unit tests separately.

@srdo

srdo commented Nov 13, 2017

Copy link
Copy Markdown
Contributor

Sounds good.

d2r pushed a commit to d2r/storm that referenced this pull request Oct 16, 2018
We are closing stale Pull Requests to make the list more manageable.
Please re-open any Pull Request that has been closed in error.
Closesapache#608Closesapache#639Closesapache#640Closesapache#648Closesapache#662Closesapache#668Closesapache#692Closesapache#705Closesapache#724Closesapache#728Closesapache#730Closesapache#753Closesapache#803Closesapache#854Closesapache#922Closesapache#986Closesapache#992Closesapache#1019Closesapache#1040Closesapache#1041Closesapache#1043Closesapache#1046Closesapache#1051Closesapache#1078Closesapache#1146Closesapache#1164Closesapache#1165Closesapache#1178Closesapache#1213Closesapache#1225Closesapache#1258Closesapache#1259Closesapache#1268Closesapache#1272Closesapache#1277Closesapache#1278Closesapache#1288Closesapache#1296Closesapache#1328Closesapache#1342Closesapache#1353Closesapache#1370Closesapache#1376Closesapache#1391Closesapache#1395Closesapache#1399Closesapache#1406Closesapache#1410Closesapache#1422Closesapache#1427Closesapache#1443Closesapache#1462Closesapache#1468Closesapache#1483Closesapache#1506Closesapache#1509Closesapache#1515Closesapache#1520Closesapache#1521Closesapache#1525Closesapache#1527Closesapache#1544Closesapache#1550Closesapache#1566Closesapache#1569Closesapache#1570Closesapache#1575Closesapache#1580Closesapache#1584Closesapache#1591Closesapache#1600Closesapache#1611Closesapache#1613Closesapache#1639Closesapache#1703Closesapache#1711Closesapache#1719Closesapache#1737Closesapache#1760Closesapache#1767Closesapache#1768Closesapache#1785Closesapache#1799Closesapache#1822Closesapache#1824Closesapache#1844Closesapache#1874Closesapache#1918Closesapache#1928Closesapache#1937Closesapache#1942Closesapache#1951Closesapache#1957Closesapache#1963Closesapache#1964Closesapache#1965Closesapache#1967Closesapache#1968Closesapache#1971Closesapache#1985Closesapache#1986Closesapache#1998Closesapache#2031Closesapache#2032Closesapache#2071Closesapache#2076Closesapache#2108Closesapache#2119Closesapache#2128Closesapache#2142Closesapache#2174Closesapache#2206Closesapache#2297Closesapache#2322Closesapache#2332Closesapache#2341Closesapache#2377Closesapache#2414Closesapache#2469
d2r pushed a commit to d2r/storm that referenced this pull request Oct 16, 2018
We are closing stale Pull Requests to make the list more manageable.
Please re-open any Pull Request that has been closed in error.
Closesapache#608Closesapache#639Closesapache#640Closesapache#648Closesapache#662Closesapache#668Closesapache#692Closesapache#705Closesapache#724Closesapache#728Closesapache#730Closesapache#753Closesapache#803Closesapache#854Closesapache#922Closesapache#986Closesapache#992Closesapache#1019Closesapache#1040Closesapache#1041Closesapache#1043Closesapache#1046Closesapache#1051Closesapache#1078Closesapache#1146Closesapache#1164Closesapache#1165Closesapache#1178Closesapache#1213Closesapache#1225Closesapache#1258Closesapache#1259Closesapache#1268Closesapache#1272Closesapache#1277Closesapache#1278Closesapache#1288Closesapache#1296Closesapache#1328Closesapache#1342Closesapache#1353Closesapache#1370Closesapache#1376Closesapache#1391Closesapache#1395Closesapache#1399Closesapache#1406Closesapache#1410Closesapache#1422Closesapache#1427Closesapache#1443Closesapache#1462Closesapache#1468Closesapache#1483Closesapache#1506Closesapache#1509Closesapache#1515Closesapache#1520Closesapache#1521Closesapache#1525Closesapache#1527Closesapache#1544Closesapache#1550Closesapache#1566Closesapache#1569Closesapache#1570Closesapache#1575Closesapache#1580Closesapache#1584Closesapache#1591Closesapache#1600Closesapache#1611Closesapache#1613Closesapache#1639Closesapache#1703Closesapache#1711Closesapache#1719Closesapache#1737Closesapache#1760Closesapache#1767Closesapache#1768Closesapache#1785Closesapache#1799Closesapache#1822Closesapache#1824Closesapache#1844Closesapache#1874Closesapache#1918Closesapache#1928Closesapache#1937Closesapache#1942Closesapache#1951Closesapache#1957Closesapache#1963Closesapache#1964Closesapache#1965Closesapache#1967Closesapache#1968Closesapache#1971Closesapache#1985Closesapache#1986Closesapache#1998Closesapache#2031Closesapache#2032Closesapache#2071Closesapache#2076Closesapache#2108Closesapache#2119Closesapache#2128Closesapache#2142Closesapache#2174Closesapache#2206Closesapache#2297Closesapache#2322Closesapache#2332Closesapache#2341Closesapache#2377Closesapache#2414Closesapache#2469
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lawrencecraft@srdo