From 1ca155f3592e5fe4a0784daa0ef636cf73cb1edb Mon Sep 17 00:00:00 2001 From: Ankit Kumar Date: Mon, 27 May 2024 19:17:28 +0530 Subject: [PATCH 1/3] Update to handle catalog IT validation(resolve schema from subject) --- .../test/internal/binding/TestBindingFactory.java | 12 ++++++++++++ .../binding/config/TestBindingOptionsConfig.java | 5 ++++- .../config/TestBindingOptionsConfigAdapter.java | 4 +++- .../engine/schema/binding/test.schema.patch.json | 4 ++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java index 22c7112144..6f11d12a94 100644 --- a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java +++ b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java @@ -275,6 +275,18 @@ private void onInitialBegin( { doInitialReset(traceId); } + if (assertion.resolve) + { + String schema = handler.resolve(id); + if (assertion.schema == null && schema != null) + { + doInitialReset(traceId); + } + else if (assertion.schema != null && !assertion.schema.equals(schema)) + { + doInitialReset(traceId); + } + } } else { diff --git a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java index 69ff33e9f3..7cb4af53bf 100644 --- a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java +++ b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java @@ -87,15 +87,18 @@ public static final class CatalogAssertion public final int id; public final String schema; public final long delay; + public final boolean resolve; public CatalogAssertion( int id, String schema, - long delay) + long delay, + boolean resolve) { this.id = id; this.schema = schema; this.delay = delay; + this.resolve = resolve; } } } diff --git a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java index 6840c32814..11f62d80d0 100644 --- a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java +++ b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java @@ -44,6 +44,7 @@ public final class TestBindingOptionsConfigAdapter implements OptionsConfigAdapt private static final String ID_NAME = "id"; private static final String SCHEMA_NAME = "schema"; private static final String DELAY_NAME = "delay"; + private static final String RESOLVE_NAME = "resolve"; private final SchemaConfigAdapter schema = new SchemaConfigAdapter(); @@ -175,7 +176,8 @@ public OptionsConfig adaptFromJson( catalogAssertions.add(new TestBindingOptionsConfig.CatalogAssertion( c.containsKey(ID_NAME) ? c.getInt(ID_NAME) : 0, c.containsKey(SCHEMA_NAME) ? !c.isNull(SCHEMA_NAME) ? c.getString(SCHEMA_NAME) : null : null, - c.containsKey(DELAY_NAME) ? c.getJsonNumber(DELAY_NAME).longValue() : 0L)); + c.containsKey(DELAY_NAME) ? c.getJsonNumber(DELAY_NAME).longValue() : 0L, + c.containsKey(RESOLVE_NAME) ? c.getBoolean(RESOLVE_NAME) : false)); } testOptions.catalogAssertions(catalogName, catalogAssertions); } diff --git a/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json b/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json index dfbd5c307e..8eaf579a33 100644 --- a/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json +++ b/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json @@ -83,6 +83,10 @@ "delay": { "type": "number" + }, + "resolve": + { + "type": "boolean" } } } From 3ecc2f0273c19564a474938653c5df80d663f4a5 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Date: Tue, 28 May 2024 13:58:58 +0530 Subject: [PATCH 2/3] addressing review comments --- .../engine/test/internal/binding/TestBindingFactory.java | 5 ++++- .../binding/config/TestBindingOptionsConfig.java | 5 +---- .../binding/config/TestBindingOptionsConfigAdapter.java | 9 +++++---- .../specs/engine/schema/binding/test.schema.patch.json | 4 ---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java index 6f11d12a94..ff0474debd 100644 --- a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java +++ b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java @@ -15,8 +15,11 @@ */ package io.aklivity.zilla.runtime.engine.test.internal.binding; +import static io.aklivity.zilla.runtime.engine.test.internal.binding.config.TestBindingOptionsConfigAdapter.DEFAULT_ASSERTION_SCHEMA; + import java.util.LinkedList; import java.util.List; +import java.util.Objects; import org.agrona.DirectBuffer; import org.agrona.MutableDirectBuffer; @@ -275,7 +278,7 @@ private void onInitialBegin( { doInitialReset(traceId); } - if (assertion.resolve) + if (!Objects.equals(DEFAULT_ASSERTION_SCHEMA, assertion.schema)) { String schema = handler.resolve(id); if (assertion.schema == null && schema != null) diff --git a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java index 7cb4af53bf..69ff33e9f3 100644 --- a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java +++ b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfig.java @@ -87,18 +87,15 @@ public static final class CatalogAssertion public final int id; public final String schema; public final long delay; - public final boolean resolve; public CatalogAssertion( int id, String schema, - long delay, - boolean resolve) + long delay) { this.id = id; this.schema = schema; this.delay = delay; - this.resolve = resolve; } } } diff --git a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java index 11f62d80d0..4575e6bf68 100644 --- a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java +++ b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/config/TestBindingOptionsConfigAdapter.java @@ -33,6 +33,8 @@ public final class TestBindingOptionsConfigAdapter implements OptionsConfigAdapterSpi { + public static final String DEFAULT_ASSERTION_SCHEMA = new String(); + private static final String MODE_NAME = "mode"; private static final String CATALOG_NAME = "catalog"; private static final String AUTHORIZATION_NAME = "authorization"; @@ -44,7 +46,6 @@ public final class TestBindingOptionsConfigAdapter implements OptionsConfigAdapt private static final String ID_NAME = "id"; private static final String SCHEMA_NAME = "schema"; private static final String DELAY_NAME = "delay"; - private static final String RESOLVE_NAME = "resolve"; private final SchemaConfigAdapter schema = new SchemaConfigAdapter(); @@ -175,9 +176,9 @@ public OptionsConfig adaptFromJson( JsonObject c = assertion.asJsonObject(); catalogAssertions.add(new TestBindingOptionsConfig.CatalogAssertion( c.containsKey(ID_NAME) ? c.getInt(ID_NAME) : 0, - c.containsKey(SCHEMA_NAME) ? !c.isNull(SCHEMA_NAME) ? c.getString(SCHEMA_NAME) : null : null, - c.containsKey(DELAY_NAME) ? c.getJsonNumber(DELAY_NAME).longValue() : 0L, - c.containsKey(RESOLVE_NAME) ? c.getBoolean(RESOLVE_NAME) : false)); + c.containsKey(SCHEMA_NAME) ? !c.isNull(SCHEMA_NAME) ? c.getString(SCHEMA_NAME) + : null : DEFAULT_ASSERTION_SCHEMA, + c.containsKey(DELAY_NAME) ? c.getJsonNumber(DELAY_NAME).longValue() : 0L)); } testOptions.catalogAssertions(catalogName, catalogAssertions); } diff --git a/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json b/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json index 8eaf579a33..dfbd5c307e 100644 --- a/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json +++ b/specs/engine.spec/src/main/scripts/io/aklivity/zilla/specs/engine/schema/binding/test.schema.patch.json @@ -83,10 +83,6 @@ "delay": { "type": "number" - }, - "resolve": - { - "type": "boolean" } } } From bc2f559472dcf2f608dae10e88811d8854857bfa Mon Sep 17 00:00:00 2001 From: Ankit Kumar Date: Tue, 28 May 2024 21:35:03 +0530 Subject: [PATCH 3/3] addressing review comments --- .../engine/test/internal/binding/TestBindingFactory.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java index ff0474debd..d6e8b7bb7b 100644 --- a/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java +++ b/runtime/engine/src/test/java/io/aklivity/zilla/runtime/engine/test/internal/binding/TestBindingFactory.java @@ -278,14 +278,10 @@ private void onInitialBegin( { doInitialReset(traceId); } - if (!Objects.equals(DEFAULT_ASSERTION_SCHEMA, assertion.schema)) + if (DEFAULT_ASSERTION_SCHEMA != assertion.schema) { String schema = handler.resolve(id); - if (assertion.schema == null && schema != null) - { - doInitialReset(traceId); - } - else if (assertion.schema != null && !assertion.schema.equals(schema)) + if (!Objects.equals(assertion.schema, schema)) { doInitialReset(traceId); }