-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ab31e7
commit 79d1ecb
Showing
10 changed files
with
2,680 additions
and
352 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
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
86 changes: 86 additions & 0 deletions
86
...-dump/src/test/java/io/aklivity/zilla/runtime/command/dump/internal/airline/DumpRule.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,86 @@ | ||
/* | ||
* Copyright 2021-2023 Aklivity Inc | ||
* | ||
* Licensed under the Aklivity Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* https://www.aklivity.io/aklivity-community-license/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package io.aklivity.zilla.runtime.command.dump.internal.airline; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import java.net.URL; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.junit.rules.TestRule; | ||
import org.junit.runner.Description; | ||
import org.junit.runners.model.Statement; | ||
import org.testcontainers.containers.Container; | ||
|
||
public final class DumpRule implements TestRule | ||
{ | ||
private static final Matcher TIMESTAMP_MATCHER = Pattern.compile("Timestamp: 0x[0-9A-Fa-f]+").matcher(""); | ||
private static final String TIMESTAMP_PLACEHOLDER = "Timestamp: [timestamp]"; | ||
|
||
private static final Path ENGINE_PATH = Path.of("target/zilla-itests"); | ||
private static final Path PCAP_PATH = ENGINE_PATH.resolve("actual.pcap"); | ||
private static final Path TXT_PATH = ENGINE_PATH.resolve("actual.txt"); | ||
private static final DumpCommandRunner DUMP = new DumpCommandRunner(); | ||
private static final TsharkRunner TSHARK = new TsharkRunner(); | ||
|
||
private Path expected; | ||
|
||
@Override | ||
public Statement apply( | ||
Statement base, | ||
Description description) | ||
{ | ||
return new Statement() | ||
{ | ||
@Override | ||
public void evaluate() throws Throwable | ||
{ | ||
base.evaluate(); | ||
DUMP.createPcap(PCAP_PATH); | ||
Container.ExecResult result = TSHARK.createTxt(PCAP_PATH); | ||
String result0 = replaceTimestamps(result.getStdout()); | ||
Files.writeString(TXT_PATH, result0); | ||
assertThat(result.getExitCode(), equalTo(0)); | ||
assert expected != null; | ||
assertThat(result0, equalTo(Files.readString(expected))); | ||
} | ||
}; | ||
} | ||
|
||
public void expect( | ||
String file) throws Exception | ||
{ | ||
this.expected = resourceToPath(file); | ||
} | ||
|
||
private String replaceTimestamps( | ||
String input) | ||
{ | ||
TIMESTAMP_MATCHER.reset(input); | ||
return TIMESTAMP_MATCHER.replaceAll(TIMESTAMP_PLACEHOLDER); | ||
} | ||
|
||
private static Path resourceToPath( | ||
String name) throws Exception | ||
{ | ||
URL resource = DumpRule.class.getResource(name); | ||
assert resource != null; | ||
return Path.of(resource.toURI()); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...t/java/io/aklivity/zilla/runtime/command/dump/internal/airline/GrpcServerStreamRpcIT.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,62 @@ | ||
/* | ||
* Copyright 2021-2023 Aklivity Inc | ||
* | ||
* Licensed under the Aklivity Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* https://www.aklivity.io/aklivity-community-license/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package io.aklivity.zilla.runtime.command.dump.internal.airline; | ||
|
||
import static java.util.concurrent.TimeUnit.SECONDS; | ||
import static org.junit.rules.RuleChain.outerRule; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.DisableOnDebug; | ||
import org.junit.rules.TestRule; | ||
import org.junit.rules.Timeout; | ||
import org.kaazing.k3po.junit.annotation.Specification; | ||
import org.kaazing.k3po.junit.rules.K3poRule; | ||
|
||
import io.aklivity.zilla.runtime.engine.test.EngineRule; | ||
import io.aklivity.zilla.runtime.engine.test.annotation.Configuration; | ||
|
||
public class GrpcServerStreamRpcIT | ||
{ | ||
private final K3poRule k3po = new K3poRule() | ||
.addScriptRoot("net", "io/aklivity/zilla/specs/binding/grpc/streams/network/server.stream.rpc") | ||
.addScriptRoot("app", "io/aklivity/zilla/specs/binding/grpc/streams/application/server.stream.rpc"); | ||
|
||
private final TestRule timeout = new DisableOnDebug(new Timeout(10, SECONDS)); | ||
|
||
private final EngineRule engine = new EngineRule() | ||
.directory("target/zilla-itests") | ||
.countersBufferCapacity(4096) | ||
.configurationRoot("io/aklivity/zilla/specs/binding/grpc/config") | ||
.external("app0") | ||
.clean(); | ||
|
||
private final DumpRule dump = new DumpRule(); | ||
|
||
@Rule | ||
public final TestRule chain = outerRule(dump).around(engine).around(k3po).around(timeout); | ||
|
||
@Test | ||
@Configuration("server.when.yaml") | ||
@Specification({ | ||
"${net}/message.exchange/client", | ||
"${app}/message.exchange/server" | ||
}) | ||
public void shouldEstablishServerStreamRpc() throws Exception | ||
{ | ||
k3po.finish(); | ||
dump.expect("expected_grpc_server_stream_rpc_establish.txt"); | ||
} | ||
} |
81 changes: 0 additions & 81 deletions
81
...dump/src/test/java/io/aklivity/zilla/runtime/command/dump/internal/airline/HelloRule.java
This file was deleted.
Oops, something went wrong.
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
66 changes: 66 additions & 0 deletions
66
...st/java/io/aklivity/zilla/runtime/command/dump/internal/airline/Http2AuthorizationIT.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,66 @@ | ||
/* | ||
* Copyright 2021-2023 Aklivity Inc | ||
* | ||
* Licensed under the Aklivity Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* https://www.aklivity.io/aklivity-community-license/ | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package io.aklivity.zilla.runtime.command.dump.internal.airline; | ||
|
||
import static io.aklivity.zilla.runtime.binding.http.internal.HttpConfiguration.HTTP_CONCURRENT_STREAMS; | ||
import static io.aklivity.zilla.runtime.binding.http.internal.HttpConfiguration.HTTP_SERVER_HEADER; | ||
import static java.util.concurrent.TimeUnit.SECONDS; | ||
import static org.junit.rules.RuleChain.outerRule; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.DisableOnDebug; | ||
import org.junit.rules.TestRule; | ||
import org.junit.rules.Timeout; | ||
import org.kaazing.k3po.junit.annotation.Specification; | ||
import org.kaazing.k3po.junit.rules.K3poRule; | ||
|
||
import io.aklivity.zilla.runtime.engine.test.EngineRule; | ||
import io.aklivity.zilla.runtime.engine.test.annotation.Configuration; | ||
|
||
public class Http2AuthorizationIT | ||
{ | ||
private final K3poRule k3po = new K3poRule() | ||
.addScriptRoot("net", "io/aklivity/zilla/specs/binding/http/streams/network/rfc7540/authorization") | ||
.addScriptRoot("app", "io/aklivity/zilla/specs/binding/http/streams/application/rfc7540/authorization"); | ||
|
||
private final TestRule timeout = new DisableOnDebug(new Timeout(10, SECONDS)); | ||
|
||
private final EngineRule engine = new EngineRule() | ||
.directory("target/zilla-itests") | ||
.countersBufferCapacity(8192) | ||
.configure(HTTP_CONCURRENT_STREAMS, 100) | ||
.configure(HTTP_SERVER_HEADER, "Zilla") | ||
.configurationRoot("io/aklivity/zilla/specs/binding/http/config/v2") | ||
.external("app0") | ||
.clean(); | ||
|
||
private final DumpRule dump = new DumpRule(); | ||
|
||
@Rule | ||
public final TestRule chain = outerRule(dump).around(engine).around(k3po).around(timeout); | ||
|
||
@Test | ||
@Configuration("server.authorization.credentials.yaml") | ||
@Specification({ | ||
"${net}/challenge.credentials.header/client", | ||
"${app}/challenge.credentials.header/server", | ||
}) | ||
public void shouldChallengeCredentialsHeader() throws Exception | ||
{ | ||
k3po.finish(); | ||
dump.expect("expected_http2_authorization_challenge_credentials_header.txt"); | ||
} | ||
} |
Oops, something went wrong.