Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.hadoop.conf.ReconfigurationException;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.conf.ReconfigurableBase;
import org.apache.hadoop.hdds.conf.ReconfigurationHandler;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
Expand All @@ -54,7 +54,6 @@
public abstract class TestReconfigShell implements NonHATests.TestCase {

private OzoneAdmin ozoneAdmin;
private OzoneConfiguration conf;
private ReconfigurationHandler reconfigurationHandler;
private GenericTestUtils.PrintStreamCapturer out;
private GenericTestUtils.PrintStreamCapturer err;
Expand All @@ -64,7 +63,6 @@ void capture() {
out = GenericTestUtils.captureOut();
err = GenericTestUtils.captureErr();
ozoneAdmin = new OzoneAdmin();
conf = new OzoneConfiguration();
reconfigurationHandler = cluster().getOzoneManager().getReconfigurationHandler();
}

Expand All @@ -89,10 +87,12 @@ void testOzoneManagerGetReconfigurationProperties() {
}

@Test
void testDirectoryDeletingServiceIntervalReconfiguration() throws ReconfigurationException {
void testDirectoryDeletingServiceIntervalReconfiguration() throws ReconfigurationException,
InterruptedException, TimeoutException {
OzoneManager om = cluster().getOzoneManager();
InetSocketAddress socket = om.getOmRpcServerAddr();
LogCapturer logCapturer = LogCapturer.captureLogs(DirectoryDeletingService.class);
LogCapturer dirDeletingServiceLog = LogCapturer.captureLogs(DirectoryDeletingService.class);
LogCapturer reconfigHandlerLog = LogCapturer.captureLogs(ReconfigurationHandler.class);

String initialInterval = "1m";
String intervalFromXML = "2m"; //config value set in ozone-site.xml
Expand All @@ -103,18 +103,20 @@ void testDirectoryDeletingServiceIntervalReconfiguration() throws Reconfiguratio

//Start the reconfiguration task
executeAndAssertStart("OM", socket);
//If config value is set in ozone-site.xml then it is picked up during reconfiguration
assertThat(conf.get(OZONE_DIR_DELETING_SERVICE_INTERVAL)).isEqualTo(intervalFromXML);

executeAndAssertStatus("OM", socket);
assertThat(reconfigurationHandler.getConf().get(OZONE_DIR_DELETING_SERVICE_INTERVAL)).isEqualTo(intervalFromXML);
assertThat(out.get()).contains(
String.format("SUCCESS: Changed property %s", OZONE_DIR_DELETING_SERVICE_INTERVAL)
);
assertThat(logCapturer.getOutput()).contains(
GenericTestUtils.waitFor(() -> reconfigHandlerLog.getOutput().contains("Reconfiguration completed"),
1000, 20000);
assertThat(dirDeletingServiceLog.getOutput()).contains(
String.format("Updating and restarting DirectoryDeletingService with interval %d %s",
intervalFromXMLInSeconds, TimeUnit.SECONDS.name().toLowerCase())
);
intervalFromXMLInSeconds, TimeUnit.SECONDS.name().toLowerCase()));
assertThat(reconfigurationHandler.getConf().get(OZONE_DIR_DELETING_SERVICE_INTERVAL)).isEqualTo(intervalFromXML);

String address = socket.getHostString() + ":" + socket.getPort();
GenericTestUtils.waitFor(() -> {
ozoneAdmin.getCmd().execute("reconfig", "--service", "OM", "--address", address, "status");
String output = out.get();
return output.contains("finished") &&
output.contains(String.format("SUCCESS: Changed property %s", OZONE_DIR_DELETING_SERVICE_INTERVAL));
}, 1000, 20000);
}

@Test
Expand Down Expand Up @@ -177,10 +179,4 @@ private void executeAndAssertStart(String service, InetSocketAddress socket) {
assertThat(out.get()).contains(service + ": Started reconfiguration task on node [" + address + "]");
}

private void executeAndAssertStatus(String service, InetSocketAddress socket) {
String address = socket.getHostString() + ":" + socket.getPort();
ozoneAdmin.getCmd().execute("reconfig", "--service", service, "--address", address, "status");
assertThat(out.get()).contains(service + ": Reconfiguring status for node [" + address + "]: started");
}

}