From f17bb8adacc9a371cfa0a4a299f781799426cfb1 Mon Sep 17 00:00:00 2001 From: Andras Csaki Date: Wed, 6 Oct 2021 12:18:05 +0200 Subject: [PATCH] CDPD-29746: Don't publish test artifacts Change-Id: I4a8a1370d0a3ebf44669ba6778e7552d71b8f33f --- build.gradle | 23 +- .../schema-lifecycle/build.gradle | 5 - .../schema/lifecycle/SchemaLifecycleApp.java | 80 ++++- .../lifecycle/CustomStateTransitionTest.java | 24 +- .../schema-registry-webservice/build.gradle | 9 +- .../schemaregistry/avro/Device.java | 314 ++++++++++++++++++ .../avro/KafkaAvroSerDesTest.java | 1 - .../util/AvroSchemaRegistryClientUtil.java | 2 +- .../src/test/resources/device-compat.avsc | 12 + .../src/test/resources/device-incompat.avsc | 11 + .../resources/device-unsupported-type.avsc | 2 + .../src/test/resources/device.avsc | 11 + .../resources/exportimport/confluent1.txt | 6 + .../src/test/resources/schema-1.avsc | 94 ++++++ .../src/test/resources/schema-2.avsc | 99 ++++++ .../src/test/resources/schema-3.avsc | 94 ++++++ .../src/test/resources/schema-4.avsc | 99 ++++++ 17 files changed, 839 insertions(+), 47 deletions(-) create mode 100644 schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/Device.java create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/device-compat.avsc create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/device-incompat.avsc create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/device-unsupported-type.avsc create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/device.avsc create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/exportimport/confluent1.txt create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/schema-1.avsc create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/schema-2.avsc create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/schema-3.avsc create mode 100644 schema-registry/schema-registry-webservice/src/test/resources/schema-4.avsc diff --git a/build.gradle b/build.gradle index ec5ce1a40..a93b70bd4 100644 --- a/build.gradle +++ b/build.gradle @@ -108,15 +108,6 @@ subprojects { test.finalizedBy(jacocoTestReport) jacocoTestReport.dependsOn(test) - task testJar(type: Jar, dependsOn: testClasses) { - classifier = 'test' - from sourceSets.test.output - } - - artifacts { - tests testJar - } - checkstyle { toolVersion = '9.3' ignoreFailures = false @@ -155,15 +146,21 @@ subprojects { } } - if (it.name != 'jersey-shaded') { // jersey-shaded has custom publication + configurations.matching { it.name.contains("tests") }.each {testConfiguration -> + try { + components.java.withVariantsFromConfiguration(testConfiguration) { + skip() + } + } catch(InvalidUserDataException e) {} + } + + // jersey-shaded has custom publication and we don't publish any test artifacts + if (it.name != 'jersey-shaded' & it.name != 'behavior-tests') { publishing { publications { mavenJava(MavenPublication) { groupId = group from components.java - artifact(testJar) { - classifier "tests" - } } } } diff --git a/examples/schema-registry/schema-lifecycle/build.gradle b/examples/schema-registry/schema-lifecycle/build.gradle index 521d5f369..defda6bed 100644 --- a/examples/schema-registry/schema-lifecycle/build.gradle +++ b/examples/schema-registry/schema-lifecycle/build.gradle @@ -26,9 +26,4 @@ dependencies { testImplementation group: 'org.scala-lang', name: 'scala-reflect', version: scala_version testCompile libraries.junit - testCompile(project(path: ':schema-registry:schema-registry-webservice', configuration: 'tests')) { - exclude group: 'junit' - } - - } diff --git a/examples/schema-registry/schema-lifecycle/src/main/java/com/hortonworks/registries/examples/schema/lifecycle/SchemaLifecycleApp.java b/examples/schema-registry/schema-lifecycle/src/main/java/com/hortonworks/registries/examples/schema/lifecycle/SchemaLifecycleApp.java index b4e6e9941..a2db7dbc0 100644 --- a/examples/schema-registry/schema-lifecycle/src/main/java/com/hortonworks/registries/examples/schema/lifecycle/SchemaLifecycleApp.java +++ b/examples/schema-registry/schema-lifecycle/src/main/java/com/hortonworks/registries/examples/schema/lifecycle/SchemaLifecycleApp.java @@ -16,22 +16,88 @@ package com.hortonworks.registries.examples.schema.lifecycle; +import com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient; import com.hortonworks.registries.schemaregistry.webservice.LocalSchemaRegistryServer; +import org.apache.commons.io.IOUtils; +import org.yaml.snakeyaml.Yaml; + +import java.io.FileInputStream; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; public class SchemaLifecycleApp { - private static LocalSchemaRegistryServer LOCAL_SCHEMA_REGISTRY_SERVER = null; + private LocalSchemaRegistryServer localSchemaRegistryServer; + private volatile Map cachedClientConf; + private volatile SchemaRegistryClient cachedSchemaRegistryClient; + private static final String V1_API_PATH = "api/v1"; + + private final String serverConfigurationPath; - public static void main(String[] args) throws Exception { - startUp(); + public SchemaLifecycleApp(String serverConfigurationPath) { + this.serverConfigurationPath = serverConfigurationPath; } - public static void startUp() throws Exception { - LOCAL_SCHEMA_REGISTRY_SERVER = new LocalSchemaRegistryServer(SchemaLifecycleApp.class.getClassLoader() + public SchemaLifecycleApp() { + this(SchemaLifecycleApp.class.getClassLoader() .getResource("registry-lifecycle-example.yaml").getPath()); - LOCAL_SCHEMA_REGISTRY_SERVER.start(); } - private SchemaLifecycleApp() { } + public void startUp() throws Exception { + localSchemaRegistryServer = new LocalSchemaRegistryServer(serverConfigurationPath); + localSchemaRegistryServer.start(); + } + + public void stop() throws Exception { + localSchemaRegistryServer.stop(); + } + + public SchemaRegistryClient getClient() { + return getClient(null); + } + + public SchemaRegistryClient getClient(String clientConfigPath) { + SchemaRegistryClient schemaRegistryClient = new SchemaRegistryClient(exportClientConf(false, clientConfigPath)); + if (cachedSchemaRegistryClient == null) { + cachedSchemaRegistryClient = schemaRegistryClient; + } + return schemaRegistryClient; + } + + private Map exportClientConf(boolean cached, String clientConfigPath) { + if (!cached) { + Map clientConfig = createClientConf(clientConfigPath); + if (cachedClientConf == null) { + cachedClientConf = clientConfig; + } + return clientConfig; + } else { + if (cachedClientConf == null) { + cachedClientConf = createClientConf(clientConfigPath); + } + return cachedClientConf; + } + } + private Map createClientConf(String clientConfigPath) { + String registryURL = getRegistryURL(); + if (clientConfigPath == null) { + Map ret = new HashMap<>(); + ret.put(SchemaRegistryClient.Configuration.SCHEMA_REGISTRY_URL.name(), registryURL); + return ret; + } + try (FileInputStream fis = new FileInputStream(clientConfigPath)) { + Map ret = new Yaml().load(IOUtils.toString(fis, StandardCharsets.UTF_8)); + ret.put("schema.registry.url", registryURL); + return ret; + } catch (Exception e) { + throw new RuntimeException("Failed to export schema client configuration for yaml : " + + clientConfigPath, e); + } + } + + private String getRegistryURL() { + return localSchemaRegistryServer.getLocalURL() + V1_API_PATH; + } } diff --git a/examples/schema-registry/schema-lifecycle/src/test/java/com/hortonworks/registries/examples/schema/lifecycle/CustomStateTransitionTest.java b/examples/schema-registry/schema-lifecycle/src/test/java/com/hortonworks/registries/examples/schema/lifecycle/CustomStateTransitionTest.java index 10c5bd158..3ffecc9bb 100644 --- a/examples/schema-registry/schema-lifecycle/src/test/java/com/hortonworks/registries/examples/schema/lifecycle/CustomStateTransitionTest.java +++ b/examples/schema-registry/schema-lifecycle/src/test/java/com/hortonworks/registries/examples/schema/lifecycle/CustomStateTransitionTest.java @@ -24,9 +24,6 @@ import com.hortonworks.registries.schemaregistry.SchemaVersion; import com.hortonworks.registries.schemaregistry.SchemaVersionInfo; import com.hortonworks.registries.schemaregistry.avro.AvroSchemaProvider; -import com.hortonworks.registries.schemaregistry.avro.conf.SchemaRegistryTestConfiguration; -import com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper; -import com.hortonworks.registries.schemaregistry.avro.util.AvroSchemaRegistryClientUtil; import com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient; import com.hortonworks.registries.schemaregistry.errors.IncompatibleSchemaException; import com.hortonworks.registries.schemaregistry.errors.InvalidSchemaException; @@ -47,27 +44,26 @@ public class CustomStateTransitionTest { private static final Logger LOG = LoggerFactory.getLogger(CustomStateTransitionTest.class); - private SchemaRegistryTestServerClientWrapper schemaRegistryTestServerClientWrapper; + private SchemaLifecycleApp schemaRegistryTestServer; private SchemaRegistryClient schemaRegistryClient; @BeforeEach public void startUp() throws Exception { String serverYAMLPath = CustomStateTransitionTest.class.getClassLoader().getResource("registry-lifecycle-test-example.yaml").getPath(); String clientYAMLPath = CustomStateTransitionTest.class.getClassLoader().getResource("registry-lifecycle-client.yaml").getPath(); - schemaRegistryTestServerClientWrapper = new SchemaRegistryTestServerClientWrapper(new SchemaRegistryTestConfiguration(serverYAMLPath, - clientYAMLPath)); - schemaRegistryTestServerClientWrapper.startTestServer(); - schemaRegistryClient = schemaRegistryTestServerClientWrapper.getClient(); + schemaRegistryTestServer = new SchemaLifecycleApp(serverYAMLPath); + schemaRegistryTestServer.startUp(); + schemaRegistryClient = schemaRegistryTestServer.getClient(clientYAMLPath); } @AfterEach public void tearDown() throws Exception { - schemaRegistryTestServerClientWrapper.stopTestServer(); + schemaRegistryTestServer.stop(); } @Test - public void testTransitionToRejectedState() - throws IOException, SchemaNotFoundException, InvalidSchemaException, IncompatibleSchemaException, + public void testTransitionToRejectedState() + throws IOException, SchemaNotFoundException, InvalidSchemaException, IncompatibleSchemaException, SchemaBranchAlreadyExistsException, SchemaLifecycleException { SchemaMetadata schemaMetadata = createSchemaMetadata("test", SchemaCompatibility.NONE); SchemaBranch branch1 = new SchemaBranch("BRANCH1", schemaMetadata.getName()); @@ -81,13 +77,13 @@ public void testTransitionToRejectedState() schemaRegistryClient.createSchemaBranch(schemaIdVersion1.getSchemaVersionId(), branch1); - String schema2 = AvroSchemaRegistryClientUtil.getSchema("/device1.avsc"); + String schema2 = getSchema("/device1.avsc"); LOG.info("Creating second version for the schema \"{}\"", schemaMetadata.getName()); SchemaIdVersion schemaIdVersion2 = schemaRegistryClient .addSchemaVersion(branch1.getName(), schemaMetadata, new SchemaVersion(schema2, "modify version")); LOG.info("ID of the second version is {}", schemaIdVersion2); - LOG.info("Starting review of the second version with ID {} (new state: {})", + LOG.info("Starting review of the second version with ID {} (new state: {})", schemaIdVersion2.getSchemaVersionId(), CustomReviewCycleStates.PEER_REVIEW_STATE.getId()); schemaRegistryClient.startSchemaVersionReview(schemaIdVersion2.getSchemaVersionId()); SchemaVersionInfo schemaVersionInfoAtReviewState = schemaRegistryClient @@ -96,7 +92,7 @@ public void testTransitionToRejectedState() Assertions.assertEquals(CustomReviewCycleStates.PEER_REVIEW_STATE.getId(), schemaVersionInfoAtReviewState.getStateId()); LOG.info("Transitioning second version into REJECTED ({}) state.", CustomReviewCycleStates.REJECTED_REVIEW_STATE.getId()); - schemaRegistryClient.transitionState(schemaIdVersion2.getSchemaVersionId(), + schemaRegistryClient.transitionState(schemaIdVersion2.getSchemaVersionId(), CustomReviewCycleStates.REJECTED_REVIEW_STATE.getId(), "Rejected by X".getBytes()); SchemaVersionInfo schemaVersionInfoAtRejectedState = schemaRegistryClient .getSchemaVersionInfo(new SchemaIdVersion(schemaIdVersion2.getSchemaVersionId())); diff --git a/schema-registry/schema-registry-webservice/build.gradle b/schema-registry/schema-registry-webservice/build.gradle index 0563b416d..c1320eda7 100644 --- a/schema-registry/schema-registry-webservice/build.gradle +++ b/schema-registry/schema-registry-webservice/build.gradle @@ -81,11 +81,8 @@ dependencies { } } - testCompile(project(path: ':schema-registry:schema-registry-client', configuration: 'tests')) { transitive = false } - testCompile(project(path: ':schema-registry:schema-registry-serdes', configuration: 'tests')) { transitive = false } - testCompile project(path: ':schema-registry:schema-registry-common', configuration: 'tests') - testCompile project(path: ':schema-registry:schema-registry-core', configuration: 'tests') - testCompile project(path: ':registry-common', configuration: 'tests') + testCompile(project(path: ':schema-registry:schema-registry-client')) { transitive = false } + testCompile(project(path: ':schema-registry:schema-registry-serdes')) { transitive = false } testCompile libraries.junit testCompile libraries.mockito @@ -95,7 +92,7 @@ dependencies { testCompile libraries.kafka.test.clients testCompile libraries.kafka.test.streams testCompile libraries.kafka.test.streams_test_utils - + testCompile(libraries.kafka.test.core) { exclude group: 'org.scala-lang' } testCompile(libraries.kafka.core) { exclude group: 'org.scala-lang' } diff --git a/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/Device.java b/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/Device.java new file mode 100644 index 000000000..c23eb845d --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/Device.java @@ -0,0 +1,314 @@ +/** + * Copyright 2016-2019 Cloudera, Inc. + * + * Autogenerated by Avro + * + * DO NOT EDIT DIRECTLY + */ +package com.hortonworks.registries.schemaregistry.avro; +@SuppressWarnings("all") +@org.apache.avro.specific.AvroGenerated +public class Device extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { + public static final org.apache.avro.Schema SCHEMA = new org.apache.avro.Schema.Parser().parse( + "{\"type\":\"record\",\"name\":\"Device\",\"namespace\":\"com.hortonworks.registries.serdes\"," + + "\"fields\":[{\"name\":\"xid\",\"type\":\"long\"},{\"name\":\"name\",\"type\":\"string\"}," + + "{\"name\":\"version\",\"type\":\"int\"},{\"name\":\"timestamp\",\"type\":\"long\"}]}"); + public static org.apache.avro.Schema getClassSchema() { + return SCHEMA; + } + @Deprecated public long xid; + @Deprecated public CharSequence name; + @Deprecated public int version; + @Deprecated public long timestamp; + + /** + * Default constructor. Note that this does not initialize fields + * to their default values from the schema. If that is desired then + * one should use newBuilder(). + */ + public Device() { } + + /** + * All-args constructor. + */ + public Device(Long xid, CharSequence name, Integer version, Long timestamp) { + this.xid = xid; + this.name = name; + this.version = version; + this.timestamp = timestamp; + } + + public org.apache.avro.Schema getSchema() { + return SCHEMA; + } + // Used by DatumWriter. Applications should not call. + public Object get(int field) { + switch (field) { + case 0: return xid; + case 1: return name; + case 2: return version; + case 3: return timestamp; + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); + } + } + // Used by DatumReader. Applications should not call. + @SuppressWarnings(value = "unchecked") + public void put(int field, Object value) { + switch (field) { + case 0: xid = (Long) value; + break; + case 1: name = (CharSequence) value; + break; + case 2: version = (Integer) value; + break; + case 3: timestamp = (Long) value; + break; + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); + } + } + + /** + * Gets the value of the 'xid' field. + */ + public Long getXid() { + return xid; + } + + /** + * Sets the value of the 'xid' field. + * @param value the value to set. + */ + public void setXid(Long value) { + this.xid = value; + } + + /** + * Gets the value of the 'name' field. + */ + public CharSequence getName() { + return name; + } + + /** + * Sets the value of the 'name' field. + * @param value the value to set. + */ + public void setName(CharSequence value) { + this.name = value; + } + + /** + * Gets the value of the 'version' field. + */ + public Integer getVersion() { + return version; + } + + /** + * Sets the value of the 'version' field. + * @param value the value to set. + */ + public void setVersion(Integer value) { + this.version = value; + } + + /** + * Gets the value of the 'timestamp' field. + */ + public Long getTimestamp() { + return timestamp; + } + + /** + * Sets the value of the 'timestamp' field. + * @param value the value to set. + */ + public void setTimestamp(Long value) { + this.timestamp = value; + } + + /** Creates a new Device RecordBuilder */ + public static Builder newBuilder() { + return new Builder(); + } + + /** Creates a new Device RecordBuilder by copying an existing Builder */ + public static Builder newBuilder(Builder other) { + return new Builder(other); + } + + /** Creates a new Device RecordBuilder by copying an existing Device instance */ + public static Builder newBuilder(Device other) { + return new Builder(other); + } + + /** + * RecordBuilder for Device instances. + */ + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase + implements org.apache.avro.data.RecordBuilder { + + private long xid; + private CharSequence name; + private int version; + private long timestamp; + + /** Creates a new Builder */ + private Builder() { + super(Device.SCHEMA); + } + + /** Creates a Builder by copying an existing Builder */ + private Builder(Builder other) { + super(other); + if (isValidValue(fields()[0], other.xid)) { + this.xid = data().deepCopy(fields()[0].schema(), other.xid); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.name)) { + this.name = data().deepCopy(fields()[1].schema(), other.name); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.version)) { + this.version = data().deepCopy(fields()[2].schema(), other.version); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.timestamp)) { + this.timestamp = data().deepCopy(fields()[3].schema(), other.timestamp); + fieldSetFlags()[3] = true; + } + } + + /** Creates a Builder by copying an existing Device instance */ + private Builder(Device other) { + super(Device.SCHEMA); + if (isValidValue(fields()[0], other.xid)) { + this.xid = data().deepCopy(fields()[0].schema(), other.xid); + fieldSetFlags()[0] = true; + } + if (isValidValue(fields()[1], other.name)) { + this.name = data().deepCopy(fields()[1].schema(), other.name); + fieldSetFlags()[1] = true; + } + if (isValidValue(fields()[2], other.version)) { + this.version = data().deepCopy(fields()[2].schema(), other.version); + fieldSetFlags()[2] = true; + } + if (isValidValue(fields()[3], other.timestamp)) { + this.timestamp = data().deepCopy(fields()[3].schema(), other.timestamp); + fieldSetFlags()[3] = true; + } + } + + /** Gets the value of the 'xid' field */ + public Long getXid() { + return xid; + } + + /** Sets the value of the 'xid' field */ + public Builder setXid(long value) { + validate(fields()[0], value); + this.xid = value; + fieldSetFlags()[0] = true; + return this; + } + + /** Checks whether the 'xid' field has been set */ + public boolean hasXid() { + return fieldSetFlags()[0]; + } + + /** Clears the value of the 'xid' field */ + public Builder clearXid() { + fieldSetFlags()[0] = false; + return this; + } + + /** Gets the value of the 'name' field */ + public CharSequence getName() { + return name; + } + + /** Sets the value of the 'name' field */ + public Builder setName(CharSequence value) { + validate(fields()[1], value); + this.name = value; + fieldSetFlags()[1] = true; + return this; + } + + /** Checks whether the 'name' field has been set */ + public boolean hasName() { + return fieldSetFlags()[1]; + } + + /** Clears the value of the 'name' field */ + public Builder clearName() { + name = null; + fieldSetFlags()[1] = false; + return this; + } + + /** Gets the value of the 'version' field */ + public Integer getVersion() { + return version; + } + + /** Sets the value of the 'version' field */ + public Builder setVersion(int value) { + validate(fields()[2], value); + this.version = value; + fieldSetFlags()[2] = true; + return this; + } + + /** Checks whether the 'version' field has been set */ + public boolean hasVersion() { + return fieldSetFlags()[2]; + } + + /** Clears the value of the 'version' field */ + public Builder clearVersion() { + fieldSetFlags()[2] = false; + return this; + } + + /** Gets the value of the 'timestamp' field */ + public Long getTimestamp() { + return timestamp; + } + + /** Sets the value of the 'timestamp' field */ + public Builder setTimestamp(long value) { + validate(fields()[3], value); + this.timestamp = value; + fieldSetFlags()[3] = true; + return this; + } + + /** Checks whether the 'timestamp' field has been set */ + public boolean hasTimestamp() { + return fieldSetFlags()[3]; + } + + /** Clears the value of the 'timestamp' field */ + public Builder clearTimestamp() { + fieldSetFlags()[3] = false; + return this; + } + + @Override + public Device build() { + try { + Device record = new Device(); + record.xid = fieldSetFlags()[0] ? this.xid : (Long) defaultValue(fields()[0]); + record.name = fieldSetFlags()[1] ? this.name : (CharSequence) defaultValue(fields()[1]); + record.version = fieldSetFlags()[2] ? this.version : (Integer) defaultValue(fields()[2]); + record.timestamp = fieldSetFlags()[3] ? this.timestamp : (Long) defaultValue(fields()[3]); + return record; + } catch (Exception e) { + throw new org.apache.avro.AvroRuntimeException(e); + } + } + } +} diff --git a/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/KafkaAvroSerDesTest.java b/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/KafkaAvroSerDesTest.java index 38c00ac13..ecdc9026b 100644 --- a/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/KafkaAvroSerDesTest.java +++ b/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/KafkaAvroSerDesTest.java @@ -20,7 +20,6 @@ import com.hortonworks.registries.schemaregistry.avro.util.AvroSchemaRegistryClientUtil; import com.hortonworks.registries.schemaregistry.serdes.avro.kafka.KafkaAvroDeserializer; import com.hortonworks.registries.schemaregistry.serdes.avro.kafka.KafkaAvroSerializer; -import com.hortonworks.registries.serdes.Device; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/util/AvroSchemaRegistryClientUtil.java b/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/util/AvroSchemaRegistryClientUtil.java index e6fe7f2f9..d175b7f52 100644 --- a/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/util/AvroSchemaRegistryClientUtil.java +++ b/schema-registry/schema-registry-webservice/src/test/java/com/hortonworks/registries/schemaregistry/avro/util/AvroSchemaRegistryClientUtil.java @@ -16,7 +16,7 @@ package com.hortonworks.registries.schemaregistry.avro.util; import com.hortonworks.registries.schemaregistry.avro.AvroSchemaRegistryClientTest; -import com.hortonworks.registries.serdes.Device; +import com.hortonworks.registries.schemaregistry.avro.Device; import org.apache.avro.Schema; import org.apache.avro.generic.GenericData; import org.apache.avro.generic.GenericRecord; diff --git a/schema-registry/schema-registry-webservice/src/test/resources/device-compat.avsc b/schema-registry/schema-registry-webservice/src/test/resources/device-compat.avsc new file mode 100644 index 000000000..91fcc7859 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/device-compat.avsc @@ -0,0 +1,12 @@ +{ + "type" : "record", + "namespace" : "com.hortonworks.registries", + "name" : "device", + "fields" : [ + { "name" : "xid" , "type" : "long" }, + { "name" : "name" , "type" : "string" }, + { "name" : "version" , "type" : "int" }, + { "name" : "timestamp" , "type" : "long" }, + { "name" : "make" , "type" : "string", "default": ""} + ] +} \ No newline at end of file diff --git a/schema-registry/schema-registry-webservice/src/test/resources/device-incompat.avsc b/schema-registry/schema-registry-webservice/src/test/resources/device-incompat.avsc new file mode 100644 index 000000000..82101762b --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/device-incompat.avsc @@ -0,0 +1,11 @@ +{ + "type" : "record", + "namespace" : "com.hortonworks.registries", + "name" : "Device", + "fields" : [ + { "name" : "xid" , "type" : "long" }, + { "name" : "name" , "type" : "string" }, + { "name" : "version" , "type" : "int" }, + { "name" : "mfr" , "type" : "string" } + ] +} \ No newline at end of file diff --git a/schema-registry/schema-registry-webservice/src/test/resources/device-unsupported-type.avsc b/schema-registry/schema-registry-webservice/src/test/resources/device-unsupported-type.avsc new file mode 100644 index 000000000..5862118c9 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/device-unsupported-type.avsc @@ -0,0 +1,2 @@ +[{\"name\":\"driverId\",\"type\":\"INTEGER\",\"optional\":false},{\"name\":\"truckId\", \"type\":\"LONG\", \"optional\":false},{\"name\":\"eventTime\",\"type\":\"STRING\",\"optional\":true},{\"name\":\"eventType\", \"type\":\"STRING\", \"optional\":true},{\"name\":\"longitude\", \"type\":\"DOUBLE\", \"optional\":true},{\"name\":\"latitude\", \"type\":\"DOUBLE\", \"optional\":true},{\"name\":\"eventKey\", \"type\":\"STRING\", \"optional\":true},{\"name\":\"correlationId\", \"type\":\"STRING\", \"optional\":true},{\"name\":\"driverName\", \"type\":\"STRING\", \"optional\":true},{\"name\":\"routeId\", \"type\":\"LONG\",\"optional\":true},{\"name\":\"routeName\", \"type\":\"STRING\",\"optional\":true},{\"name\":\"eventDate\",\"type\":\"STRING\",\"optional\":true},{\"name\":\"miles\",\"type\":\"INTEGER\",\"optional\":false}] + diff --git a/schema-registry/schema-registry-webservice/src/test/resources/device.avsc b/schema-registry/schema-registry-webservice/src/test/resources/device.avsc new file mode 100644 index 000000000..125c6ff40 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/device.avsc @@ -0,0 +1,11 @@ +{ + "type" : "record", + "namespace" : "com.hortonworks.registries", + "name" : "device", + "fields" : [ + { "name" : "xid" , "type" : "long" }, + { "name" : "name" , "type" : "string" }, + { "name" : "version" , "type" : "int" }, + { "name" : "timestamp" , "type" : "long" } + ] +} \ No newline at end of file diff --git a/schema-registry/schema-registry-webservice/src/test/resources/exportimport/confluent1.txt b/schema-registry/schema-registry-webservice/src/test/resources/exportimport/confluent1.txt new file mode 100644 index 000000000..6799ae637 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/exportimport/confluent1.txt @@ -0,0 +1,6 @@ +{"keytype":"SCHEMA","subject":"Kafka-key","version":1,"magic":1} {"subject":"Kafka-key","version":1,"id":1,"schema":"\"string\"","deleted":false} +{"keytype":"SCHEMA","subject":"Car","version":1,"magic":1} {"subject":"Car","version":1,"id":2,"schema":"{\"type\":\"record\",\"name\":\"Car\",\"namespace\":\"com.piripocs\",\"fields\":[{\"name\":\"model\",\"type\":\"string\"},{\"name\":\"color\",\"type\":\"string\",\"default\":\"blue\"},{\"name\":\"price\",\"type\":\"string\",\"default\":\"0\"},{\"name\":\"year\",\"type\":[\"null\",\"string\"],\"default\":null}]}","deleted":false} +{"keytype":"SCHEMA","subject":"Car","version":2,"magic":1} {"subject":"Car","version":2,"id":3,"schema":"{\"type\":\"record\",\"name\":\"Car\",\"namespace\":\"com.piripocs\",\"fields\":[{\"name\":\"model\",\"type\":\"string\"},{\"name\":\"color\",\"type\":\"string\",\"default\":\"blue\"},{\"name\":\"price\",\"type\":\"string\",\"default\":\"0\"}]}","deleted":false} +{"keytype":"CONFIG","subject":"Car","magic":0} {"compatibilityLevel":"FULL"} +{"keytype":"SCHEMA","subject":"Fruit","version":1,"magic":1} {"subject":"Fruit","version":1,"id":4,"schema":"{\"type\":\"record\",\"name\":\"Fruit\",\"namespace\":\"com.piripocs\",\"fields\":[{\"name\":\"color\",\"type\":\"string\",\"default\":\"green\"}]}","deleted":false} +{"keytype":"SCHEMA","subject":"Kafka-key","version":1,"magic":1} {"subject":"Kafka-key","version":1,"id":1,"schema":"\"string\"","deleted":true} \ No newline at end of file diff --git a/schema-registry/schema-registry-webservice/src/test/resources/schema-1.avsc b/schema-registry/schema-registry-webservice/src/test/resources/schema-1.avsc new file mode 100644 index 000000000..76140b3c8 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/schema-1.avsc @@ -0,0 +1,94 @@ +{ + "type": "record", + "namespace": "com.hwx.schemas", + "name": "ComplexDevice", + "fields": [ + { + "name": "xid", + "type": "long" + }, + { + "name": "name", + "type": "string", + "default": "default" + }, + { + "name": "version", + "type": "int" + }, + { + "name": "longArrayFields", + "type": { + "type": "array", + "items": "long" + } + }, + { + "name": "complexArrayFields", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "field_element", + "fields": [ + { + "name": "arr_f_11", + "type": "string" + }, + { + "name": "arr_f_2", + "type": "int" + } + ] + } + } + }, + { + "name": "daysField", + "type": { + "name": "days", + "type": "enum", + "symbols": [ + "SUN", + "MON", + "TUES", + "WED", + "THURS", + "FRI", + "SAT" + ] + } + }, + { + "name": "md5", + "type": { + "name": "MD5", + "type": "fixed", + "size": 16 + } + }, + { + "name": "unionField", + "type": [ + "null", + "string" + ] + }, + { + "name": "longMapRecord", + "type": { + "name": "longMapRecordEntry", + "type": "record", + "fields": [ + { + "name": "map_f_1", + "type": { + "type": "map", + "values": "long" + } + } + ] + } + } + ] +} diff --git a/schema-registry/schema-registry-webservice/src/test/resources/schema-2.avsc b/schema-registry/schema-registry-webservice/src/test/resources/schema-2.avsc new file mode 100644 index 000000000..ace466963 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/schema-2.avsc @@ -0,0 +1,99 @@ +{ + "type": "record", + "namespace": "com.hwx.schemas", + "name": "ComplexDevice", + "fields": [ + { + "name": "xid", + "type": "long" + }, + { + "name": "txid", + "type": "long", + "default": 1 + }, + { + "name": "name", + "type": "string", + "default": "default" + }, + { + "name": "version", + "type": "int" + }, + { + "name": "longArrayFields", + "type": { + "type": "array", + "items": "long" + } + }, + { + "name": "complexArrayFields", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "field_element", + "fields": [ + { + "name": "arr_f_11", + "type": "string" + }, + { + "name": "arr_f_2", + "type": "int" + } + ] + } + } + }, + { + "name": "daysField", + "type": { + "name": "days", + "type": "enum", + "symbols": [ + "SUN", + "MON", + "TUES", + "WED", + "THURS", + "FRI", + "SAT" + ] + } + }, + { + "name": "md5", + "type": { + "name": "MD5", + "type": "fixed", + "size": 16 + } + }, + { + "name": "unionField", + "type": [ + "null", + "string" + ] + }, + { + "name": "longMapRecord", + "type": { + "name": "longMapRecordEntry", + "type": "record", + "fields": [ + { + "name": "map_f_1", + "type": { + "type": "map", + "values": "long" + } + } + ] + } + } + ] +} diff --git a/schema-registry/schema-registry-webservice/src/test/resources/schema-3.avsc b/schema-registry/schema-registry-webservice/src/test/resources/schema-3.avsc new file mode 100644 index 000000000..b59fc45f4 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/schema-3.avsc @@ -0,0 +1,94 @@ +{ + "type": "record", + "namespace": "com.hwx.schemas", + "name": "ComplexDevice", + "fields": [ + { + "name": "xid", + "type": "long" + }, + { + "name": "txid", + "type": "long", + "default": 1 + }, + { + "name": "version", + "type": "int" + }, + { + "name": "longArrayFields", + "type": { + "type": "array", + "items": "long" + } + }, + { + "name": "complexArrayFields", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "field_element", + "fields": [ + { + "name": "arr_f_11", + "type": "string" + }, + { + "name": "arr_f_2", + "type": "int" + } + ] + } + } + }, + { + "name": "daysField", + "type": { + "name": "days", + "type": "enum", + "symbols": [ + "SUN", + "MON", + "TUES", + "WED", + "THURS", + "FRI", + "SAT" + ] + } + }, + { + "name": "md5", + "type": { + "name": "MD5", + "type": "fixed", + "size": 16 + } + }, + { + "name": "unionField", + "type": [ + "null", + "string" + ] + }, + { + "name": "longMapRecord", + "type": { + "name": "longMapRecordEntry", + "type": "record", + "fields": [ + { + "name": "map_f_1", + "type": { + "type": "map", + "values": "long" + } + } + ] + } + } + ] +} diff --git a/schema-registry/schema-registry-webservice/src/test/resources/schema-4.avsc b/schema-registry/schema-registry-webservice/src/test/resources/schema-4.avsc new file mode 100644 index 000000000..b3f7b3955 --- /dev/null +++ b/schema-registry/schema-registry-webservice/src/test/resources/schema-4.avsc @@ -0,0 +1,99 @@ +{ + "type": "record", + "namespace": "com.hwx.schemas", + "name": "ComplexDevice", + "fields": [ + { + "name": "xid", + "type": "long" + }, + { + "name": "txid", + "type": "long", + "default": 1 + }, + { + "name": "name", + "type": "long", + "default": 0 + }, + { + "name": "version", + "type": "int" + }, + { + "name": "longArrayFields", + "type": { + "type": "array", + "items": "long" + } + }, + { + "name": "complexArrayFields", + "type": { + "type": "array", + "items": { + "type": "record", + "name": "field_element", + "fields": [ + { + "name": "arr_f_11", + "type": "string" + }, + { + "name": "arr_f_2", + "type": "int" + } + ] + } + } + }, + { + "name": "daysField", + "type": { + "name": "days", + "type": "enum", + "symbols": [ + "SUN", + "MON", + "TUES", + "WED", + "THURS", + "FRI", + "SAT" + ] + } + }, + { + "name": "md5", + "type": { + "name": "MD5", + "type": "fixed", + "size": 16 + } + }, + { + "name": "unionField", + "type": [ + "null", + "string" + ] + }, + { + "name": "longMapRecord", + "type": { + "name": "longMapRecordEntry", + "type": "record", + "fields": [ + { + "name": "map_f_1", + "type": { + "type": "map", + "values": "long" + } + } + ] + } + } + ] +}