-
Notifications
You must be signed in to change notification settings - Fork 344
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
Fixes duplicate runs #401
Fixes duplicate runs #401
Conversation
@@ -46,8 +43,6 @@ type templateValues struct { | |||
|
|||
// GenerateManifest fills in a template with a Sonobuoy config | |||
func (c *SonobuoyClient) GenerateManifest(cfg *GenConfig) ([]byte, error) { | |||
// Provide defaults but don't overwrite any customized configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt this was not the appropriate place for setting defaults
some logs to show it's working |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only thing blocking is the giant thunk of duplicated tests.
}, | ||
}, | ||
}, | ||
raw: "not empty", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids the logic here https://github.com/heptio/sonobuoy/blob/master/cmd/sonobuoy/app/sonobuoyconfig.go#L63 so that I can supply my own config.
pkg/config/config.go
Outdated
|
||
// TODO(chuckha) here is a safety net in case a supplied plugin search path is provided in the custom config. | ||
// mergo will append the defaults to the provided slice which may not be the behavior we want. | ||
// This could go away if we change the assumptions about loading plugins change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you be a little clearer about what the TODO is?
pkg/config/config.go
Outdated
// This could go away if we change the assumptions about loading plugins change. | ||
uniqueSearchPaths := make(map[string]struct{}) | ||
for _, searchPath := range cfg.PluginSearchPath { | ||
if _, ok := uniqueSearchPaths[searchPath]; !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just unconditionally insert the element? should be an effective no-op if you're inserting the same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also bool
might make it more obvious you're just using this as a ersatz set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty struct is convention for a map used as a set, at least from what i've seen. I think kubernetes straight up maps type Empty struct{}
for the sets it uses. Either way this code is going away
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, TIL
@@ -14,16 +14,19 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
*/ | |||
|
|||
package config | |||
package config_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only tested the public api and I've found that when tests are in the same package there is a tendency to test internal details that don't really need testing. If for some reason a package local function needs testing and testing the public api that uses it isn't sufficient we can add another test file later if that sounds ok to you.
pkg/config/config_test.go
Outdated
@@ -37,3 +40,96 @@ func TestDefaults(t *testing.T) { | |||
t.Fatalf("Defaults should match but didn't") | |||
} | |||
} | |||
|
|||
func TestMerge(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests seem pretty much identical to the ones above. Are they exercising something significantly different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, i'll clean these up
9d42626
to
fe22a9d
Compare
pkg/plugin/loader/loader_test.go
Outdated
plugin.Selection{Name: "daemonset"}, | ||
plugin.Selection{Name: "job"}, | ||
} | ||
plugins, err := LoadAllPlugins(namespace, sonobuoyImage, imagePullPolicy, searchPath, selections) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops this test is broken. it passes but only because no tests are run. Fixing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one minor nit, then lgtm!
@@ -192,3 +192,24 @@ func TestFilterList(t *testing.T) { | |||
t.Errorf("expected %+#v, got %+#v", expected, filtered) | |||
} | |||
} | |||
|
|||
func TestLoadAllPlugins(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add a comment about what this is actually testing? or call it TestLoadAllPluginsRemovesDuplicates or smth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turned it into a table test with a description
* Ignore duplicate plugins during plugin loading. * Adds lots of tests for merging behavior. * Adds tests to some other parts of the code relating to configuration manipulation. Signed-off-by: Chuck Ha <chuck@heptio.com>
* Ignore duplicate plugins during plugin loading. * Adds lots of tests for merging behavior. * Adds tests to some other parts of the code relating to configuration manipulation. Signed-off-by: Chuck Ha <chuck@heptio.com> Signed-off-by: Jesse Hamilton jesse.hamilton@heptio.com
* Ignore duplicate plugins during plugin loading. * Adds lots of tests for merging behavior. * Adds tests to some other parts of the code relating to configuration manipulation. Signed-off-by: Chuck Ha <chuck@heptio.com> Signed-off-by: Jesse Hamilton jesse.hamilton@heptio.com Signed-off-by: Jesse Hamilton jesse.hamilton@heptio.com
* Ignore duplicate plugins during plugin loading. * Adds lots of tests for merging behavior. * Adds tests to some other parts of the code relating to configuration manipulation. Signed-off-by: Chuck Ha <chuck@heptio.com>
Signed-off-by: Chuck Ha chuck@heptio.com
What this PR does / why we need it:
Which issue(s) this PR fixes
Special notes for your reviewer:
Release note: