Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end-to-end testing for the dump command #646

Merged
merged 18 commits into from
Dec 22, 2023
Merged
11 changes: 11 additions & 0 deletions incubator/command-dump/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The `dump` command creates a `pcap` file that can be opened by Wireshark using the `zilla.lua` dissector plugin.

`WiresharkIT` is an integration test that tests the `zilla.lua` dissector by running `tshark` in a docker container. If it doesn't find the image, it builds it on-the-fly, but the process is faster if the `tshark` image is pre-built.

This is the command to build a multi-arch `tshark` image and push it to a docker repository:

```bash
cd <zilla-source>/incubator/command-dump/src/test/resources/io/aklivity/zilla/runtime/command/dump/internal
docker buildx create --name container --driver=docker-container
docker buildx build --tag <repository>/tshark:<version> --platform linux/arm64/v8,linux/amd64 --builder container --push .
```

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@TestInstance(PER_CLASS)
public class WiresharkIT
{
private static final String TSHARK_DOCKER_IMAGE = "mytshark:4.2.0"; // TODO: Ati - image name
private static final String TSHARK_DOCKER_IMAGE = "kreinerattila/tshark:4.2.0";
private static final String COMMAND = "sleep infinity";
private static final WaitStrategy WAIT_STRATEGY = Wait.forSuccessfulCommand("echo 42");

Expand Down Expand Up @@ -80,30 +80,30 @@ public void close()
}

@Test
public void shouldMatchExpectedOutputWithoutFilter() throws Exception
public void shouldMatchExpectedOutput() throws Exception
{
// GIVEN
String pcapFileName = "expected_dump_without_filter.pcap";
String pcapFileName = "expected_dump.pcap";
String containerPath = String.format("/opt/%s", pcapFileName);
copyResource(pcapFileName, tshark, containerPath);
String expectedText = Files.readString(resourceToPath("expected_dump_without_filter.txt"));
String expectedText = Files.readString(resourceToPath("expected_dump.txt"));

// WHEN
Container.ExecResult result = tshark.execInContainer("tshark", "-O", "zilla", "-r", containerPath);
Container.ExecResult result = tshark.execInContainer("tshark", "-O", "zilla,http", "-r", containerPath);

// THEN
assertThat(result.getExitCode(), equalTo(0));
assertThat(result.getStdout(), equalTo(expectedText));
}

@Test
public void shouldMatchExpectedOutputWithFilter() throws Exception
public void shouldMatchExpectedFilteredOutput() throws Exception
{
// GIVEN
String pcapFileName = "expected_dump_with_kafka_filter.pcap";
String pcapFileName = "expected_filtered_dump.pcap";
String containerPath = String.format("/opt/%s", pcapFileName);
copyResource(pcapFileName, tshark, containerPath);
String expectedText = Files.readString(resourceToPath("expected_dump_with_kafka_filter.txt"));
String expectedText = Files.readString(resourceToPath("expected_filtered_dump.txt"));

// WHEN
Container.ExecResult result = tshark.execInContainer("tshark", "-O", "zilla", "-r", containerPath);
Expand Down
Loading