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

Loadtesting E2Es #6956

Merged
merged 29 commits into from May 15, 2024
Merged

Loadtesting E2Es #6956

merged 29 commits into from May 15, 2024

Conversation

enisdenjo
Copy link
Collaborator

@enisdenjo enisdenjo commented May 8, 2024

  • Loadtests are regular tests
    • Loadtest filenames match pattern *.loadtest.ts
  • Loadtests is buildless
  • Loadtests are isolated, but should NOT run concurrently making sure they don't interfere
  • No extra tools, just JavaScript
  • Type-safe
  • Easy to set up
  • Automatic cleanup
  • Any E2E and any GraphQL request can be benchmarked
  • Expected thresholds are coded in tests
  • All loadtest requests must be successful (respond with a 200 OK and not contain any GQL errors)

import os from 'os';
import { createTbench, Tbench, TbenchResult } from '@e2e/tbench';
import { createTenv } from '@e2e/tenv';
const { serve, compose } = createTenv(__dirname);
let tbench: Tbench;
beforeAll(async () => {
tbench = await createTbench(
// to give space for jest and the serve process.
os.availableParallelism() - 2,
);
});
const threshold: TbenchResult = {
maxCpu: Infinity, // we dont care
maxMem: 300, // MB
slowestRequest: 0.5, // seconds
};
it(`should perform within threshold ${JSON.stringify(threshold)}`, async () => {
const { output } = await compose({ output: 'graphql' });
const { maxCpu, maxMem, slowestRequest } = await tbench.serveSustain({
serve: await serve({ fusiongraph: output }),
params: {
query: /* GraphQL */ `
query Albums {
albums(limit: 2) {
albumId
title
artist {
name
}
}
}
`,
},
});
expect(maxCpu).toBeLessThan(threshold.maxCpu);
expect(maxMem).toBeLessThan(threshold.maxMem);
expect(slowestRequest).toBeLessThan(threshold.slowestRequest);
});

TODO

  • Loadtest rest of E2Es

Copy link

codesandbox bot commented May 8, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

github-actions bot commented May 8, 2024

💻 Website Preview

The latest changes are available as preview in: https://8421a2e7.graphql-mesh.pages.dev

@enisdenjo enisdenjo changed the title Benchmarking E2Es Loadtesting E2Es May 8, 2024
Copy link
Contributor

github-actions bot commented May 14, 2024

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-mesh/json-schema 0.100.7-alpha-20240514183156-bf92bd7a55730267c588da9d69b37227c33ae841 npm ↗︎ unpkg ↗︎
@graphql-mesh/openapi 0.100.8-alpha-20240514183156-bf92bd7a55730267c588da9d69b37227c33ae841 npm ↗︎ unpkg ↗︎
@graphql-mesh/raml 0.100.7-alpha-20240514183156-bf92bd7a55730267c588da9d69b37227c33ae841 npm ↗︎ unpkg ↗︎
@omnigraph/json-schema 0.100.7-alpha-20240514183156-bf92bd7a55730267c588da9d69b37227c33ae841 npm ↗︎ unpkg ↗︎
@omnigraph/openapi 0.100.8-alpha-20240514183156-bf92bd7a55730267c588da9d69b37227c33ae841 npm ↗︎ unpkg ↗︎
@omnigraph/raml 0.100.7-alpha-20240514183156-bf92bd7a55730267c588da9d69b37227c33ae841 npm ↗︎ unpkg ↗︎

@enisdenjo enisdenjo merged commit 7ab932a into master May 15, 2024
23 checks passed
@enisdenjo enisdenjo deleted the bench branch May 15, 2024 10:24
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.

None yet

2 participants