-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1910 from alvasw/test_tor_installation_startup_ra…
…ce_condition Test Tor Installation and Startup Race Condition
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
plugins { | ||
id("bisq.java-conventions") | ||
id("bisq.java-integration-tests") | ||
id("bisq.protobuf") | ||
} | ||
|
||
|
55 changes: 55 additions & 0 deletions
55
network/tor/tor/src/integrationTest/java/bisq/tor/InstallerAndRunRaceConditionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.tor; | ||
|
||
import bisq.tor.installer.TorInstallationFiles; | ||
import bisq.tor.installer.TorInstaller; | ||
import bisq.tor.process.LdPreload; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class InstallerAndRunRaceConditionTest { | ||
@Test | ||
void test(@TempDir Path tempDir) throws IOException, InterruptedException { | ||
var torInstallationFiles = new TorInstallationFiles(tempDir); | ||
var torInstaller = new TorInstaller(torInstallationFiles); | ||
torInstaller.installIfNotUpToDate(); | ||
|
||
Path torBinaryPath = tempDir.resolve("tor"); | ||
var processBuilder = new ProcessBuilder( | ||
torBinaryPath.toAbsolutePath().toString(), | ||
"--version" | ||
); | ||
|
||
Map<String, String> environment = processBuilder.environment(); | ||
environment.put("LD_PRELOAD", LdPreload.computeLdPreloadVariable(tempDir)); | ||
|
||
Process process = processBuilder.start(); | ||
boolean isSuccess = process.waitFor(30, TimeUnit.SECONDS); | ||
|
||
assertThat(isSuccess).isTrue(); | ||
assertThat(process.exitValue()).isEqualTo(0); | ||
} | ||
} |