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

Don't stacktrace when calling unsupported plan functions through BoltSpec #2692

Closed
lucywyman opened this issue Mar 4, 2021 · 0 comments
Closed
Assignees
Labels
Bug Bug reports and fixes.

Comments

@lucywyman
Copy link
Contributor

lucywyman commented Mar 4, 2021

Describe the Bug

How do we want to handle unsupported plan functions in BoltSpec, like parallelize? Require they be mocked?

For run_task_with just have an 'allow' and basically require that that be set, so that the return value is mocked. Either a limited mock, or something that's not too unwieldy (since run_task_with return objects can be pretty large)

For parallelize, when 'round_robin' gets called define in the mock_executor to run things in order. If it's easier to run through actual round_robin we can probably do that since tasks shouldn't be delayed.

Part of this should be verifying that there aren't any other executor functions that need to be defined or handled in the mock executor.

It would be good to see if we can automate scanning the executor and verifying that anything is either marked private or defined in the mock executor, but if that breaks tests or takes more than half a day to implement it isn't a strict requirement for this ticket.

@lucywyman lucywyman added the Bug Bug reports and fixes. label Mar 4, 2021
@lucywyman lucywyman added this to 📝 To Do in Bolt Kanban via automation Mar 10, 2021
@beechtom beechtom self-assigned this Mar 11, 2021
@beechtom beechtom moved this from 📝 To Do to ⚡️ Doing in Bolt Kanban Mar 11, 2021
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
…tions

This adds a test that checks that all public methods on the
`Bolt::Executor` class are defined on the
`BoltSpec::Plans::MockExecutor` class. This is to ensure that if tests
run with BoltSpec invoke any methods on the executor that it will not
result in an "undefined method" error.

!no-release-note
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
This adds support for testing plans that use the `run_task_with()` plan
function to BoltSpec. When BoltSpec runs a plan with this function, it
will execute a separate task run for each target. Users making
assertions about tasks run with `run_task_with()` should make an
assertion about each individual target that the task runs against, or an
assertion about the number of times that the task is run. This includes
an example in the 'Testing plans' documentation that details how to test
these types of plans.

!feature

* **Test plans that use `run_task_with()` plan function in BoltSpec*
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `run_task_with()` plan function can now be tested
  with BoltSpec.
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
This adds support for testing plans that use the `parallelize()` plan
function in BoltSpec. The block passed to the function is evaluated
using each object sequentially instead of in parallel.

!feature

* **Test plans that use `parallelize()` plan function in BoltSpec**
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `parallelize()` plan function can now be tested
  with BoltSpec.
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
…tions

This adds a test that checks that all public methods on the
`Bolt::Executor` class are defined on the
`BoltSpec::Plans::MockExecutor` class. This is to ensure that if tests
run with BoltSpec invoke any methods on the executor that it will not
result in an "undefined method" error.

!no-release-note
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
This adds support for testing plans that use the `run_task_with()` plan
function to BoltSpec. When BoltSpec runs a plan with this function, it
will execute a separate task run for each target. Users making
assertions about tasks run with `run_task_with()` should make an
assertion about each individual target that the task runs against, or an
assertion about the number of times that the task is run. This includes
an example in the 'Testing plans' documentation that details how to test
these types of plans.

!feature

* **Test plans that use `run_task_with()` plan function in BoltSpec*
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `run_task_with()` plan function can now be tested
  with BoltSpec.
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
This adds support for testing plans that use the `parallelize()` plan
function in BoltSpec. The block passed to the function is evaluated
using each object sequentially instead of in parallel.

!feature

* **Test plans that use `parallelize()` plan function in BoltSpec**
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `parallelize()` plan function can now be tested
  with BoltSpec.
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
…tions

This adds a test that checks that all public methods on the
`Bolt::Executor` class are defined on the
`BoltSpec::Plans::MockExecutor` class. This is to ensure that if tests
run with BoltSpec invoke any methods on the executor that it will not
result in an "undefined method" error.

!no-release-note
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
This adds support for testing plans that use the `run_task_with()` plan
function to BoltSpec. When BoltSpec runs a plan with this function, it
will execute a separate task run for each target. Users making
assertions about tasks run with `run_task_with()` should make an
assertion about each individual target that the task runs against, or an
assertion about the number of times that the task is run. This includes
an example in the 'Testing plans' documentation that details how to test
these types of plans.

!feature

* **Test plans that use `run_task_with()` plan function in BoltSpec*
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `run_task_with()` plan function can now be tested
  with BoltSpec.
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
This adds support for testing plans that use the `parallelize()` plan
function in BoltSpec. The block passed to the function is evaluated
using each object sequentially instead of in parallel.

!feature

* **Test plans that use `parallelize()` plan function in BoltSpec**
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `parallelize()` plan function can now be tested
  with BoltSpec.
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
…tions

This adds a test that checks that all public methods on the
`Bolt::Executor` class are defined on the
`BoltSpec::Plans::MockExecutor` class. This is to ensure that if tests
run with BoltSpec invoke any methods on the executor that it will not
result in an "undefined method" error.

!no-release-note
beechtom added a commit to beechtom/bolt that referenced this issue Mar 17, 2021
This adds support for testing plans that use the `run_task_with()` plan
function to BoltSpec. When BoltSpec runs a plan with this function, it
will execute a separate task run for each target. Users making
assertions about tasks run with `run_task_with()` should make an
assertion about each individual target that the task runs against, or an
assertion about the number of times that the task is run. This includes
an example in the 'Testing plans' documentation that details how to test
these types of plans.

!feature

* **Test plans that use `run_task_with()` plan function in BoltSpec*
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `run_task_with()` plan function can now be tested
  with BoltSpec.
@beechtom beechtom moved this from ⚡️ Doing to 🚧 Reviewing in Bolt Kanban Mar 18, 2021
beechtom added a commit to beechtom/bolt that referenced this issue Mar 18, 2021
…tions

This adds a test that checks that all public methods on the
`Bolt::Executor` class are defined on the
`BoltSpec::Plans::MockExecutor` class. This is to ensure that if tests
run with BoltSpec invoke any methods on the executor that it will not
result in an "undefined method" error.

!no-release-note
beechtom added a commit to beechtom/bolt that referenced this issue Mar 18, 2021
This adds support for testing plans that use the `run_task_with()` plan
function to BoltSpec. When BoltSpec runs a plan with this function, it
will execute a separate task run for each target. Users making
assertions about tasks run with `run_task_with()` should make an
assertion about each individual target that the task runs against, or an
assertion about the number of times that the task is run. This includes
an example in the 'Testing plans' documentation that details how to test
these types of plans.

!feature

* **Test plans that use `run_task_with()` plan function in BoltSpec*
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `run_task_with()` plan function can now be tested
  with BoltSpec.
lucywyman added a commit that referenced this issue Mar 24, 2021
(GH-2692) Support 'run_task_with' and 'parallelize' in BoltSpec
@lucywyman lucywyman removed this from 🚧 Reviewing in Bolt Kanban Mar 24, 2021
lucywyman pushed a commit to lucywyman/bolt that referenced this issue Mar 26, 2021
…tions

This adds a test that checks that all public methods on the
`Bolt::Executor` class are defined on the
`BoltSpec::Plans::MockExecutor` class. This is to ensure that if tests
run with BoltSpec invoke any methods on the executor that it will not
result in an "undefined method" error.

!no-release-note
lucywyman pushed a commit to lucywyman/bolt that referenced this issue Mar 26, 2021
This adds support for testing plans that use the `run_task_with()` plan
function to BoltSpec. When BoltSpec runs a plan with this function, it
will execute a separate task run for each target. Users making
assertions about tasks run with `run_task_with()` should make an
assertion about each individual target that the task runs against, or an
assertion about the number of times that the task is run. This includes
an example in the 'Testing plans' documentation that details how to test
these types of plans.

!feature

* **Test plans that use `run_task_with()` plan function in BoltSpec*
  ([puppetlabs#2692](puppetlabs#2692))

  Plans that use the `run_task_with()` plan function can now be tested
  with BoltSpec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug reports and fixes.
Projects
None yet
Development

No branches or pull requests

2 participants