From 056bf86bc449a3ae291ff5960dc227f299221b27 Mon Sep 17 00:00:00 2001 From: Lucas Hinderberger Date: Tue, 4 Jun 2024 12:19:27 +0200 Subject: [PATCH] Fix for "make apitest" regressions due to backtick fix Contrary to what we've first assumed, the recursion after template evaluation is currently required for correctly running the datastore tests. But since parallelRepititions was incorrectly assumed to be never zero, the recursive call to parseAndRunTest would never actually run its tests. This partially reverts commit f2c79372c23a4086850b5e3cf8ffbb5ef1ec678e. --- api_testsuite.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/api_testsuite.go b/api_testsuite.go index 30ef522..dc026f5 100644 --- a/api_testsuite.go +++ b/api_testsuite.go @@ -234,10 +234,11 @@ func (ats *Suite) parseAndRunTest(v any, manifestDir, testFilePath string, k, re case string: parallelRepititions, _ = util.GetParallelPathSpec(t) - // FIXME - Shouldn't this be > 1 (also in util.IsParallelPathSpec)? - // If so, the declaration in L.6 can be removed and this can be turned - // into a declaration and moved to after the if block. isParallelPathSpec = parallelRepititions > 0 + + if parallelRepititions < 1 { + parallelRepititions = 1 + } } //Get the Manifest with @ logic @@ -253,13 +254,21 @@ func (ats *Suite) parseAndRunTest(v any, manifestDir, testFilePath string, k, re } // Parse as template always - testObj, err = loader.Render(testObj, filepath.Join(manifestDir, dir), nil) - if err != nil { - r.SaveToReportLog(err.Error()) - logrus.Error(fmt.Errorf("can not render template (%s): %s", testFilePath, err)) + requestBytes, lErr := loader.Render(testObj, filepath.Join(manifestDir, dir), nil) + if lErr != nil { + r.SaveToReportLog(lErr.Error()) + logrus.Error(fmt.Errorf("can not render template (%s): %s", testFilePath, lErr)) return false } + // If objects are different, we did have a Go template, recurse one level deep + if string(requestBytes) != string(testObj) { + return ats.parseAndRunTest([]byte(requestBytes), filepath.Join(manifestDir, dir), + testFilePath, k, parallelRepititions, isParallelPathSpec, r, loader) + } + + testObj = requestBytes + //Try to directly unmarshal the manifest into testcase array var testCases []json.RawMessage err = util.Unmarshal(testObj, &testCases)