Update controller e2e tests
Rewrite the controller tests to test the new behavior of the reconciler and also simplify the tests for scenarios that are now being tests in internal/source package, especially the git operations related tests. Some of the old controller tests are still kept to ensure those functionalities continue to work after the controller rewrite, even if some of them are redundant. They can be removed in the future for the tests in the respective subpackages, internal/policy and internal/source. New tests that focus the status conditions and notifications have been added for various possible scenarios. The test helpers have been modified to simplify their usage and some have been replaced with their equivalent version from the testutils package. Signed-off-by: Sunny <github@darkowlzz.space>
This commit is contained in:
parent
edc5cee43d
commit
f5a2940cd7
|
@ -57,7 +57,7 @@ import (
|
|||
"github.com/fluxcd/pkg/runtime/testenv"
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||
|
||||
image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
|
||||
image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta2"
|
||||
"github.com/fluxcd/image-automation-controller/pkg/update"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
Copyright 2022 The Flux authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
fuzz "github.com/AdaLogics/go-fuzz-headers"
|
||||
)
|
||||
|
||||
func Fuzz_templateMsg(f *testing.F) {
|
||||
f.Add("template", []byte{})
|
||||
f.Add("", []byte{})
|
||||
|
||||
f.Fuzz(func(t *testing.T, template string, seed []byte) {
|
||||
var values TemplateData
|
||||
fuzz.NewConsumer(seed).GenerateStruct(&values)
|
||||
|
||||
_, _ = templateMsg(template, &values)
|
||||
})
|
||||
}
|
|
@ -26,6 +26,7 @@ import (
|
|||
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/client-go/kubernetes/scheme"
|
||||
"k8s.io/client-go/tools/record"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
|
@ -34,7 +35,7 @@ import (
|
|||
"github.com/fluxcd/pkg/runtime/testenv"
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1"
|
||||
|
||||
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
|
||||
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta2"
|
||||
// +kubebuilder:scaffold:imports
|
||||
)
|
||||
|
||||
|
@ -85,9 +86,10 @@ func runTestsWithFeatures(m *testing.M, feats map[string]bool) int {
|
|||
|
||||
controllerName := "image-automation-controller"
|
||||
if err := (&ImageUpdateAutomationReconciler{
|
||||
Client: testEnv,
|
||||
EventRecorder: testEnv.GetEventRecorderFor(controllerName),
|
||||
features: feats,
|
||||
Client: testEnv,
|
||||
EventRecorder: record.NewFakeRecorder(32),
|
||||
features: feats,
|
||||
ControllerName: controllerName,
|
||||
}).SetupWithManager(ctx, testEnv, ImageUpdateAutomationReconcilerOptions{
|
||||
RateLimiter: controller.GetDefaultRateLimiter(),
|
||||
}); err != nil {
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: test
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: hello
|
||||
image: helloworld:1.0.1 # SETTER_SITE
|
|
@ -1,10 +0,0 @@
|
|||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: test
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: hello
|
||||
image: helloworld:1.2.0 # SETTER_SITE
|
|
@ -1 +0,0 @@
|
|||
/surely/does/not/exist
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue