From 2e60b79dd4b4e85424c5edf4c3497b99db652c45 Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Fri, 12 Apr 2024 09:20:06 -0400 Subject: [PATCH] :bug: minor fixes to test runner Signed-off-by: Pranav Gaikwad --- cmd/test.go | 1 + pkg/testing/runner.go | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/test.go b/cmd/test.go index 951755a..655e74f 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -37,6 +37,7 @@ func NewTestCommand(log logr.Logger) *cobra.Command { RunLocal: Settings.RunLocal, ContainerImage: Settings.RunnerImage, ProgressPrinter: testing.PrintProgress, + Log: log.V(3), }) testing.PrintSummary(os.Stdout, results) if err != nil { diff --git a/pkg/testing/runner.go b/pkg/testing/runner.go index 974bfb0..16d0dd6 100644 --- a/pkg/testing/runner.go +++ b/pkg/testing/runner.go @@ -35,6 +35,7 @@ type TestOptions struct { RunLocal bool ContainerImage string ProgressPrinter ResultPrinter + Log logr.Logger } // TODO (pgaikwad): we need to move the default config to a common place @@ -42,11 +43,12 @@ type TestOptions struct { var defaultProviderConfig = []provider.Config{ { Name: "java", - BinaryPath: "/jdtls/bin/jdtls", + BinaryPath: "/usr/local/bin/java-external-provider", InitConfig: []provider.InitConfig{ { AnalysisMode: provider.FullAnalysisMode, ProviderSpecificConfig: map[string]interface{}{ + "lspServerName": "java", "bundles": "/jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar", "depOpenSourceLabelsFile": "/usr/local/etc/maven.default.index", provider.LspServerPathConfigKey: "/jdtls/bin/jdtls", @@ -139,19 +141,16 @@ func (r defaultRunner) Run(testFiles []TestsFile, opts TestOptions) ([]Result, e wg := &sync.WaitGroup{} - workerCount := 5 - // when running in container, we don't want to mount - // same base volumes concurrently in two different places - if !opts.RunLocal { - workerCount = 1 - } + workerCount := 1 // setup workers for idx := 0; idx < workerCount; idx += 1 { wg.Add(1) - go runWorker(wg, workerInputChan, resChan) + go runWorker(wg, workerInputChan, resChan, opts.Log) } // send input + wg.Add(1) go func() { + defer wg.Done() for idx := range testFiles { testFile := testFiles[idx] workerInputChan <- workerInput{ @@ -203,7 +202,7 @@ func (r defaultRunner) Run(testFiles []TestsFile, opts TestOptions) ([]Result, e return results, nil } -func runWorker(wg *sync.WaitGroup, inChan chan workerInput, outChan chan []Result) { +func runWorker(wg *sync.WaitGroup, inChan chan workerInput, outChan chan []Result, log logr.Logger) { defer wg.Done() for input := range inChan { results := []Result{} @@ -222,6 +221,7 @@ func runWorker(wg *sync.WaitGroup, inChan chan workerInput, outChan chan []Resul Error: fmt.Errorf("failed creating temp dir - %w", err)}) continue } + log.Info("created temporary directory", "dir", tempDir, "tests", input.testsFile.Path) // print analysis logs to a file logFile, err := os.OpenFile(filepath.Join(tempDir, "analysis.log"), os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644) if err != nil { @@ -338,6 +338,8 @@ func runLocal(logFile io.Writer, dir string, analysisParams AnalysisParams) (str filepath.Join(dir, "output.yaml"), "--rules", filepath.Join(dir, "rules.yaml"), + "--verbose", + "20", } if analysisParams.DepLabelSelector != "" { args = append(args, []string{ @@ -363,6 +365,8 @@ func runInContainer(consoleLogger logr.Logger, image string, logFile io.Writer, "/shared/output.yaml", "--rules", "/shared/rules.yaml", + "--verbose", + "20", } if analysisParams.DepLabelSelector != "" { args = append(args, []string{