private void generateRefreshJarFiles(String version) throws IOException, InterruptedException { String u = HiveTestUtils .getFileFromClasspath(RELOADED_CLAZZ_PREFIX_NAME + version + HiveTestUtils.TXT_FILE_EXT); File jarFile = HiveTestUtils.genLocalJarForTest(u, RELOADED_CLAZZ_PREFIX_NAME); Files.move(jarFile, new File(jarFile.getAbsolutePath() + "." + version)); }
@Parameters(name="{1}") public static Collection<Object[]> data() throws IOException, InterruptedException { // generate the dummy driver by using txt file String u = HiveTestUtils.getFileFromClasspath("DummyDriver.txt"); Map<File, String> extraContent=new HashMap<>(); extraContent.put(new File("META-INF/services/java.sql.Driver"), dummyDriverClazzName); File jarFile = HiveTestUtils.genLocalJarForTest(u, dummyDriverClazzName, extraContent); String pathToDummyDriver = jarFile.getAbsolutePath(); return Arrays.asList(new Object[][] { { "jdbc:postgresql://host:5432/testdb", "org.postgresql.Driver", System.getProperty("maven.local.repository") + File.separator + "postgresql" + File.separator + "postgresql" + File.separator + "9.1-901.jdbc4" + File.separator + "postgresql-9.1-901.jdbc4.jar", true }, { "jdbc:dummy://host:5432/testdb", dummyDriverClazzName, pathToDummyDriver, false } }); }
job.setOutputValueClass(IntWritable.class); FileInputFormat.addInputPath(job, new Path(HiveTestUtils .getFileFromClasspath("orc-file-11-format.orc"))); Path outputPath = new Path(workDir, "TestOrcFile." + testCaseName.getMethodName() + ".txt");
private void configLog(String hiveLog4jTest, String hiveExecLog4jTest) throws Exception { String expectedLog4jTestPath = HiveTestUtils.getFileFromClasspath(hiveLog4jTest); String expectedLog4jExecPath = HiveTestUtils.getFileFromClasspath(hiveExecLog4jTest); System.setProperty(ConfVars.HIVE_LOG4J_FILE.varname, expectedLog4jTestPath); System.setProperty(ConfVars.HIVE_EXEC_LOG4J_FILE.varname, expectedLog4jExecPath); LogUtils.initHiveLog4j(); HiveConf conf = new HiveConf(); assertEquals(expectedLog4jTestPath, conf.getVar(ConfVars.HIVE_LOG4J_FILE)); assertEquals(expectedLog4jExecPath, conf.getVar(ConfVars.HIVE_EXEC_LOG4J_FILE)); }
job.setOutputValueClass(IntWritable.class); FileInputFormat.addInputPath(job, new Path(HiveTestUtils.getFileFromClasspath("orc-file-11-format.orc"))); Path outputPath = new Path(workDir, "TestOrcFile." + testCaseName.getMethodName() + ".txt");
private String getParsedUrlFromConfigFile(String filename) throws BeelineHS2ConnectionFileParseException { String path = HiveTestUtils.getFileFromClasspath(filename); testLocations.add(path); UserHS2ConnectionFileParser testHS2ConfigManager = new UserHS2ConnectionFileParser(testLocations); return HS2ConnectionFileUtils.getUrl(testHS2ConfigManager.getConnectionProperties()); }
@Test public void testHiveSitePath() throws Exception { String expectedPath = HiveTestUtils.getFileFromClasspath("hive-site.xml"); String hiveSiteLocation = HiveConf.getHiveSiteLocation().getPath(); Assert.assertEquals(expectedPath, hiveSiteLocation); }
@Test public void testReloadAuxJars2() { HiveConf conf = new HiveConf(); HiveConf.setVar(conf, ConfVars.HIVERELOADABLEJARS, hiveReloadPath); SessionState ss = new SessionState(conf); SessionState.start(ss); ss = SessionState.get(); File dist = null; try { dist = new File(reloadFolder.getAbsolutePath() + File.separator + reloadClazzFileName); Files.copy(new File(HiveTestUtils.getFileFromClasspath(clazzDistFileName)), dist); ss.loadReloadableAuxJars(); Assert.assertEquals("version1", getReloadedClazzVersion(ss.getConf().getClassLoader())); } catch (Exception e) { LOG.error("Reload auxiliary jar test fail with message: ", e); Assert.fail(e.getMessage()); } finally { FileUtils.deleteQuietly(dist); try { ss.close(); } catch (IOException ioException) { Assert.fail(ioException.getMessage()); LOG.error("Fail to close the created session: ", ioException); } } }
dist = new File(reloadFolder.getAbsolutePath() + File.separator + reloadClazzFileName); Files.copy(new File(HiveTestUtils.getFileFromClasspath(clazzDistFileName)), dist); ss.loadReloadableAuxJars(); Files.copy(new File(HiveTestUtils.getFileFromClasspath(clazzV2FileName)), dist);
@Test(expected = ClassCastException.class) public void testSerdeStatsOldFormat() throws Exception { Path oldFilePath = new Path(HiveTestUtils.getFileFromClasspath("orc-file-11-format.orc")); Reader reader = OrcFile.createReader(oldFilePath, OrcFile.readerOptions(conf).filesystem(fs));
@Test public void testReadOldFileHeader() throws IOException { String[] row = new String[]{"Tester", "Bart", "333 X St.", "Reno", "NV", "USA"}; RCFile.Reader reader = new RCFile.Reader(fs, new Path(HiveTestUtils.getFileFromClasspath("rc-file-v0.rc")), conf); LongWritable rowID = new LongWritable(); BytesRefArrayWritable cols = new BytesRefArrayWritable(); assertTrue("old file reader first row", reader.next(rowID)); reader.getCurrentRow(cols); assertEquals(row.length, cols.size()); for (int i=0; i < cols.size(); ++i) { assertEquals(row[i], new String(cols.get(i).getBytesCopy())); } assertFalse("old file reader end", reader.next(rowID)); reader.close(); }
@Test public void testReadFormat_0_11() throws Exception { Path oldFilePath = new Path(HiveTestUtils.getFileFromClasspath("orc-file-11-format.orc")); Reader reader = OrcFile.createReader(oldFilePath, OrcFile.readerOptions(conf).filesystem(fs));