added manger to keep track of go routines in the services (#2869)

- added manager to wait for all go routines to end before exit
- code refactor
- renamed Manafer to Interface and GoRoutineManager to GroupManager
- replaced some go routine calls with manager Add func
- added unit tests for manager
This commit is contained in:
Vardhaman Surana
2023-11-07 15:30:48 +05:30
committed by GitHub
parent 27132975c4
commit 2a40b4538c
24 changed files with 283 additions and 67 deletions
+9 -2
View File
@@ -35,6 +35,7 @@ import (
"github.com/fission/fission/pkg/crd"
"github.com/fission/fission/pkg/storagesvc"
"github.com/fission/fission/pkg/utils/manager"
)
const (
@@ -86,6 +87,9 @@ func TestS3StorageService(t *testing.T) {
fmt.Println("Test S3 Storage service")
var minioClient *minio.Client
mgr := manager.New()
defer mgr.Wait()
// Start minio docker container
pool, err := dockertest.NewPool("")
resource := runMinioDockerContainer(pool)
@@ -139,7 +143,7 @@ func TestS3StorageService(t *testing.T) {
storage := storagesvc.NewS3Storage()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_ = storagesvc.Start(ctx, crd.NewClientGenerator(), logger, storage, port)
_ = storagesvc.Start(ctx, crd.NewClientGenerator(), logger, storage, mgr, port)
time.Sleep(time.Second)
client := MakeClient(fmt.Sprintf("http://localhost:%v/", 8081))
@@ -205,6 +209,9 @@ func TestLocalStorageService(t *testing.T) {
testID := uniuri.NewLen(8)
port := 8082
mgr := manager.New()
defer mgr.Wait()
config := zap.NewDevelopmentConfig()
config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
logger, err := config.Build()
@@ -217,7 +224,7 @@ func TestLocalStorageService(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
os.Setenv("METRICS_ADDR", "8083")
_ = storagesvc.Start(ctx, crd.NewClientGenerator(), logger, storage, port)
_ = storagesvc.Start(ctx, crd.NewClientGenerator(), logger, storage, mgr, port)
time.Sleep(time.Second)
client := MakeClient(fmt.Sprintf("http://localhost:%v/", port))