kubeshop / testkube

☸️ Kubernetes-native testing framework for test execution and orchestration
https://testkube.io
Other
1.36k stars 132 forks source link

failed to list tests with executions - {aggregate: 1} is not valid for the current pipeline stage #4680

Closed michaelsatish closed 11 months ago

michaelsatish commented 11 months ago

Describe the bug After updating the testkube components, I am getting the below error on the tests page.

failed to list tests with executions: could not get latest executions: could not get latest executions for tests [to-test] sorted by start time: {aggregate: 1} is not valid for the current pipeline stage, context: null

Version / Cluster

Additional Information

I am using AWS DocumentDB, and here are the logs from API Server.

{"level":"warn","ts":1700825310.8240836,"caller":"api-server/main.go:276","msg":"failed to apply MongoDB migrations: failed to apply MongoDB migrations: migration '01_create_indexes' failed, rolled failed to: rolling back '01_create_indexes' failed.: ns not found: Index type not supported : hashed"}

{"level":"error","ts":1700825344.9348545,"caller":"server/httpserver.go:76","msg":"failed to list tests with executions: could not get latest executions: could not get latest executions for tests [to-test] sorted by start time: {aggregate: 1} is not valid for the current pipeline stage","status":500,"stacktrace":"github.com/kubeshop/testkube/pkg/server.(*HTTPServer).Error\n\t/home/runner/work/testkube/testkube/pkg/server/httpserver.go:76\ngithub.com/kubeshop/testkube/internal/app/api/v1.(*TestkubeAPI).InitRoutes.TestkubeAPI.ListTestWithExecutionsHandler.func37\n\t/home/runner/work/testkube/testkube/internal/app/api/v1/tests.go:227\ngithub.com/gofiber/fiber/v2.(*App).next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/router.go:132\ngithub.com/gofiber/fiber/v2.(*Ctx).Next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/ctx.go:945\ngithub.com/kubeshop/testkube/internal/app/api/v1.(*TestkubeAPI).InitRoutes.(*TestkubeAPI).AuthHandler.func2\n\t/home/runner/work/testkube/testkube/internal/app/api/v1/handlers.go:54\ngithub.com/gofiber/fiber/v2.(*Ctx).Next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/ctx.go:942\ngithub.com/gofiber/fiber/v2/middleware/cors.New.func1\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/middleware/cors/cors.go:141\ngithub.com/gofiber/fiber/v2.(*App).next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/router.go:132\ngithub.com/gofiber/fiber/v2.(*Ctx).Next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/ctx.go:945\ngithub.com/kubeshop/testkube/pkg/server.(*HTTPServer).Init.New.func2\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/middleware/pprof/pprof.go:41\ngithub.com/gofiber/fiber/v2.(*Ctx).Next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/ctx.go:942\ngithub.com/kubeshop/testkube/pkg/server.(*HTTPServer).Init.func1\n\t/home/runner/work/testkube/testkube/pkg/server/httpserver.go:46\ngithub.com/gofiber/fiber/v2.(*App).next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/router.go:132\ngithub.com/gofiber/fiber/v2.(*Ctx).Next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/ctx.go:945\ngithub.com/kubeshop/testkube/pkg/server.(*HTTPServer).Init.New.func2\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/middleware/pprof/pprof.go:41\ngithub.com/gofiber/fiber/v2.(*Ctx).Next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/ctx.go:942\ngithub.com/kubeshop/testkube/pkg/server.(*HTTPServer).Init.func1\n\t/home/runner/work/testkube/testkube/pkg/server/httpserver.go:46\ngithub.com/gofiber/fiber/v2.(*App).next\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/router.go:132\ngithub.com/gofiber/fiber/v2.(*App).handler\n\t/home/runner/go/pkg/mod/github.com/gofiber/fiber/v2@v2.39.0/router.go:159\ngithub.com/valyala/fasthttp.(*Server).serveConn\n\t/home/runner/go/pkg/mod/github.com/valyala/fasthttp@v1.44.0/server.go:2372\ngithub.com/valyala/fasthttp.(*workerPool).workerFunc\n\t/home/runner/go/pkg/mod/github.com/valyala/fasthttp@v1.44.0/workerpool.go:224\ngithub.com/valyala/fasthttp.(*workerPool).getCh.func1\n\t/home/runner/go/pkg/mod/github.com/valyala/fasthttp@v1.44.0/workerpool.go:196"}
vsukhin commented 11 months ago

thank you @michaelsatish will check it out. you can disable migrations using helm chart var. might be documentdb doesn't support indicies

michaelsatish commented 11 months ago

@vsukhin Thank you. I reverted back the API version to 1.15.20 and it worked again. May be the new version broke an existing functionality?

Looking at the diff, I see changes to pkg/repository/result/mongo.go https://github.com/kubeshop/testkube/compare/v1.15.20...v1.16.8

I am not experienced in mongo pipelines, if it helps here is the AWS DocumentDB stage operators https://docs.aws.amazon.com/documentdb/latest/developerguide/mongo-apis.html#mongo-apis-aggregation-pipeline-stage

rangoo94 commented 11 months ago

Hi @michaelsatish, the problem is that we have used hashed index that is not supported in the DocumentDB.

I don't think that it is a big problem for us to use regular index instead in the OSS version, so we will just do that 👍

Thank you for the report!

michaelsatish commented 11 months ago

Wonderful. Thank you so much @rangoo94

rangoo94 commented 11 months ago

Hi @michaelsatish!

The fix has been just released in v1.16.9 🎉 I hope that it helps.

Once again, thank you for reporting the problem!