-
Notifications
You must be signed in to change notification settings - Fork 18
Refactor implement step runner #48
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
240db9e
Implement StepRunner
rihter007 b451ac5
Use StepRunner in TestRunner
rihter007 377a270
Remove unused stepState.setErr function
rihter007 ebbd664
Treat StepRunner stopped when both reading and running loops exited
rihter007 bc6829d
Move stop callback notification on success when both reading and runn…
rihter007 9a03b4a
Start StepRunner via explicit Run method
rihter007 84ad31f
Increase successTimeout for integration unit tests
rihter007 c526388
Fix race condition in awaitTargetResult when both cancel and result r…
rihter007 63859b0
Fix race condition in accessing StepState.resumeState
rihter007 4d1094e
Remove unnecessary check StepRunner.AddTarget
rihter007 feacc06
Push result to target result channel without ctx.Done() check to avoi…
rihter007 adcf883
Minor code style improvement
rihter007 23f6645
Improve code-style
rihter007 c523ce2
Remove context from StepRunner
rihter007 462f278
Properly handle an error from StepRunner.Run
rihter007 759fc76
Add test description for ErrAlreadyDone
rihter007 566c2a1
Refactor reportTargetResult
rihter007 7922406
Return original behaviour to reportTargetResult
rihter007 5efe6d8
Add basic unit test for StepRunner
rihter007 62d049c
Code style improvements of StepRunner
rihter007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package runner | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/benbjohnson/clock" | ||
"github.com/linuxboot/contest/pkg/event/testevent" | ||
"github.com/linuxboot/contest/pkg/pluginregistry" | ||
"github.com/linuxboot/contest/pkg/target" | ||
"github.com/linuxboot/contest/pkg/test" | ||
"github.com/linuxboot/contest/pkg/xcontext" | ||
"github.com/linuxboot/contest/plugins/targetlocker/inmemory" | ||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type BaseTestSuite struct { | ||
suite.Suite | ||
|
||
pluginRegistry *pluginregistry.PluginRegistry | ||
internalStorage *MemoryStorageEngine | ||
} | ||
|
||
func (s *BaseTestSuite) SetupTest() { | ||
storageEngine, err := NewMemoryStorageEngine() | ||
require.NoError(s.T(), err) | ||
s.internalStorage = storageEngine | ||
|
||
target.SetLocker(inmemory.New(clock.New())) | ||
|
||
s.pluginRegistry = pluginregistry.NewPluginRegistry(xcontext.Background()) | ||
} | ||
|
||
func (s *BaseTestSuite) TearDownTest() { | ||
target.SetLocker(nil) | ||
} | ||
|
||
func (s *BaseTestSuite) RegisterStateFullStep( | ||
runFunction func( | ||
ctx xcontext.Context, ch test.TestStepChannels, params test.TestStepParameters, | ||
ev testevent.Emitter, resumeState json.RawMessage) (json.RawMessage, error), | ||
validateFunction func(ctx xcontext.Context, params test.TestStepParameters) error) error { | ||
|
||
return s.pluginRegistry.RegisterTestStep(stateFullStepName, func() test.TestStep { | ||
return &stateFullStep{ | ||
runFunction: runFunction, | ||
validateFunction: validateFunction, | ||
} | ||
}, nil) | ||
} | ||
|
||
func (s *BaseTestSuite) NewStep(label, name string, params test.TestStepParameters) test.TestStepBundle { | ||
td := test.TestStepDescriptor{ | ||
Name: name, | ||
Label: label, | ||
Parameters: params, | ||
} | ||
sb, err := s.pluginRegistry.NewTestStepBundle(ctx, td) | ||
require.NoError(s.T(), err) | ||
return *sb | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.