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

refactor: make the Launcher abstraction less opinionated #3273

Merged
merged 4 commits into from
Jul 25, 2024
Merged

Conversation

hassy
Copy link
Member

@hassy hassy commented Jul 18, 2024

Description

After these changes the Launcher class will delegate more of how a test is run down to the actual implementation of the runtime platform (e.g. local, AWS Lambda, AWS ECS or something else).

It will no longer manage workers directly via createWorker(), prepareWorker() etc.

The only concerns handled in Launcher now are to:

  • Initialize a specific platform implementation (e.g. AWS Lambda)
  • Subscribe to events emitted by the platform
    • Worker-level events such as 'stats' or 'phaseCompleted' and aggregate metric reports from multiple workers

These changes make it easier to implement support for new platforms and to move the existing AWS ECS implementation over to use the Launcher abstraction.

Pre-merge checklist

This is for use by the Artillery team. Please leave this in if you're contributing to Artillery.

  • Does this require an update to the docs? No
  • Does this require a changelog entry? No

After these changes the Launcher will delegate more of how a test
is run down to the actual implementation of the runtime platform
(e.g. local, AWS Lambda, AWS Fargate or something else).

It will no longer manage workers directly via createWorker(),
prepareWorker() etc.

The only concerns handled in Launcher now are to:

- Initialize a runtime platform implementation
- Subscribe to events emitted by the platform
  - Worker-level events such as 'stats' or 'phaseCompleted' and
    aggregate metric reports from multiple workers
This was previously done at Launcher level, but
has now been delegated to platform implementation
A worker may encounter an error that does not necessarily require
stopping the execution of a test script, e.g. a local worker may not
be able to load a plugin. The worker can communicate such errors
by setting a "level" property on the workerError message.

This change takes level into account for determining whether the
worker has stopped running or not.

Previous version of this code has a bug, where the stoppedError
state assigned to the worker [1] would get overridden elsewhere
meaning that the condition that determined whether all workers
exited [2] would not evaluate to true as expected. It also had
the same issue of not taking level into account, meaning that
code that handled loading plugins in local worker threads[3] should
have stopped the execution of a test early, but didn't.

1. https://github.com/artilleryio/artillery/blob/1f6e1c6d95d943f1ee6e5ef5b422f8ea70c24b85/packages/artillery/lib/launch-platform.js#L79
2. https://github.com/artilleryio/artillery/blob/1f6e1c6d95d943f1ee6e5ef5b422f8ea70c24b85/packages/artillery/lib/launch-platform.js#L242
3. https://github.com/artilleryio/artillery/blob/1f6e1c6d95d943f1ee6e5ef5b422f8ea70c24b85/packages/artillery/lib/platform/local/worker.js#L160-L167
Increase the duration of the test to make sure that at least one
intermediate report is produced before the workers are terminated
due to OOM. An assertion in an e2e test relies on having at least
one intermediate report produced:

https://github.com/artilleryio/artillery/blob/5a01e3632c4b6959ad94299bd7caf37397331c6b/packages/artillery/test/cloud-e2e/fargate/memory.test.js#L22
@hassy hassy merged commit 43068a4 into main Jul 25, 2024
56 checks passed
@hassy hassy deleted the refactor/launcher branch July 25, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant