Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema gets updated with every message produce #22

Closed
saad1200 opened this issue Sep 6, 2021 · 10 comments
Closed

Schema gets updated with every message produce #22

saad1200 opened this issue Sep 6, 2021 · 10 comments
Labels
🐛 Bug Something isn't working

Comments

@saad1200
Copy link

saad1200 commented Sep 6, 2021

I have notices an issue with produce with configuration with schema and schema serializer. For some reason the defaults (which can be null) are removed from from the server schema as soon as I run the tests.
It seems the goavro lib that is being used does this as part of serialization. The problem is, this schema later is used as in a post request to fitch the schema id from the server. This post request update the server schema in this case. I could not find a way that we provide the schema id to bypass this logic/behavior.

@ssam5532
Copy link

ssam5532 commented May 5, 2022

Any update on this?

@mostafa
Copy link
Owner

mostafa commented May 5, 2022

Hey @saad1200 @ssam5532!

Can any of you provide an example script (and/or configuration) you use, so I can test it? Or at least explain more details.

@saad1200
Copy link
Author

saad1200 commented May 5, 2022

@mostafa Any produce code example from the repo can be used to reproduce this. It has been few months now, but I think it is an issue with goavro lib.

we noticed that xk6-kafka is posting a new schema when called with produceWithConfiguration. Looks like it’s because they’re stripping out some of the java specific types and before posting the schema to the registry (which I guess they need to do, to get an ID).

req, err := http.NewRequest("POST", url, bytes.NewReader([]byte(body)))

If you look at line 54 and 56, goavro’s codec is turning the schema into and object, then making it into a string again on line 56.

@saad1200
Copy link
Author

saad1200 commented May 5, 2022

@ssam5532 our work around is to setup wiremock and use it as schema registry proxy. It is another dependency and far from ideal solution but allowed us to continue using K6.

@mostafa
Copy link
Owner

mostafa commented May 5, 2022

@saad1200
I suppose this can be fixed by trying to fetch the schema first before posting one. We can also use something like srclient and have it handle everything, but it's an extra dependency for just two HTTP requests.

Update:
Upon further investigation, I found out that it uses the internal HTTP client of Go, goavro v2, and jsonschema v5 as dependencies, so it's okay for our use-case. I'll try to see how I can integrate it and make a PR when ready.

@mostafa mostafa added the 🐛 Bug Something isn't working label May 7, 2022
mostafa added a commit that referenced this issue May 8, 2022
Add srclient dependency as a better way to access Schema Registry
Combine functions in Avro serdes
Change SchemaRegistryConfiguration and BasicAuth to fix issues (breaking change)
Validate configuration for all supported (and unsupported) serde functionlity
Default serde is now StringSerializer and StringDeserializer
Refactor wire format de/encoding
Fix bugs, typos and refactor the rest
@mostafa
Copy link
Owner

mostafa commented May 8, 2022

@saad1200 @ssam5532 I'd be happy to have your feedback on #52.

mostafa added a commit that referenced this issue May 9, 2022
* Use a proper Schema Registry client to fix issues in #22
* Add srclient dependency as a better way to access Schema Registry
* Combine functions in Avro serdes
* Change SchemaRegistryConfiguration and BasicAuth to fix issues (breaking change)
* Validate configuration for all supported (and unsupported) serde functionality
* Default serde is now StringSerializer and StringDeserializer
* Refactor wire format de/encoding
* Fix bugs and typos and refactor the rest
* Refactor basic auth function and move structs to their relevant files
* Fix linting errors reported by gosimple (golangci-lint)
@mostafa
Copy link
Owner

mostafa commented May 10, 2022

@saad1200 @ssam5532
The PR (#52) is merged now, and you can test it to see if it fixes the issue or not. I haven't released a version yet, so you need to build the latest main according to xk6 build instructions to test it. Let me know if you face any issues along the way!
Also, based on my tests, the schema doesn't get updated.

@mostafa mostafa closed this as completed May 13, 2022
@saad1200
Copy link
Author

@mostafa sorry for the delay. I will block some time next weekend to test the changes.

mostafa added a commit that referenced this issue May 31, 2022
* Use a proper Schema Registry client to fix issues in #22
* Add srclient dependency as a better way to access Schema Registry
* Combine functions in Avro serdes
* Change SchemaRegistryConfiguration and BasicAuth to fix issues (breaking change)
* Validate configuration for all supported (and unsupported) serde functionality
* Default serde is now StringSerializer and StringDeserializer
* Refactor wire format de/encoding
* Fix bugs and typos and refactor the rest
* Refactor basic auth function and move structs to their relevant files
* Fix linting errors reported by gosimple (golangci-lint)
@kusumkappdirect
Copy link

@saad1200 , can you please help me here. , my schema also get updated with each sent message on topic , how you retrieve the schema first and then send same ?

@saad1200
Copy link
Author

saad1200 commented Jul 16, 2022

@kusumkappdirect
If you are using latest release and still having this issue all you need to do is to setup wiremock on the dev server or locally, then in the k6 setup method get the schema from the schema registry and stub the methods to return that schema using wiremock. Pass wiremock address instead of the schema registry to the k6 extension produce method.
I will share my code with you soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
Status: Release
Development

No branches or pull requests

4 participants