Committed by
Gerrit Code Review
Using tempdir for stc CompilerTest
This fixes the problem when running multiple, parallel builds on a machine with a shared /tmp (i.e. Jenkins) Change-Id: Ib9ba840811ba95fa2cae50218732a2678900cda4
Showing
2 changed files
with
8 additions
and
8 deletions
... | @@ -15,9 +15,9 @@ | ... | @@ -15,9 +15,9 @@ |
15 | */ | 15 | */ |
16 | package org.onlab.stc; | 16 | package org.onlab.stc; |
17 | 17 | ||
18 | +import com.google.common.io.Files; | ||
18 | import org.junit.BeforeClass; | 19 | import org.junit.BeforeClass; |
19 | import org.junit.Test; | 20 | import org.junit.Test; |
20 | -import org.onlab.util.Tools; | ||
21 | 21 | ||
22 | import java.io.File; | 22 | import java.io.File; |
23 | import java.io.FileInputStream; | 23 | import java.io.FileInputStream; |
... | @@ -35,12 +35,10 @@ import static org.onlab.stc.Scenario.loadScenario; | ... | @@ -35,12 +35,10 @@ import static org.onlab.stc.Scenario.loadScenario; |
35 | */ | 35 | */ |
36 | public class CompilerTest { | 36 | public class CompilerTest { |
37 | 37 | ||
38 | - static final File TEST_DIR = new File("/tmp/junit-stc"); | 38 | + static final File TEST_DIR = Files.createTempDir(); |
39 | 39 | ||
40 | @BeforeClass | 40 | @BeforeClass |
41 | public static void setUpClass() throws IOException { | 41 | public static void setUpClass() throws IOException { |
42 | - Tools.removeDirectory(TEST_DIR); | ||
43 | - TEST_DIR.mkdirs(); | ||
44 | stageTestResource("scenario.xml"); | 42 | stageTestResource("scenario.xml"); |
45 | stageTestResource("simple-scenario.xml"); | 43 | stageTestResource("simple-scenario.xml"); |
46 | stageTestResource("one-scenario.xml"); | 44 | stageTestResource("one-scenario.xml"); |
... | @@ -51,6 +49,7 @@ public class CompilerTest { | ... | @@ -51,6 +49,7 @@ public class CompilerTest { |
51 | System.setProperty("TOC1", "1.2.3.1"); | 49 | System.setProperty("TOC1", "1.2.3.1"); |
52 | System.setProperty("TOC2", "1.2.3.2"); | 50 | System.setProperty("TOC2", "1.2.3.2"); |
53 | System.setProperty("TOC3", "1.2.3.3"); | 51 | System.setProperty("TOC3", "1.2.3.3"); |
52 | + System.setProperty("test.dir", TEST_DIR.getAbsolutePath()); | ||
54 | } | 53 | } |
55 | 54 | ||
56 | public static FileInputStream getStream(String name) throws FileNotFoundException { | 55 | public static FileInputStream getStream(String name) throws FileNotFoundException { |
... | @@ -72,7 +71,8 @@ public class CompilerTest { | ... | @@ -72,7 +71,8 @@ public class CompilerTest { |
72 | assertSame("incorrect scenario", scenario, compiler.scenario()); | 71 | assertSame("incorrect scenario", scenario, compiler.scenario()); |
73 | assertEquals("incorrect step count", 25, flow.getVertexes().size()); | 72 | assertEquals("incorrect step count", 25, flow.getVertexes().size()); |
74 | assertEquals("incorrect dependency count", 21, flow.getEdges().size()); | 73 | assertEquals("incorrect dependency count", 21, flow.getEdges().size()); |
75 | - assertEquals("incorrect logDir", "/tmp/junit-stc/foo", compiler.logDir().getPath()); | 74 | + assertEquals("incorrect logDir", |
75 | + TEST_DIR.getAbsolutePath() + "/foo", compiler.logDir().getPath()); | ||
76 | 76 | ||
77 | Step step = compiler.getStep("there"); | 77 | Step step = compiler.getStep("there"); |
78 | assertEquals("incorrect edge count", 2, flow.getEdgesFrom(step).size()); | 78 | assertEquals("incorrect edge count", 2, flow.getEdgesFrom(step).size()); | ... | ... |
... | @@ -13,10 +13,10 @@ | ... | @@ -13,10 +13,10 @@ |
13 | ~ See the License for the specific language governing permissions and | 13 | ~ See the License for the specific language governing permissions and |
14 | ~ limitations under the License. | 14 | ~ limitations under the License. |
15 | --> | 15 | --> |
16 | -<scenario name="foo" description="Test Scenario" logDir="/tmp/junit-stc/foo"> | 16 | +<scenario name="foo" description="Test Scenario" logDir="${test.dir}/foo"> |
17 | - <import file="/tmp/junit-stc/one-scenario.xml" namespace="foo"/> | 17 | + <import file="${test.dir}/one-scenario.xml" namespace="foo"/> |
18 | 18 | ||
19 | - <import file="/tmp/junit-stc/two-scenario.xml"/> | 19 | + <import file="${test.dir}/two-scenario.xml"/> |
20 | 20 | ||
21 | <dependency name="dude" requires="~yolo"/> | 21 | <dependency name="dude" requires="~yolo"/> |
22 | 22 | ... | ... |
-
Please register or login to post a comment