use of org.sonar.process.sharedmemoryfile.DefaultProcessCommands in project sonarqube by SonarSource.
the class ProcessCommandWrapperImplTest method requestSQRestart_updates_shareMemory_file.
@Test
public void requestSQRestart_updates_shareMemory_file() throws IOException {
File tmpDir = temp.newFolder().getAbsoluteFile();
settings.setProperty(PROPERTY_SHARED_PATH, tmpDir.getAbsolutePath());
settings.setProperty(PROPERTY_PROCESS_INDEX, PROCESS_NUMBER);
ProcessCommandWrapperImpl underTest = new ProcessCommandWrapperImpl(settings.asConfig());
underTest.requestSQRestart();
try (DefaultProcessCommands processCommands = DefaultProcessCommands.secondary(tmpDir, PROCESS_NUMBER)) {
assertThat(processCommands.askedForRestart()).isTrue();
}
}
use of org.sonar.process.sharedmemoryfile.DefaultProcessCommands in project sonarqube by SonarSource.
the class ProcessCommandWrapperImplTest method requestSQStop_updates_shareMemory_file.
@Test
public void requestSQStop_updates_shareMemory_file() throws IOException {
File tmpDir = temp.newFolder().getAbsoluteFile();
settings.setProperty(PROPERTY_SHARED_PATH, tmpDir.getAbsolutePath());
settings.setProperty(PROPERTY_PROCESS_INDEX, PROCESS_NUMBER);
ProcessCommandWrapperImpl underTest = new ProcessCommandWrapperImpl(settings.asConfig());
underTest.requestHardStop();
try (DefaultProcessCommands processCommands = DefaultProcessCommands.secondary(tmpDir, PROCESS_NUMBER)) {
assertThat(processCommands.askedForHardStop()).isTrue();
}
}
use of org.sonar.process.sharedmemoryfile.DefaultProcessCommands in project sonarqube by SonarSource.
the class CeHttpClientImplTest method setUpWithHttpUrl.
private void setUpWithHttpUrl(ProcessId processId) {
try (DefaultProcessCommands processCommands = DefaultProcessCommands.secondary(ipcSharedDir, processId.getIpcIndex())) {
processCommands.setUp();
processCommands.setHttpUrl(format("http://%s:%d", server.getHostName(), server.getPort()));
}
}
use of org.sonar.process.sharedmemoryfile.DefaultProcessCommands in project sonarqube by SonarSource.
the class CeHttpServer method registerHttpUrl.
private void registerHttpUrl() {
int processNumber = parseInt(processProps.getProperty(PROPERTY_PROCESS_INDEX));
File shareDir = new File(processProps.getProperty(PROPERTY_SHARED_PATH));
try (DefaultProcessCommands commands = DefaultProcessCommands.secondary(shareDir, processNumber)) {
String url = getUrl();
commands.setHttpUrl(url);
LoggerFactory.getLogger(getClass()).debug("System Info HTTP server listening at {}", url);
}
}
use of org.sonar.process.sharedmemoryfile.DefaultProcessCommands in project sonarqube by SonarSource.
the class ProcessCommandWrapperImplTest method isCeOperational_reads_shared_memory_operational_flag_in_location_3.
@Test
public void isCeOperational_reads_shared_memory_operational_flag_in_location_3() throws IOException {
File tmpDir = temp.newFolder().getAbsoluteFile();
settings.setProperty(PROPERTY_SHARED_PATH, tmpDir.getAbsolutePath());
boolean expected = new Random().nextBoolean();
if (expected) {
try (DefaultProcessCommands processCommands = DefaultProcessCommands.secondary(tmpDir, 3)) {
processCommands.setOperational();
}
}
ProcessCommandWrapperImpl underTest = new ProcessCommandWrapperImpl(settings.asConfig());
assertThat(underTest.isCeOperational()).isEqualTo(expected);
}
Aggregations