From 313fdca1dfa18be77e821e7906e5a05cf0350cf5 Mon Sep 17 00:00:00 2001 From: Olga Naydyonock Date: Mon, 5 Aug 2024 14:44:31 +0300 Subject: [PATCH] [CI] Module parsing fix (#40053) Currently if CI detects changes in more than one module locations, e.g. `elasticsearch` and `system`, it defines a comma separated string like `MODULE=elasticsearch,system`, which results in the error `Error: no module elasticsearch,system` [link](https://github.com/elastic/beats/blob/main/dev-tools/mage/gotest.go#L209). This commit fixes the above bug by running each module test sequentially. Closes https://github.com/elastic/ingest-dev/issues/3508 --------- Co-authored-by: Dimitrios Liappis --- dev-tools/mage/gotest.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/dev-tools/mage/gotest.go b/dev-tools/mage/gotest.go index fb03c8d48fa..5d507c65aa4 100644 --- a/dev-tools/mage/gotest.go +++ b/dev-tools/mage/gotest.go @@ -168,7 +168,22 @@ func DefaultTestBinaryArgs() TestBinaryArgs { // Use RACE_DETECTOR=true to enable the race detector. // Use MODULE=module to run only tests for `module`. func GoTestIntegrationForModule(ctx context.Context) error { - module := EnvOr("MODULE", "") + modules := EnvOr("MODULE", "") + if modules == "" { + log.Printf("Warning: environment variable MODULE is empty: [%s]\n", modules) + } + moduleArr := strings.Split(modules, ",") + + for _, module := range moduleArr { + err := goTestIntegrationForSingleModule(ctx, module) + if err != nil { + return err + } + } + return nil +} + +func goTestIntegrationForSingleModule(ctx context.Context, module string) error { modulesFileInfo, err := os.ReadDir("./module") if err != nil { return err