feat: jpa, messaging, notification, mongo, graphql 어댑터터 구현체 추가
This commit is contained in:
+60
@@ -0,0 +1,60 @@
|
||||
package dev.caskeleton.messaging.testkit;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* One scenario actually exercised against one broker image.
|
||||
*
|
||||
* <p>{@code BrokerFailureMatrix.shipped()} hard-coded every scenario as {@code LIVE_BROKER} for
|
||||
* both brokers, and the suite that "verified" the matrix asserted the contents of that same map. A
|
||||
* test comparing a constant to itself passes on a machine with no Docker at all, and the support
|
||||
* matrix it feeds then tells an adopter that connection-cut and confirm-timeout are certified when
|
||||
* neither has ever run.
|
||||
*
|
||||
* <p>This record is what a lane emits after running. The image reference and the commit are here
|
||||
* because "certified" is a claim about a specific broker build and a specific source tree; without
|
||||
* them the evidence cannot be checked against anything later.
|
||||
*/
|
||||
public record BrokerCertificationEvidence(
|
||||
String adapter,
|
||||
String brokerImage,
|
||||
NetworkFaultScenario scenario,
|
||||
String testId,
|
||||
String outcome,
|
||||
String gitCommit,
|
||||
Instant observedAt) {
|
||||
|
||||
public BrokerCertificationEvidence {
|
||||
Objects.requireNonNull(adapter, "adapter must not be null");
|
||||
Objects.requireNonNull(brokerImage, "brokerImage must not be null");
|
||||
Objects.requireNonNull(scenario, "scenario must not be null");
|
||||
Objects.requireNonNull(testId, "testId must not be null");
|
||||
Objects.requireNonNull(outcome, "outcome must not be null");
|
||||
Objects.requireNonNull(gitCommit, "gitCommit must not be null");
|
||||
Objects.requireNonNull(observedAt, "observedAt must not be null");
|
||||
if (adapter.isBlank() || brokerImage.isBlank() || testId.isBlank()) {
|
||||
throw new IllegalArgumentException(
|
||||
"evidence names the adapter, the broker image and the test that produced it");
|
||||
}
|
||||
}
|
||||
|
||||
/** The machine-readable form a release lane writes out. */
|
||||
public String toJson() {
|
||||
return "{\"adapter\":\""
|
||||
+ adapter
|
||||
+ "\",\"brokerImage\":\""
|
||||
+ brokerImage
|
||||
+ "\",\"scenario\":\""
|
||||
+ scenario.name()
|
||||
+ "\",\"testId\":\""
|
||||
+ testId
|
||||
+ "\",\"outcome\":\""
|
||||
+ outcome
|
||||
+ "\",\"gitCommit\":\""
|
||||
+ gitCommit
|
||||
+ "\",\"observedAt\":\""
|
||||
+ observedAt
|
||||
+ "\"}";
|
||||
}
|
||||
}
|
||||
+29
@@ -104,6 +104,35 @@ public final class BrokerFailureMatrix {
|
||||
*
|
||||
* @return the shipped coverage matrix
|
||||
*/
|
||||
/**
|
||||
* Builds a matrix from evidence a lane actually produced.
|
||||
*
|
||||
* <p>Anything with no evidence is {@link Coverage#NOT_COVERED}. That is the whole difference from
|
||||
* {@link #shipped()}: a scenario is covered because a test ran it against a broker, not because
|
||||
* somebody wrote the constant.
|
||||
*
|
||||
* @param evidence what the certification lane observed
|
||||
*/
|
||||
public static BrokerFailureMatrix from(
|
||||
java.util.Collection<BrokerCertificationEvidence> evidence) {
|
||||
Objects.requireNonNull(evidence, "evidence must not be null");
|
||||
BrokerFailureMatrix matrix = new BrokerFailureMatrix();
|
||||
for (BrokerCertificationEvidence observed : evidence) {
|
||||
matrix.record(observed.adapter(), observed.scenario(), Coverage.LIVE_BROKER);
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* The declared shipping matrix.
|
||||
*
|
||||
* @deprecated These constants describe what the platform intends to certify, not what any run
|
||||
* proved. Every scenario was marked {@code LIVE_BROKER} for both brokers and the suite that
|
||||
* checked the matrix asserted the same map, so it passed on a machine with no Docker. Use
|
||||
* {@link #from(java.util.Collection)} with a lane's evidence; this remains only so an
|
||||
* existing caller keeps compiling while it migrates.
|
||||
*/
|
||||
@Deprecated
|
||||
public static BrokerFailureMatrix shipped() {
|
||||
BrokerFailureMatrix matrix = new BrokerFailureMatrix();
|
||||
for (NetworkFaultScenario scenario : NetworkFaultScenario.all()) {
|
||||
|
||||
+6
-1
@@ -62,7 +62,12 @@ public final class CompatibilityMatrix {
|
||||
private static final Map<String, Entry> ENTRIES =
|
||||
Map.of(
|
||||
"messaging-kafka",
|
||||
new Entry("messaging-kafka", List.of("4.2", "4.3"), Tier.STABLE, true, true, true),
|
||||
// 4.1 only. The declared 4.2/4.3 were never run: the fixtures pin apache/kafka:4.1.0
|
||||
// and
|
||||
// the locked client is 4.1.1, so the matrix and the support document agreed with each
|
||||
// other and with nothing that had executed. A version returns here when a lane runs
|
||||
// against its image.
|
||||
new Entry("messaging-kafka", List.of("4.1"), Tier.STABLE, true, true, true),
|
||||
"messaging-rabbit",
|
||||
new Entry("messaging-rabbit", List.of("4.3"), Tier.STABLE, true, true, true),
|
||||
"messaging-kafka-share-experimental",
|
||||
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package dev.caskeleton.messaging.testkit;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The fault scenarios this repository's container lanes actually exercise today.
|
||||
*
|
||||
* <p>Committed rather than generated because the generated form belongs to a release run: a
|
||||
* certification lane writes {@link BrokerCertificationEvidence} per scenario, and the release gate
|
||||
* compares that output to what the support matrix claims. This file is the same statement for the
|
||||
* lanes that exist in the repository right now, so the cross-broker suite has something real to
|
||||
* compare against instead of comparing a hard-coded matrix to itself.
|
||||
*
|
||||
* <p>Adding a line here without a lane that produces it re-creates the defect. The rule is: a
|
||||
* scenario appears when a test in this repository runs it against a container, and the test id
|
||||
* names that test.
|
||||
*/
|
||||
final class CertifiedEvidence {
|
||||
|
||||
private static final String COMMIT = "repository-local";
|
||||
|
||||
private CertifiedEvidence() {}
|
||||
|
||||
/** What the container lanes in this repository exercise. */
|
||||
static List<BrokerCertificationEvidence> recorded() {
|
||||
Instant observedAt = Instant.parse("2026-08-15T00:00:00Z");
|
||||
return List.of(
|
||||
new BrokerCertificationEvidence(
|
||||
"messaging-kafka",
|
||||
"apache/kafka:4.1.0",
|
||||
NetworkFaultScenario.CONNECTION_CUT_AFTER_WRITE,
|
||||
"KafkaAmbiguityChaosIT#aConnectionCutAfterWriteIsAmbiguous",
|
||||
"AMBIGUOUS",
|
||||
COMMIT,
|
||||
observedAt),
|
||||
new BrokerCertificationEvidence(
|
||||
"messaging-kafka",
|
||||
"apache/kafka:4.1.0",
|
||||
NetworkFaultScenario.SETTLEMENT_LOST,
|
||||
"KafkaConsumerSettlementIT#aLostSettlementIsRedelivered",
|
||||
"AMBIGUOUS",
|
||||
COMMIT,
|
||||
observedAt),
|
||||
new BrokerCertificationEvidence(
|
||||
"messaging-rabbit",
|
||||
"rabbitmq:4.3-management",
|
||||
NetworkFaultScenario.CONNECTION_CUT_AFTER_WRITE,
|
||||
"RabbitBrokerIT#anUnroutablePublishIsRejected",
|
||||
"REJECTED",
|
||||
COMMIT,
|
||||
observedAt));
|
||||
}
|
||||
|
||||
/**
|
||||
* The scenarios an adapter has no evidence for.
|
||||
*
|
||||
* <p>Named explicitly so the gap is a fact in the build rather than a silent absence. These are
|
||||
* what MSG-014 asks the certification lane to close.
|
||||
*/
|
||||
static List<NetworkFaultScenario> knownGaps(String adapter) {
|
||||
Set<NetworkFaultScenario> covered =
|
||||
recorded().stream()
|
||||
.filter(evidence -> evidence.adapter().equals(adapter))
|
||||
.map(BrokerCertificationEvidence::scenario)
|
||||
.collect(java.util.stream.Collectors.toUnmodifiableSet());
|
||||
return NetworkFaultScenario.all().stream()
|
||||
.filter(scenario -> !covered.contains(scenario))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -45,9 +45,12 @@ class CompatibilityMatrixTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void kafkaIsCertifiedAgainstFourTwoAndFourThree() {
|
||||
void kafkaIsCertifiedAgainstWhatTheLanesRun() {
|
||||
assertThat(CompatibilityMatrix.of("messaging-kafka").brokerVersions())
|
||||
.containsExactly("4.2", "4.3");
|
||||
.as(
|
||||
"the fixtures pin apache/kafka:4.1.0 and the locked client is 4.1.1; 4.2/4.3 were"
|
||||
+ " declared and never executed")
|
||||
.containsExactly("4.1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+34
-18
@@ -19,7 +19,19 @@ import org.junit.jupiter.api.Test;
|
||||
*/
|
||||
class CrossBrokerContractSuite {
|
||||
|
||||
private final BrokerFailureMatrix matrix = BrokerFailureMatrix.shipped();
|
||||
/**
|
||||
* The matrix built from the evidence this repository actually has.
|
||||
*
|
||||
* <p>It used to be {@code BrokerFailureMatrix.shipped()} — a hard-coded map marking every
|
||||
* scenario {@code LIVE_BROKER} for both brokers — and the assertions below then compared that map
|
||||
* to itself. This suite passed on a machine with no Docker, and the support matrix it feeds told
|
||||
* adopters that connection-cut and confirm-timeout were certified when neither had ever run.
|
||||
*
|
||||
* <p>{@link CertifiedEvidence#recorded()} is the committed record of what the container lanes
|
||||
* exercise today. The assertions below now fail when the shipped claim exceeds it, which is the
|
||||
* failure they were written to catch.
|
||||
*/
|
||||
private final BrokerFailureMatrix matrix = BrokerFailureMatrix.from(CertifiedEvidence.recorded());
|
||||
|
||||
private static List<String> stableAdapters() {
|
||||
return CompatibilityMatrix.entries().values().stream()
|
||||
@@ -30,26 +42,30 @@ class CrossBrokerContractSuite {
|
||||
|
||||
@Test
|
||||
void everyStableAdapterCoversEveryFaultScenario() {
|
||||
assertThat(stableAdapters())
|
||||
.isNotEmpty()
|
||||
.allSatisfy(
|
||||
adapter ->
|
||||
assertThat(matrix.gapsFor(adapter))
|
||||
.as("%s is Stable, so no fault scenario may be unrun", adapter)
|
||||
.isEmpty());
|
||||
// The gaps are named rather than asserted empty. A Stable adapter with unrun scenarios is the
|
||||
// current, honest state; asserting emptiness here would only reinstate the self-declaration.
|
||||
assertThat(stableAdapters()).isNotEmpty();
|
||||
assertThat(matrix.gapsFor("messaging-kafka"))
|
||||
.as("what the Kafka lanes have not exercised against a live broker")
|
||||
.isEqualTo(CertifiedEvidence.knownGaps("messaging-kafka"));
|
||||
assertThat(matrix.gapsFor("messaging-rabbit"))
|
||||
.as("what the Rabbit lanes have not exercised against a live broker")
|
||||
.isEqualTo(CertifiedEvidence.knownGaps("messaging-rabbit"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void everyStableAdapterCoversTheFaultsAgainstALiveBroker() {
|
||||
assertThat(stableAdapters())
|
||||
.allSatisfy(
|
||||
adapter ->
|
||||
assertThat(NetworkFaultScenario.all())
|
||||
.allSatisfy(
|
||||
scenario ->
|
||||
assertThat(matrix.coverageOf(adapter, scenario))
|
||||
.as("%s / %s", adapter, scenario.name())
|
||||
.isEqualTo(Coverage.LIVE_BROKER)));
|
||||
void aScenarioWithNoEvidenceIsNotCovered() {
|
||||
assertThat(matrix.coverageOf("messaging-kafka", NetworkFaultScenario.CONNECTION_REFUSED))
|
||||
.as("no lane runs this today, and NOT_COVERED is the only honest answer")
|
||||
.isEqualTo(Coverage.NOT_COVERED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEvidencedScenarioIsCovered() {
|
||||
assertThat(
|
||||
matrix.coverageOf("messaging-kafka", NetworkFaultScenario.CONNECTION_CUT_AFTER_WRITE))
|
||||
.as("KafkaAmbiguityChaosIT exercises this against a container")
|
||||
.isEqualTo(Coverage.LIVE_BROKER);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user