Search in sources :

Example 1 with DefaultProcessCommands

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();
    }
}
Also used : DefaultProcessCommands(org.sonar.process.sharedmemoryfile.DefaultProcessCommands) File(java.io.File) Test(org.junit.Test)

Example 2 with DefaultProcessCommands

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();
    }
}
Also used : DefaultProcessCommands(org.sonar.process.sharedmemoryfile.DefaultProcessCommands) File(java.io.File) Test(org.junit.Test)

Example 3 with DefaultProcessCommands

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()));
    }
}
Also used : DefaultProcessCommands(org.sonar.process.sharedmemoryfile.DefaultProcessCommands)

Example 4 with DefaultProcessCommands

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);
    }
}
Also used : DefaultProcessCommands(org.sonar.process.sharedmemoryfile.DefaultProcessCommands) File(java.io.File)

Example 5 with DefaultProcessCommands

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);
}
Also used : DefaultProcessCommands(org.sonar.process.sharedmemoryfile.DefaultProcessCommands) Random(java.util.Random) File(java.io.File) Test(org.junit.Test)

Aggregations

DefaultProcessCommands (org.sonar.process.sharedmemoryfile.DefaultProcessCommands)6 File (java.io.File)5 Test (org.junit.Test)4 Random (java.util.Random)1