-
Notifications
You must be signed in to change notification settings - Fork 687
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 operator interface for Probe pkg #4849
base: master
Are you sure you want to change the base?
Add operator interface for Probe pkg #4849
Conversation
- Add probeOperator to probe pkg - Add probeOperator to handler that uses probeUtils - Add probe operator as parameter to functions that use probe operations in probeUtils Signed-off-by: sukkyun2 <[email protected]>
Signed-off-by: sukkyun2 <[email protected]>
- Apply goimports Signed-off-by: sukkyun2 <[email protected]>
579cec1
to
5186dbf
Compare
can you check a build-pipeline? @sukkyun2 |
@@ -697,7 +697,7 @@ func ParseProbesFromManifestForRuns(wfType *dbChaosExperiment.ChaosExperimentTyp | |||
} | |||
|
|||
// GenerateExperimentManifestWithProbes - uses GenerateProbeManifest to get and store the respective probe attribute into Raw Data template for Non Cron Workflow | |||
func GenerateExperimentManifestWithProbes(manifest string, projectID string) (argoTypes.Workflow, error) { | |||
func GenerateExperimentManifestWithProbes(manifest string, projectID string, probeOperator *dbSchemaProbe.Operator) (argoTypes.Workflow, error) { |
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.
Rather than passing the operator as a parameter, better to add this to the Probe Service and then use it like so
func (p *probe) GenerateExperimentManifestWithProbes ... {
p.probeOperator.GetProbeByName
}
Otherwise every instance of this handler would require you to declare and pass on this probeOperator like this
something := GenerateExperimentManifestWithProbes(..previous params, interface.probeOperator)
The better approach would be to use this handler via the service
something := c.probeService.GenerateExperimentManifestWithProbes(..previous params)
Its easier to test in the long run, the test cases would actually be used as checkpoints with this approach. Which also means that the respective initializers would need to change. For example for the above
type experimentRunOps struct {
...previous values
probeService probeService.Service
}
func NewExperimentRunOps(...previous values, probeService probeService.Service) ExperimentRunOps {
return &experimentRunOps{
...previous values,
probeService: probeService,
}
}
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’ve made the changes as suggested. Thank you for the feedback.
@@ -855,7 +855,7 @@ func GenerateExperimentManifestWithProbes(manifest string, projectID string) (ar | |||
} | |||
|
|||
// GenerateCronExperimentManifestWithProbes - uses GenerateProbeManifest to get and store the respective probe attribute into Raw Data template | |||
func GenerateCronExperimentManifestWithProbes(manifest string, projectID string) (argoTypes.CronWorkflow, error) { | |||
func GenerateCronExperimentManifestWithProbes(manifest string, projectID string, probeOperator *dbSchemaProbe.Operator) (argoTypes.CronWorkflow, error) { |
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.
Same review for this, could be added to the Service interface and used like the above
- Updated handler to call GenerateExperimentManifestWithProbes, GenerateCronExperimentManifestWithProbes via ProbeService Signed-off-by: sukkyun2 <[email protected]>
- add mock probeService generated by mockery Signed-off-by: sukkyun2 <[email protected]>
Signed-off-by: sukkyun2 <[email protected]>
Proposed changes
This PR adds operator interface to probe pkg
#4836, I tried to add fuzz test for probe handler.
However, the current architecture made it impossible to mock probe operations, so I added probe operator interface.
This picture is about probe pkg.
References
Types of changes
What types of changes does your code introduce to Litmus? Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Dependency
Special notes for your reviewer:
I need feedback on the approach of passing
probeOperator
as a parameter to functions.For example, the function
GenerateExperimentManifestWithProbes
in chaoscenter/graphql/server/pkg/probe/utils/utils.go directly accesses probe operation. I have added theprobeOperator
dependency to the handler that usesGenerateExperimentManifestWithProbes
and updated the function calls to passprobeOperator
as a parameter.