Simplify TestStep API
@mimir-d ci sta già lavorando.
Dal 23/8/2022.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Issue by marcoguerri
Wednesday Feb 05, 2020 at 12:51 GMT
Originally opened as https://github.com/facebookincubator/contest/issues/23
I have been thinking of how to implement single target cancellation for two reasons:
- It's a feature we might want to support in the future
- I believed it would be necessary when losing locks on the targets. However, after reading again the implementation based on Zookeeper, if things go wrong, we'll lose the connection pool to the whole ensemble. So we won't lose per-target-locks, but we'll lose all locks: we'll need to cancel the whole job (which we can do now).
Even though number 2) doesn't really apply, I had some ideas on how to simplify the API for TestStep. There is now a good amount of duplication. Taking a sample TestStep as example:
func (ts *SSHCmd) Run(cancel, pause <-chan struct{}, ch teststep.TestStepChannels, params teststep.TestStepParameters, ev eventmanager.Emitter) error {
if err := ts.validateAndPopulate(params); err != nil {
return err
}
f := func(cancel, pause <-chan struct{}, target *target.Target) error {
// DO WORK
}
return teststeps.ForEachTarget(Name, cancel, pause, ch, f)
- Validate Params
- Define the function object
- Call ForEachTarget
I would divide the TestStep API into high level API (supporting ForEachTarget and ForAllTarget semantics), and low level API, which uses directly the channels and can be used if more complex Target aggregations are necessary. Most of the use cases should be covered by the high level API.
With the high level API, the plugin would not implement the TestStep interface, but would define function objects and parameters that would be used to instantiate a generic SingleTargetTestStep struct. For example, myplugin.go would do something as follows:
var pluginName = "myplugin"
func run(cancel, pause <-chan struct{}, target *target.Target) error {
// Do work
}
func resume(cancel, pause <-chan struct{}, target *target.Target) error {
// Do work
}
func NewMyPlugin() TestStep {
return teststep.NewSingleTargetTestStep{
Run: run,
Resume: resume,
Name: pluginName
}
}
How does this help?
- It makes it easier to implement the API, as it removes the duplicated code coming from having to define the TestStep struct, call validateAndPopulate, call ForEachTarget, etc. A possible "regression" is that
validateAndPopulatewill change semantics, it will only be validate, there won't be anything to populate. I think it's fine, and it's actually in line with the direction we have taken to offload parameter expansion to theParamsobject. - It will move the responsibility to schedule each Target into a
TestStepinstance to theTestRunner: this will allow per-Target control. - It allows to implement the
ForAllTargetssemantics in the same way, also reducing at minimum the duplication - It will still allow to use the "low level API", i.e. implementing directly the
TestStepinterface and use the channels directly.
- Lingua principale
- Go
- Stelle
- 20
- Fork
- 17
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di linuxboot/contest
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
update readmeForse già presa @mimir-d l’ha presa 1255 giorni fa. Apertabug documentation
-
enhancement good first issue
Difficoltà 3/5 1-2 giorni Idoneità per principianti 38/100
-
enhancement good first issue v2_overhaul
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
enhancement good first issue
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
Tutte le issue di linuxboot/contest
Issue simili
-
📖 docs: Docker Compose quick start doesn't mention editing the project values in src/hive.yamlApertadocumentation help wanted needs-triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 75/100
hivecommons/hive#11606 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[docs] `/docs/identity-security/usage/alerts/`: docs reference a date that has already passedApertadocumentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
gravitational/teleport#69869 ·
-
category:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
LanternOps/breeze#8493 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
shaiknoorullah/hg-mono#815 ·
I maintainer di solito rispondono entro 1 giorno