pmalhaire / xk6-mqtt

k6 mqtt extension
Apache License 2.0
49 stars 37 forks source link

Failing to Build using xk6 - "unknown field 'Metric' in struct literal of type metrics.Sample" #13

Closed PatrickLevy closed 1 year ago

PatrickLevy commented 1 year ago

Description First of all, thank you for this extension! I have been using it for a little while and it has worked wonderfully. Just recently xk6 has started failing to build when I include this extension.

Steps to reproduce:

xk6 build --with github.com/pmalhaire/xk6-mqtt@latest

Example output

~/stresstesting (master) $ xk6 build --with github.com/pmalhaire/xk6-mqtt@latest

... etc.

2022/11/11 23:52:36 [INFO] exec (timeout=0s): /usr/local/opt/go@1.18/bin/go mod edit -require go.k6.io/k6@latest
2022/11/11 23:52:36 [INFO] exec (timeout=0s): /usr/local/opt/go@1.18/bin/go mod tidy
go: finding module for package github.com/pmalhaire/xk6-mqtt
go: found github.com/pmalhaire/xk6-mqtt in github.com/pmalhaire/xk6-mqtt v0.38.0
2022/11/11 23:52:37 [INFO] exec (timeout=0s): /usr/local/opt/go@1.18/bin/go mod edit -require github.com/pmalhaire/xk6-mqtt@latest
2022/11/11 23:52:37 [INFO] exec (timeout=0s): /usr/local/opt/go@1.18/bin/go mod tidy
2022/11/11 23:52:37 [INFO] Build environment ready
2022/11/11 23:52:37 [INFO] Building k6
2022/11/11 23:52:37 [INFO] exec (timeout=0s): /usr/local/opt/go@1.18/bin/go mod tidy
2022/11/11 23:52:37 [INFO] exec (timeout=0s): /usr/local/opt/go@1.18/bin/go build -o /Users/patlevy/Exosite/exosense/loadtesting/murano-stress-test/stresstesting/k6 -ldflags -w -s -trimpath
# github.com/pmalhaire/xk6-mqtt
../../../../../go/pkg/mod/github.com/pmalhaire/xk6-mqtt@v0.38.0/publish.go:40:18: unknown field 'Metric' in struct literal of type metrics.Sample
../../../../../go/pkg/mod/github.com/pmalhaire/xk6-mqtt@v0.38.0/subscribe.go:71:19: unknown field 'Metric' in struct literal of type metrics.Sample
2022/11/11 23:53:02 [INFO] Cleaning up temporary folder: /Users/patlevy/stresstesting/buildenv_2022-11-11-2352.1238861476
2022/11/11 23:53:02 [FATAL] exit status 2
pmalhaire commented 1 year ago

Thank you for reporting, do you have xk6 version used in the build ?, so I can reproduce your issue.

It's probably due to an update in the xk6 code base not yet taken into account it this extension, I'll try with latest xk6.

Best

pmalhaire commented 1 year ago

I reproduced the issue, I could fix the code but unfortunately no the tests yet, I'll provide the fix soon. I have a quick fix which is to temporary comment tests, I'll do this if I can't find a better way in the coming days.

PatrickLevy commented 1 year ago

Ok, thanks for confirmation! It looks like a work-around is to build with version v0.40.0 or older of k6. I apologize I didn't outline this earlier, I thought I had tried building with older versions but I think I was specifying the version number incorrectly so it was failing for a different reason.

This all seems to confirm that the breaking changes introduced here are causing the problems.

Works:

xk6 build v0.40.0 --with github.com/pmalhaire/xk6-mqtt@latest

Fails

xk6 build v0.41.0 --with github.com/pmalhaire/xk6-mqtt@latest
pmalhaire commented 1 year ago

It should be fixed and work with latest k6 version (the bad way for now)

pmalhaire commented 1 year ago

@PatrickLevy is it fixed for you as well ? I'll reopen if it's not