MCPcopy Create free account
hub / github.com/apache/pig / testSetStoreSchema

Method testSetStoreSchema

test/org/apache/pig/test/TestStoreBase.java:72–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70 abstract protected void setupPigServer() throws Exception;
71
72 @Test
73 public void testSetStoreSchema() throws Exception {
74 Map<String, Boolean> filesToVerify = new HashMap<String, Boolean>();
75 filesToVerify.put(outputFileName + "_storeSchema_test", Boolean.TRUE);
76 filesToVerify.put(DummyOutputCommitter.FILE_SETUPJOB_CALLED, Boolean.TRUE);
77 filesToVerify.put(DummyOutputCommitter.FILE_SETUPTASK_CALLED, Boolean.TRUE);
78 filesToVerify.put(DummyOutputCommitter.FILE_COMMITTASK_CALLED, Boolean.TRUE);
79 filesToVerify.put(DummyOutputCommitter.FILE_ABORTTASK_CALLED, Boolean.FALSE);
80 filesToVerify.put(DummyOutputCommitter.FILE_COMMITJOB_CALLED, Boolean.TRUE);
81 filesToVerify.put(DummyOutputCommitter.FILE_ABORTJOB_CALLED, Boolean.FALSE);
82 filesToVerify.put(DummyOutputCommitter.FILE_CLEANUPJOB_CALLED, Boolean.FALSE);
83 String[] inputData = new String[]{"hello\tworld", "bye\tworld"};
84
85 String script = "a = load '"+ inputFileName + "' as (a0:chararray, a1:chararray);" +
86 "store a into '" + outputFileName + "' using " +
87 DUMMY_STORE_CLASS_NAME + "();";
88
89 if(!mode.isLocal()) {
90 filesToVerify.put(DummyOutputCommitter.FILE_SETUPJOB_CALLED, Boolean.TRUE);
91 filesToVerify.put(DummyOutputCommitter.FILE_COMMITJOB_CALLED, Boolean.TRUE);
92 } else {
93 if (Util.isHadoop1_x()) {
94 // MAPREDUCE-1447/3563 (LocalJobRunner does not call methods of mapreduce
95 // OutputCommitter) is fixed only in 0.23.1
96 filesToVerify.put(DummyOutputCommitter.FILE_SETUPJOB_CALLED, Boolean.FALSE);
97 filesToVerify.put(DummyOutputCommitter.FILE_COMMITJOB_CALLED, Boolean.FALSE);
98 }
99 }
100 ps.setBatchOn();
101 Util.deleteFile(ps.getPigContext(), TESTDIR);
102 Util.createInputFile(ps.getPigContext(),
103 inputFileName, inputData);
104 Util.registerMultiLineQuery(ps, script);
105 ps.executeBatch();
106 for (Entry<String, Boolean> entry : filesToVerify.entrySet()) {
107 String condition = entry.getValue() ? "" : "not";
108 assertEquals("Checking if file " + entry.getKey() +
109 " does " + condition + " exists in " + mode +
110 " mode", (boolean) entry.getValue(),
111 Util.exists(ps.getPigContext(), entry.getKey()));
112 }
113 }
114
115 @Test
116 public void testCleanupOnFailure() throws Exception {

Callers

nothing calls this directly

Calls 14

isHadoop1_xMethod · 0.95
deleteFileMethod · 0.95
createInputFileMethod · 0.95
existsMethod · 0.95
entrySetMethod · 0.80
isLocalMethod · 0.65
getValueMethod · 0.65
putMethod · 0.45
setBatchOnMethod · 0.45
getPigContextMethod · 0.45
executeBatchMethod · 0.45

Tested by

no test coverage detected