-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests with fake client-go for all parts of controller #60
Labels
enhancement
New feature or request
Comments
invidian
added a commit
that referenced
this issue
Apr 6, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
invidian
added a commit
that referenced
this issue
Apr 6, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
invidian
added a commit
that referenced
this issue
Apr 9, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
invidian
added a commit
that referenced
this issue
Apr 9, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
invidian
added a commit
that referenced
this issue
Apr 10, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
invidian
added a commit
that referenced
this issue
Apr 10, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
invidian
added a commit
that referenced
this issue
Apr 10, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
invidian
added a commit
that referenced
this issue
Apr 10, 2021
Refs #60 Signed-off-by: Mateusz Gozdek <[email protected]>
For operator, following tests must still be added:
FAIL "/tmp/go-mutesting-068518235/pkg/operator/agent_manager.go.5" with checksum d1d55f49f782e9210654d61f82593b99
Mutate "pkg/operator/operator.go"
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.0 2021-06-09 09:37:21.034736036 +0200
@@ -130,7 +130,7 @@
func New(config Config) (*Kontroller, error) {
// Kubernetes client.
if config.Client == nil {
- return nil, fmt.Errorf("kubernetes client must not be nil")
+ _ = fmt.Errorf
}
namespace := os.Getenv("POD_NAMESPACE")
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.0" with checksum 10e5a9c80ecb59d2cd4458c315a5b47b
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.1 2021-06-09 09:37:28.131506959 +0200
@@ -135,8 +135,8 @@
namespace := os.Getenv("POD_NAMESPACE")
if namespace == "" {
- return nil, fmt.Errorf("unable to determine operator namespace: please ensure POD_NAMESPACE " +
- "environment variable is set")
+ _ = fmt.Errorf
+
}
// TODO: a better id might be necessary.
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.1" with checksum a21ce2afe9752ccf387819f756ed0fb0
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.2 2021-06-09 09:37:29.514860983 +0200
@@ -145,7 +145,7 @@
// more likely to have a value.
hostname, err := os.Hostname()
if err != nil {
- return nil, fmt.Errorf("getting hostname: %w", err)
+ _, _ = fmt.Errorf, err
}
var rebootWindow *timeutil.Periodic
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.2" with checksum fb294b54e8a7490e34e018130c1511c9
Mutation did not compile
SKIP "/tmp/go-mutesting-068518235/pkg/operator/operator.go.3" with checksum 60255384368834043f9d7a377002468f
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.4 2021-06-09 09:37:31.378222365 +0200
@@ -153,7 +153,7 @@
if config.RebootWindowStart != "" && config.RebootWindowLength != "" {
rw, err := timeutil.ParsePeriodic(config.RebootWindowStart, config.RebootWindowLength)
if err != nil {
- return nil, fmt.Errorf("parsing reboot window: %w", err)
+ _, _ = fmt.Errorf, err
}
rebootWindow = rw
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.43" with checksum 2961cdc6043ea49e15f279886ccd536f
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.44 2021-06-09 09:40:39.155245246 +0200
@@ -201,7 +201,7 @@
// Start Flatcar Container Linux node auto-labeler.
if k.autoLabelContainerLinux {
- go wait.Until(func() { k.legacyLabeler(ctx) }, k.reconciliationPeriod, ctx.Done())
+ go wait.Until(func() { _, _ = k.legacyLabeler, ctx }, k.reconciliationPeriod, ctx.Done())
}
klog.V(5).Info("starting controller")
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.28 2021-06-09 09:39:49.577466457 +0200
@@ -504,7 +504,7 @@
rebootingNodes = append(rebootingNodes, afterRebootNodes...)
// Verify the number of currently rebooting nodes is less than the the maximum number.
- if len(rebootingNodes) >= k.maxRebootingNodes {
+ if len(rebootingNodes) > k.maxRebootingNodes {
for _, n := range rebootingNodes {
klog.Infof("Found node %q still rebooting, waiting", n.Name)
}
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.28" with checksum b3cf0a6acede66bad151008bddd0ca1c
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.29 2021-06-09 09:39:55.750933852 +0200
@@ -523,7 +523,7 @@
// Choose some number of nodes.
chosenNodes := make([]*corev1.Node, 0, remainingRebootableCount)
- for i := 0; i < remainingRebootableCount && i < len(rebootableNodes); i++ {
+ for i := 0; i <= remainingRebootableCount && i < len(rebootableNodes); i++ {
chosenNodes = append(chosenNodes, &rebootableNodes[i])
}
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.29" with checksum c8d2cd7949c2e71e232171a67e6a1e10
PASS "/tmp/go-mutesting-068518235/pkg/operator/operator.go.30" with checksum d6db1c5e6969cbb246a129f7fa80ee7d
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.31 2021-06-09 09:40:03.997781656 +0200
@@ -587,7 +587,7 @@
return fmt.Errorf("setting label %q to %q on node %q: %w", label, constants.True, nodeName, err)
}
- if len(annotations) > 0 {
+ if len(annotations) >= 0 {
klog.Infof("Waiting for %s annotations on node %q: %v", annotationsType, nodeName, annotations)
}
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.31" with checksum e0c432d45d9320fc7b24663c2a1b2029
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.32 2021-06-09 09:40:11.104606254 +0200
@@ -150,7 +150,7 @@
var rebootWindow *timeutil.Periodic
- if config.RebootWindowStart != "" && config.RebootWindowLength != "" {
+ if true && config.RebootWindowLength != "" {
rw, err := timeutil.ParsePeriodic(config.RebootWindowStart, config.RebootWindowLength)
if err != nil {
return nil, fmt.Errorf("parsing reboot window: %w", err)
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.32" with checksum 37341006ccf25fa3c57423dfd8fe336b
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.33 2021-06-09 09:40:13.297988665 +0200
@@ -150,7 +150,7 @@
var rebootWindow *timeutil.Periodic
- if config.RebootWindowStart != "" && config.RebootWindowLength != "" {
+ if config.RebootWindowStart != "" && true {
rw, err := timeutil.ParsePeriodic(config.RebootWindowStart, config.RebootWindowLength)
if err != nil {
return nil, fmt.Errorf("parsing reboot window: %w", err)
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.33" with checksum e58d4ceb1c572eb917ecedb02f58e705
--- pkg/operator/operator.go 2021-06-09 09:35:27.556903533 +0200
+++ /tmp/go-mutesting-068518235/pkg/operator/operator.go.34 2021-06-09 09:40:14.638018725 +0200
@@ -523,7 +523,7 @@
// Choose some number of nodes.
chosenNodes := make([]*corev1.Node, 0, remainingRebootableCount)
- for i := 0; i < remainingRebootableCount && i < len(rebootableNodes); i++ {
+ for i := 0; true && i < len(rebootableNodes); i++ {
chosenNodes = append(chosenNodes, &rebootableNodes[i])
}
FAIL "/tmp/go-mutesting-068518235/pkg/operator/operator.go.34" with checksum 2ff3cca35e3e0e47842e240943ef1b36 |
Agent tests has been finally added in #116. We have left:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given that this operator simply operates on Node objects, we should be able to use client-go to run both operator and node agent usign fake client-go and with mock D-Bus to test most parts of those controllers.
The text was updated successfully, but these errors were encountered: