Skip to content

Commit

Permalink
Simplified schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartboyd119 committed Sep 24, 2024
1 parent 0a4946b commit bbb0656
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 104 deletions.
11 changes: 4 additions & 7 deletions test/evolution/avro1/schema_1_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 41 additions & 47 deletions test/evolution/avro1x/schema_1_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions test/evolution/avro2/schema_2_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 9 additions & 13 deletions test/evolution/schema_1.avsc
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
{
"type": "record",
"name": "AryeoListingRecord",
"namespace": "com.zillowgroup.rmx.pem_schema",
"name": "Event",
"namespace": "com.zillowgroup",
"fields": [
{
"name": "id",
"type": "string",
"doc": "Id(uuid v7) of the underlying Aryeo Listing"
"type": "string"
},
{
"name": "deliveredAtDateTimeUtc",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
},
"doc": "Timestamp depicting when Aryeo's listing was delivered"
}
},
{
"name": "eventType",
"type": {
"type": "enum",
"name": "AryeoListingEventType",
"name": "EventType",
"symbols": [
"listingCreated",
"listingAssociated",
"listingMediDelivered"
"created",
"associated"
],
"default": "listingCreated"
},
"doc": "Enum depicting type of event"
"default": "created"
}
}
]
}
23 changes: 9 additions & 14 deletions test/evolution/schema_2.avsc
Original file line number Diff line number Diff line change
@@ -1,34 +1,30 @@
{
"type": "record",
"name": "AryeoListingRecord",
"namespace": "com.zillowgroup.rmx.pem_schema",
"name": "Event",
"namespace": "com.zillowgroup",
"fields": [
{
"name": "id",
"type": "string",
"doc": "Id(uuid v7) of the underlying Aryeo Listing"
"type": "string"
},
{
"name": "deliveredAtDateTimeUtc",
"type": {
"type": "long",
"logicalType": "timestamp-millis"
},
"doc": "Timestamp depicting when Aryeo's listing was delivered"
}
},
{
"name": "eventType",
"type": {
"type": "enum",
"name": "AryeoListingEventType",
"name": "EventType",
"symbols": [
"listingCreated",
"listingAssociated",
"listingMediDelivered"
"created",
"associated"
],
"default": "listingCreated"
},
"doc": "Enum depicting type of event"
"default": "created"
}
},
{
"name": "interactiveContent",
Expand All @@ -48,7 +44,6 @@
}
}
],
"doc": "InteractiveContent associated to Aryeo Listing",
"default": null
}
]
Expand Down
12 changes: 6 additions & 6 deletions test/schema_registry_evo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func Test_SchemaRegistryReal_Avro_AutoRegisterSchemas_BackwardCompatibleSchemasC
require.NoError(t, err)
listingID := uuid.NewString()

evt1 := avro1.AryeoListingRecord{
evt1 := avro1.Event{
ID: listingID,
DeliveredAtDateTimeUtc: time.Now().UTC().Truncate(time.Millisecond),
EventType: "listingCreated",
Expand All @@ -97,7 +97,7 @@ func Test_SchemaRegistryReal_Avro_AutoRegisterSchemas_BackwardCompatibleSchemasC

listingID2 := uuid.NewString()

evt2 := avro2.AryeoListingRecord{
evt2 := avro2.Event{
ID: listingID2,
DeliveredAtDateTimeUtc: time.Now().UTC().Truncate(time.Millisecond),
EventType: "listingCreated",
Expand Down Expand Up @@ -131,20 +131,20 @@ func Test_SchemaRegistryReal_Avro_AutoRegisterSchemas_BackwardCompatibleSchemasC

require.NoError(t, reader.Close())

receivedEvt1 := avro1.AryeoListingRecord{}
receivedEvt1 := avro1.Event{}
require.NoError(t, msg1.Decode(&receivedEvt1))
assertEqual(t, receivedEvt1, evt1)

receivedEvt2Schema1 := avro1.AryeoListingRecord{}
receivedEvt2Schema1 := avro1.Event{}
require.NoError(t, msg2.Decode(&receivedEvt2Schema1))
expectedEvt2 := avro1.AryeoListingRecord{
expectedEvt2 := avro1.Event{
ID: evt2.ID,
DeliveredAtDateTimeUtc: evt2.DeliveredAtDateTimeUtc,
EventType: evt2.EventType,
}
assertEqual(t, expectedEvt2, receivedEvt2Schema1)

receivedEvt2Schema2 := avro2.AryeoListingRecord{}
receivedEvt2Schema2 := avro2.Event{}
require.NoError(t, msg2.Decode(&receivedEvt2Schema2))
assertEqual(t, evt2, receivedEvt2Schema2)
}
Expand Down
14 changes: 7 additions & 7 deletions test/schema_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Test_SchemaRegistry_AutoRegisterSchemasFalse_WillNotWriteMessage(t *testing

listingID := uuid.NewString()

evt1 := avro1.AryeoListingRecord{
evt1 := avro1.Event{
ID: listingID,
DeliveredAtDateTimeUtc: time.Now().UTC().Truncate(time.Millisecond),
EventType: "listingCreated",
Expand Down Expand Up @@ -103,7 +103,7 @@ func Test_SchemaRegistry_Avro_AutoRegisterSchemas_RequiresSchemaSpecification(t

listingID := uuid.NewString()

evt1 := avro1.AryeoListingRecord{
evt1 := avro1.Event{
ID: listingID,
DeliveredAtDateTimeUtc: time.Now().UTC().Truncate(time.Millisecond),
EventType: "listingCreated",
Expand Down Expand Up @@ -145,10 +145,10 @@ func Test_SchemaNotRegistered_ResultsInWorkerDecodeError(t *testing.T) {

listingID := uuid.NewString()

evt1 := avro1x.AryeoListingRecord{
evt1 := avro1x.Event{
Id: listingID,
Deliveredatdatetimeutc: rand.Int63(),
Eventtype: avro1x.AryeoListingEventTypeListingcreated,
Eventtype: avro1x.EventTypeCreated,
}

_, err = writer1.Write(ctx, evt1)
Expand All @@ -173,7 +173,7 @@ func Test_SchemaNotRegistered_ResultsInWorkerDecodeError(t *testing.T) {
wf := zkafka.NewWorkFactory(client)
w := wf.CreateWithFunc(consumerTopicConfig, func(_ context.Context, msg *zkafka.Message) error {
defer cancel()
gotErr = msg.Decode(&avro1.AryeoListingRecord{})
gotErr = msg.Decode(&avro1.Event{})
return gotErr
})

Expand Down Expand Up @@ -217,7 +217,7 @@ func Test_SchemaRegistry_Avro_SubjectNameSpecification(t *testing.T) {

listingID := uuid.NewString()

evt1 := avro1.AryeoListingRecord{
evt1 := avro1.Event{
ID: listingID,
DeliveredAtDateTimeUtc: time.Now().UTC().Truncate(time.Millisecond),
EventType: "listingCreated",
Expand Down Expand Up @@ -255,7 +255,7 @@ func Test_SchemaRegistry_Avro_SubjectNameSpecification(t *testing.T) {

require.NoError(t, reader.Close())

receivedEvt1 := avro1.AryeoListingRecord{}
receivedEvt1 := avro1.Event{}
require.NoError(t, msg1.Decode(&receivedEvt1))
assertEqual(t, evt1, receivedEvt1)
}
Expand Down

0 comments on commit bbb0656

Please sign in to comment.