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

chore: upgrade integration test-suite to enable performance testing #405

Merged
merged 6 commits into from
Oct 12, 2023

Conversation

Amplifiyer
Copy link
Contributor

@Amplifiyer Amplifiyer commented Oct 11, 2023

upgrade integration test-suite to enable performance testing and testing sandbox process loop

Description of changes:

  1. Extract killing execa process in its own module.
  2. Refactor STDIO Interaction to be more generic PredicatedAction
  3. PredicatedAction is similar to IFTTT, Each predicated action has a predicate that if true, process controller execute the attached action
  4. Move actions logic from ProcessController to PredicatedActionsBuilder
  5. Update testProject in e2e tests to include updates
  6. Add a new test that makes a change to backend code after the first deployment and asserts on the deployment time to be less than a threshold

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Amplifiyer Amplifiyer added the run-e2e Label that will include e2e tests in PR checks workflow label Oct 11, 2023
@changeset-bot
Copy link

changeset-bot bot commented Oct 11, 2023

🦋 Changeset detected

Latest commit: 7706134

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Amplifiyer Amplifiyer changed the title chore: upgrade integration test-suite to enable performance testing a… chore: upgrade integration test-suite to enable performance testing Oct 11, 2023
Comment on lines 3 to 7
/**
* Kills the given process (equivalent of sending CTRL-C)
* @param processInstance an instance of execa child process
*/
export const killExecaProcess = async (processInstance: ExecaChildProcess) => {
Copy link
Member

Choose a reason for hiding this comment

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

this file should be called execa_process_killer or execa_process_terminator.

  1. https://blog.codinghorror.com/i-shall-call-it-somethingmanager/
  2. killing a subject is poor management practice .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment on lines 9 to 13
/**
* Reusable predicates: Wait for sandbox to finish and emit "✨ Total time: xx.xxs"
*/
export const waitForSandboxDeployment = () =>
new PredicatedActionBuilder().waitForLineIncludes('Total time');
Copy link
Member

Choose a reason for hiding this comment

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

This one should also wait for line that synth and deployment was successful. Or perhaps we need a parameter or additional methods to wait for "any deployment" "successful deployment" etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now renamed it to be more specific, more macros can be added later as needed (or this changed when the need arises)

Comment on lines 63 to 73
/**
* Update the last predicated action to update backend code by copying files from
* `from` location to `to` location.
*/
updateBackendCode = (from: string, to: string) => {
this.getLastPredicatedAction().then = {
actionType: ActionType.MAKE_CODE_CHANGES,
action: async () => {
await fs.cp(from, to, {
recursive: true,
});
Copy link
Member

Choose a reason for hiding this comment

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

if this is running cp should this be updateFileContent ? We don't really assert that input is code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Comment on lines +79 to +91
/**
* Update the last predicated action to validate that the deployment time is less than the one specified
*/
ensureDeploymentTimeLessThan = (seconds: number) => {
this.getLastPredicatedAction().then = {
actionType: ActionType.ASSERT_ON_PROCESS_OUTPUT,
action: (strWithDeploymentTime: string) => {
const regex = /^✨ {2}Total time: (\d*.\d*).*$/;
const deploymentTime = strWithDeploymentTime.match(regex);
if (
deploymentTime &&
deploymentTime.length > 1 &&
!isNaN(+deploymentTime[1])
Copy link
Member

Choose a reason for hiding this comment

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

Couple of ideas.

  1. Can we also capture Synth time and other counters emitted by CDK?
  2. Would it make sense to measure perceived latency from outside of process ? This would be likely pipeline deploy only.
  3. Since we have AWS account hooked up. Can we also emit these metrics to cloudwatch to observe trends ? (perhaps only for main branch). The threshold here is going to have some padding to catch big offenders, but we should persist this data somewhere for trend analytics.
  4. Can we split CDK log parsing from calculations? I.e. parseCDKLog() => Some object model => assert and emit metrics?
  5. At some point we're going to have diagnostics/logging in our components. Perhaps we should invest into this earlier. I.e. create some components in platform-core that can capture telemetry and can be configured/injected into sandbox. And use that to get and assert data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Amplifiyer Amplifiyer marked this pull request as ready for review October 12, 2023 15:24
@Amplifiyer Amplifiyer merged commit f9a28a7 into main Oct 12, 2023
20 checks passed
@Amplifiyer Amplifiyer deleted the upgrade-integration-framework2 branch October 12, 2023 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-e2e Label that will include e2e tests in PR checks workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants