Skip to content

does xk6-kafka support avro union type? #220

@luciowu

Description

@luciowu

Hello,

I am trying to use xk6-kafka with Avro format.
It is fine for me to use this example https://github.com/mostafa/xk6-kafka/blob/main/scripts/test_avro_no_schema_registry.js

But if I did a small modification on the code with avro union type (because in our case, we use union type) as the following

const valueSchema = JSON.stringify({
  type: "record",
  name: "Value",
  namespace: "dev.mostafa.xk6.kafka",
  fields: [
    {
      name: "name",
      type : ["null", "string"],
      default: null
    },
  ],
});

export default function () {
  for (let index = 0; index < 2; index++) {
    let messages = [
      {
        value: schemaRegistry.serialize({
          data: {
            name: "xk6-kafka",
          },
          schema: { schema: valueSchema },
          schemaType: SCHEMA_TYPE_AVRO,
        }),
      },
    ];

    writer.produce({ messages: messages });
  }

it will report error
executor=constant-vus scenario=sasl_auth source=stacktrace ERRO[0005] GoError: Failed to encode data, OriginalError: %!w(*errors.errorString=&{cannot decode textual record "dev.mostafa.xk6.kafka.Value": cannot decode textual union: expected: '{'; actual: '"' for key: "name"})

Not sure is this issue related to my code or this plugin. Could you help on it?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions