From 61df65fc5fdbeddd3be44e546c2714f41cbfdb9d Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Fri, 13 Sep 2024 14:55:39 -0600 Subject: [PATCH] Remove test/batch-test.go Tests already exist for this at internal/pkg/batch/batch_test.go Signed-off-by: Jonathon Anderson --- test/batch-test.go | 48 ---------------------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 test/batch-test.go diff --git a/test/batch-test.go b/test/batch-test.go deleted file mode 100644 index b49e4c1f..00000000 --- a/test/batch-test.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "fmt" - "runtime" - "time" - - "github.com/warewulf/warewulf/internal/pkg/batch" -) - -func exampleJob(name string, id int) string { - fmt.Printf("[%d] %s started...\n", id, name) - time.Sleep(time.Second * time.Duration(id)) - fmt.Printf("[%d] %s ending...\n", id, name) - return name -} - -func main() { - - fmt.Printf("GOMAXPROCS=%d\n", runtime.GOMAXPROCS(0)) - - jobstorun := 100 - - // create batch pool to run 100 jobs at a time every 10 seconds - batchpool := batch.New(10) - retvalues := make(chan string, jobstorun) - - // submit a bunch of jobs - for i := 0; i < jobstorun; i++ { - - name := fmt.Sprintf("job-%04d", i) - id := i - batchpool.Submit(func() { - retvalues <- exampleJob(name, id) - }) - - } - - // Run all batch jobs to completion - batchpool.Run() - - close(retvalues) - - for s := range retvalues { - fmt.Printf("Return value is %s\n", s) - } - -}