Skip to content
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

TestStep variables proof of concept #83

Merged
merged 7 commits into from
Aug 8, 2022
Merged

TestStep variables proof of concept #83

merged 7 commits into from
Aug 8, 2022

Conversation

rihter007
Copy link
Contributor

PoC for #25

Introduced a new interface for step plugins:

type StepsVariables interface {
	Add(tgtID string, name string, v interface{}) error
	Get(tgtID string, name string, v interface{}) error
}

that can add/read variables from current/previous steps.

A mapping between external->internal variables is represented as StepVariablesMapping type which was added to step bundles.

In order to keep PR short, will add parameters template + better testing including e2e in the next PR

@rihter007 rihter007 force-pushed the poc/steps_variables branch 2 times, most recently from ebde5f4 to 9db5bb3 Compare June 21, 2022 12:55
@xaionaro
Copy link
Member

xaionaro commented Jun 21, 2022

Get(tgtID string, name string, v interface{}) error

It puts the value into v?

@rihter007
Copy link
Contributor Author

Get(tgtID string, name string, v interface{}) error

It puts the value into v?

yes, probably I should rename method/variable for more clearity. v -> out

@rihter007 rihter007 force-pushed the poc/steps_variables branch 6 times, most recently from b999ab2 to d34f891 Compare June 21, 2022 18:11
@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2022

Codecov Report

Merging #83 (8196bfa) into main (927ea7f) will decrease coverage by 0.01%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
- Coverage   63.85%   63.84%   -0.02%     
==========================================
  Files         163      164       +1     
  Lines       10170    10291     +121     
==========================================
+ Hits         6494     6570      +76     
- Misses       2980     3006      +26     
- Partials      696      715      +19     
Flag Coverage Δ
e2e 49.93% <37.95%> (-0.32%) ⬇️
integration 55.41% <46.20%> (-0.25%) ⬇️
unittests 49.36% <62.50%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/jobmanager/bundles.go 70.83% <ø> (ø)
pkg/pluginregistry/errors.go 33.33% <0.00%> (-66.67%) ⬇️
pkg/storage/limits/limits.go 100.00% <ø> (ø)
plugins/teststeps/echo/echo.go 8.00% <0.00%> (ø)
plugins/teststeps/randecho/randecho.go 6.66% <0.00%> (ø)
plugins/teststeps/sshcmd/sshcmd.go 1.20% <0.00%> (ø)
tests/integ/jobmanager/jobdescriptors.go 71.42% <ø> (ø)
tests/plugins/teststeps/channels/channels.go 0.00% <0.00%> (ø)
tests/plugins/teststeps/hanging/hanging.go 0.00% <0.00%> (ø)
tests/plugins/teststeps/noreturn/noreturn.go 33.33% <0.00%> (ø)
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@xaionaro
Copy link
Member

xaionaro commented Jun 24, 2022

Get(tgtID string, name string, v interface{}) error

It puts the value into v?

yes, probably I should rename method/variable for more clearity. v -> out

Yeah, let's rename the variable v in the interface to in and out accordingly?

pkg/runner/test_runner.go Outdated Show resolved Hide resolved
pkg/runner/test_runner.go Outdated Show resolved Hide resolved
xaionaro
xaionaro previously approved these changes Jun 24, 2022
Copy link
Member

@xaionaro xaionaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have questions, request, but they can go in another PR. But the review wasn't careful, and I assume @mimir-d also wanted to go through, so I would recommend to wait :)

pkg/runner/test_runner.go Outdated Show resolved Hide resolved
pkg/runner/test_runner.go Outdated Show resolved Hide resolved
pkg/runner/test_runner.go Outdated Show resolved Hide resolved
pkg/runner/test_runner.go Outdated Show resolved Hide resolved
pkg/runner/test_runner.go Outdated Show resolved Hide resolved
@xaionaro
Copy link
Member

xaionaro commented Jun 24, 2022

My main concern here is that the PR contributes into tech debt we have in TestRunner. Let me quote myself from another chat:

Basically it is a mess of different ideas intertwined in muddy implicit fuss.

But I guess solving this issue is a whole another epic story.

@rihter007
Copy link
Contributor Author

My main concern here is that the PR contributes into tech debt we have in TestRunner. Let me quote myself from another chat:

Basically it is a mess of different ideas intertwined in muddy implicit fuss.

But I guess solving this issue is a whole another epic story.

I would say the main tech debt is in convoluted state machine implementation. If it will be moved into a separate logic, everything will be straightforward. Saving additional info at the end of the TestRunner.Run is straightforward

@rihter007 rihter007 force-pushed the poc/steps_variables branch 3 times, most recently from a33174b to 3187eb6 Compare June 27, 2022 11:31
@rihter007 rihter007 requested a review from xaionaro June 27, 2022 13:46
Copy link
Member

@mimir-d mimir-d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returning for the v2 breakage and comments

pkg/jobmanager/bundles.go Outdated Show resolved Hide resolved
pkg/runner/step_runner.go Show resolved Hide resolved
pkg/storage/limits/limits.go Outdated Show resolved Hide resolved
pkg/storage/limits/limits.go Outdated Show resolved Hide resolved
pkg/storage/limits/limits_test.go Outdated Show resolved Hide resolved
pkg/test/step.go Outdated Show resolved Hide resolved
pkg/test/step.go Outdated Show resolved Hide resolved
pkg/pluginregistry/bundles.go Outdated Show resolved Hide resolved
pkg/runner/test_runner.go Show resolved Hide resolved
pkg/runner/test_runner.go Show resolved Hide resolved
@mimir-d
Copy link
Member

mimir-d commented Jun 27, 2022

would also be useful to have a "permitted outputs" type of array in the plugin itself, and the framework checks if that's valid when emitting; like the Events one. this would also be able to be extracted as docs, otherwise there's no way of knowing what output a plugin produces without reading the code

@rihter007
Copy link
Contributor Author

rihter007 commented Jun 27, 2022

would also be useful to have a "permitted outputs" type of array in the plugin itself, and the framework checks if that's valid when emitting; like the Events one. this would also be able to be extracted as docs, otherwise there's no way of knowing what output a plugin produces without reading the code

I don't know, on the other hand it makes you each time to specify all the variables when using the plugin. We can add this later as improvement. And to get a list of that permitted outputs one still needs to read either a doc or code :)

@mimir-d
Copy link
Member

mimir-d commented Jun 28, 2022

makes you each time to specify all the variables when using the plugin

yes, but it can also act as a filter; if youre only interested in some outputs, you only write those for that specific plugin. The main point is to make things obvious for the reader, and adds some safety on top.
eg.

- name: cmd
  label: cmd0
  parameters:
    - ...
  outputs:
    - stdout

- name: echo
  label: echo0
  parameters:
    - message: "cmd said {{step_output `cmd0.stdout`}}"

# this would be an error
- name: echo
  label: echo1
  parameters:
    - message: "cmd said {{step_output `cmd0.stderr`}}"

And to get a list of that permitted outputs one still needs to read either a doc or code

only valid for the first writer, these descriptors are usually a write once, read many kind of thing so it would have value for the readers

@rihter007
Copy link
Contributor Author

only valid for the first writer, these descriptors are usually a write once, read many kind of thing so it would have value for the readers
If you mean copy-paste of test descriptors :)

Anyway we can add it later if we start to feel the need of that kind of documentation

@rihter007 rihter007 requested a review from mimir-d June 29, 2022 13:11
pkg/pluginregistry/bundles.go Outdated Show resolved Hide resolved
pkg/runner/step_runner.go Show resolved Hide resolved
pkg/runner/test_runner.go Show resolved Hide resolved
pkg/runner/test_steps_variables.go Show resolved Hide resolved
pkg/runner/test_steps_variables.go Show resolved Hide resolved
pkg/test/step.go Outdated Show resolved Hide resolved
@rihter007 rihter007 force-pushed the poc/steps_variables branch 3 times, most recently from 1306d17 to 979b7dd Compare July 20, 2022 18:39
@rihter007 rihter007 requested a review from mimir-d July 20, 2022 18:50
mimir-d
mimir-d previously approved these changes Jul 25, 2022

// CheckIdentifier checks that input argument forms a valid identifier name
func CheckIdentifier(s string) error {
if len(s) == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer needed, checked by regex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it can't be omitted as FindString is used with further length comparison.
(MatchString doesn't finds any match and doesn't suit our needs)

@rihter007
Copy link
Contributor Author

rihter007 commented Aug 7, 2022

Rebased the PR. @mimir-d could you please restamp it?
Added https://github.com/linuxboot/contest/releases/tag/v1.0.0 release tag

@rihter007 rihter007 requested a review from mimir-d August 7, 2022 15:38
@rihter007 rihter007 force-pushed the poc/steps_variables branch from 9a8efb9 to 1052aa9 Compare August 7, 2022 15:46
@rihter007
Copy link
Contributor Author

Found a bug introduced by my previous PR, the fix is in #121

Add unit tests for CheckVariableName
Code-style improvements based on PR's comments

Signed-off-by: Ilya <[email protected]>
… of directly accessing internal variables

Signed-off-by: Ilya <[email protected]>
@rihter007 rihter007 force-pushed the poc/steps_variables branch from 39a8f78 to 8196bfa Compare August 8, 2022 10:43
@mimir-d mimir-d merged commit 768d780 into main Aug 8, 2022
@mimir-d mimir-d deleted the poc/steps_variables branch August 8, 2022 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants