Skip to content

Commit

Permalink
Add config for packageserver wakeup interval
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Short <[email protected]>
  • Loading branch information
tmshort committed Sep 28, 2023
1 parent 28c6773 commit 58cc928
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 9 deletions.
3 changes: 3 additions & 0 deletions crds/operators.coreos.com_olmconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ spec:
disableCopiedCSVs:
description: DisableCopiedCSVs is used to disable OLM's "Copied CSV" feature for operators installed at the cluster scope, where a cluster scoped operator is one that has been installed in an OperatorGroup that targets all namespaces. When reenabled, OLM will recreate the "Copied CSVs" for each cluster scoped operator.
type: boolean
packageServerWakeupInterval:
description: PackageServerWakeupInterval is used to define the wakeup interval for packagerservers
type: string
status:
description: OLMConfigStatus is the status for an OLMConfig resource.
type: object
Expand Down
16 changes: 7 additions & 9 deletions crds/zz_defs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions pkg/operators/v1/olmconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,85 @@ package v1

import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func boolPointer(in bool) *bool {
return &in
}
func TestPackageServerWakeupInterval(t *testing.T) {
five := time.Minute * 5
one := time.Second * 60

fiveParsed, err := time.ParseDuration("5m")
assert.NoError(t, err)

oneParsed, err := time.ParseDuration("60s")
assert.NoError(t, err)

tests := []struct {
description string
olmConfig *OLMConfig
expected *time.Duration
}{
{
description: "NilConfig",
olmConfig: nil,
expected: nil,
},
{
description: "MissingSpec",
olmConfig: &OLMConfig{},
expected: nil,
},
{
description: "MissingFeatures",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{},
},
expected: nil,
},
{
description: "MissingPackageServerInterval",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{},
},
expected: nil,
},
{
description: "PackageServerInterval5m",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{
Features: &Features{
PackageServerWakeupInterval: &metav1.Duration{Duration: fiveParsed},
},
},
},
expected: &five,
},
{
description: "PackageServerInterval60s",
olmConfig: &OLMConfig{
Spec: OLMConfigSpec{
Features: &Features{
PackageServerWakeupInterval: &metav1.Duration{Duration: oneParsed},
},
},
},
expected: &one,
},
}

for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
require.EqualValues(t, tt.expected, tt.olmConfig.PackageServerWakeupInterval())
})
}
}
func TestCopiedCSVsAreEnabled(t *testing.T) {
tests := []struct {
description string
Expand Down
Loading

0 comments on commit 58cc928

Please sign in to comment.