/** * Test appending new configs vars added to restrict list * @throws Exception */ @Test public void testAppendRestriction() throws Exception { String appendListStr = ConfVars.SCRATCHDIR.varname + "," + ConfVars.LOCALSCRATCHDIR.varname + "," + ConfVars.METASTOREURIS.varname; conf.addToRestrictList(appendListStr); // check if the new configs are added to HIVE_CONF_RESTRICTED_LIST String newRestrictList = conf.getVar(ConfVars.HIVE_CONF_RESTRICTED_LIST); assertTrue(newRestrictList.contains(ConfVars.SCRATCHDIR.varname)); assertTrue(newRestrictList.contains(ConfVars.LOCALSCRATCHDIR.varname)); assertTrue(newRestrictList.contains(ConfVars.METASTOREURIS.varname)); // check if the old values are still there in HIVE_CONF_RESTRICTED_LIST assertTrue(newRestrictList.contains(ConfVars.HIVETESTMODEPREFIX.varname)); // verify that the new configs are in effect verifyRestriction(ConfVars.HIVETESTMODEPREFIX.varname, "foo"); verifyRestriction(ConfVars.HIVE_CONF_RESTRICTED_LIST.varname, "foo"); verifyRestriction(ConfVars.LOCALSCRATCHDIR.varname, "foo"); verifyRestriction(ConfVars.METASTOREURIS.varname, "foo"); }
/** * Test that configs in restrict list can't be changed * @throws Exception */ @Test public void testMultipleRestrictions() throws Exception { verifyRestriction(ConfVars.HIVETESTMODEPREFIX.varname, "foo"); verifyRestriction(ConfVars.HIVE_IN_TEST.varname, "true"); }
private void verifyRestriction(String varName, String newVal) { try { conf.verifyAndSet(varName, newVal); fail("Setting config property " + varName + " should fail"); } catch (IllegalArgumentException e) { // the verifyAndSet in this case is expected to fail with the IllegalArgumentException } } }
/** * Test that restrict list config itselft can't be changed * @throws Exception */ @Test public void testRestrictList() throws Exception { verifyRestriction(ConfVars.HIVE_CONF_RESTRICTED_LIST.varname, "foo"); }
/** * Test that configs in restrict list can't be changed * @throws Exception */ @Test public void testRestriction() throws Exception { verifyRestriction(ConfVars.HIVETESTMODEPREFIX.varname, "foo"); conf.verifyAndSet(ConfVars.HIVE_AM_SPLIT_GENERATION.varname, "false"); }