fix file permissions on websocket autobahn generated test reports
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
5fd0b07c45
commit
eacddab552
|
@ -24,6 +24,7 @@ import java.nio.file.Paths;
|
|||
import java.time.Duration;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -41,20 +42,32 @@ public class AutobahnTests
|
|||
private static final Logger LOG = LoggerFactory.getLogger(AutobahnTests.class);
|
||||
private static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
|
||||
|
||||
private Path reportDir;
|
||||
private Path fuzzingServer;
|
||||
private Path fuzzingClient;
|
||||
|
||||
@BeforeEach
|
||||
public void before() throws Exception
|
||||
{
|
||||
fuzzingServer = USER_DIR.resolve("fuzzingserver.json");
|
||||
assertTrue(Files.exists(fuzzingServer));
|
||||
|
||||
fuzzingClient = USER_DIR.resolve("fuzzingclient.json");
|
||||
assertTrue(Files.exists(fuzzingClient));
|
||||
|
||||
reportDir = USER_DIR.resolve("target/reports");
|
||||
if (!Files.exists(reportDir))
|
||||
Files.createDirectory(reportDir);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClient() throws Exception
|
||||
{
|
||||
Path fuzzingServer = USER_DIR.resolve("fuzzingserver.json");
|
||||
assertTrue(Files.exists(fuzzingServer));
|
||||
|
||||
Path reportDir = USER_DIR.resolve("target/reports");
|
||||
if (!Files.exists(reportDir))
|
||||
Files.createDirectory(reportDir);
|
||||
|
||||
// Start a jetty docker image with this imageTag, binding the directory of a simple webapp.
|
||||
// We need to chown the generated test results so host has permissions to delete files generated by container.
|
||||
GenericContainer<?> container = new GenericContainer<>("crossbario/autobahn-testsuite:latest")
|
||||
.withLogConsumer(new Slf4jLogConsumer(LOG))
|
||||
.withExposedPorts(9001);
|
||||
.withCommand("/bin/bash", "-c", "wstest -m fuzzingserver -s /config/fuzzingserver.json ; chown -R `stat -c '%u' /target/reports` /target/reports/*")
|
||||
.withExposedPorts(9001)
|
||||
.withLogConsumer(new Slf4jLogConsumer(LOG));
|
||||
container.addFileSystemBind(fuzzingServer.toString(), "/config/fuzzingserver.json", BindMode.READ_ONLY);
|
||||
container.addFileSystemBind(reportDir.toString(), "/target/reports", BindMode.READ_WRITE);
|
||||
|
||||
|
@ -75,20 +88,14 @@ public class AutobahnTests
|
|||
@Test
|
||||
public void testServer() throws Exception
|
||||
{
|
||||
Path fuzzingClient = USER_DIR.resolve("fuzzingclient.json");
|
||||
assertTrue(Files.exists(fuzzingClient));
|
||||
|
||||
Path reportDir = USER_DIR.resolve("target/reports");
|
||||
if (!Files.exists(reportDir))
|
||||
Files.createDirectory(reportDir);
|
||||
|
||||
// We need to expose the host port of the server to the Autobahn Client in docker container.
|
||||
final int port = 9001;
|
||||
org.testcontainers.Testcontainers.exposeHostPorts(port);
|
||||
Server server = CoreAutobahnServer.startAutobahnServer(port);
|
||||
|
||||
// We need to chown the generated test results so host has permissions to delete files generated by container.
|
||||
GenericContainer<?> container = new GenericContainer<>("crossbario/autobahn-testsuite:latest")
|
||||
.withCommand("wstest -m fuzzingclient -s /config/fuzzingclient.json")
|
||||
.withCommand("/bin/bash", "-c", "wstest -m fuzzingclient -s /config/fuzzingclient.json ; chown -R `stat -c '%u' /target/reports` /target/reports/*")
|
||||
.withLogConsumer(new Slf4jLogConsumer(LOG))
|
||||
.withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofHours(1)));
|
||||
container.addFileSystemBind(fuzzingClient.toString(), "/config/fuzzingclient.json", BindMode.READ_ONLY);
|
||||
|
|
Loading…
Reference in New Issue