Add ability to configure object reaper interval for different executor types (#2543)
Added properties to configure object reaper interval, global and specific to exec type. OBJECT_REAPER_INTERVAL - global NEWDEPLOY_OBJECT_REAPER_INTERVAL - for new deploy type CONTAINER_OBJECT_REAPER_INTERVAL - for container type POOLMGR_OBJECT_REAPER_INTERVAL - for poolmgr
This commit is contained in:
@@ -18,12 +18,17 @@ package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"github.com/fission/fission/pkg/utils/loggerfactory"
|
||||
)
|
||||
|
||||
func TestGetSpecFromConfigMap(t *testing.T) {
|
||||
@@ -112,3 +117,52 @@ securityContext:
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetObjectReaperInterval(t *testing.T) {
|
||||
logger := loggerfactory.GetLogger()
|
||||
|
||||
var want uint
|
||||
|
||||
// Test default reaper interval
|
||||
want = 1
|
||||
got := GetObjectReaperInterval(logger, fv1.ExecutorTypeContainer, want)
|
||||
if want != got {
|
||||
t.Fatalf(`Get default ObjectReaperInterval failed. Want %d, Got %d`, want, got)
|
||||
}
|
||||
|
||||
// Test when only specific reaper interval set
|
||||
want = 2
|
||||
os.Setenv("CONTAINER_OBJECT_REAPER_INTERVAL", fmt.Sprint(want))
|
||||
os.Unsetenv("OBJECT_REAPER_INTERVAL")
|
||||
got = GetObjectReaperInterval(logger, fv1.ExecutorTypeContainer, 5)
|
||||
if want != got {
|
||||
t.Fatalf(`%d %d`, want, got)
|
||||
}
|
||||
|
||||
// Test when only global reaper interval set
|
||||
want = 3
|
||||
os.Unsetenv("CONTAINER_OBJECT_REAPER_INTERVAL")
|
||||
os.Setenv("OBJECT_REAPER_INTERVAL", fmt.Sprint(want))
|
||||
got = GetObjectReaperInterval(logger, fv1.ExecutorTypeContainer, 5)
|
||||
if want != got {
|
||||
t.Fatalf(`%d %d`, want, got)
|
||||
}
|
||||
|
||||
// Test when broken specific reaper interval set
|
||||
want = 4
|
||||
os.Setenv("CONTAINER_OBJECT_REAPER_INTERVAL", "just some string!")
|
||||
os.Unsetenv("OBJECT_REAPER_INTERVAL")
|
||||
got = GetObjectReaperInterval(logger, fv1.ExecutorTypeContainer, want)
|
||||
if want != got {
|
||||
t.Fatalf(`%d %d`, want, got)
|
||||
}
|
||||
|
||||
// Test when empty specific reaper interval set
|
||||
want = 5
|
||||
os.Setenv("CONTAINER_OBJECT_REAPER_INTERVAL", "")
|
||||
os.Unsetenv("OBJECT_REAPER_INTERVAL")
|
||||
got = GetObjectReaperInterval(logger, fv1.ExecutorTypeContainer, 5)
|
||||
if want != got {
|
||||
t.Fatalf(`%d %d`, want, got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user