mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
chore: seed for creating an organization with many members and projects (#7294)
This commit is contained in:
parent
6f4861afb3
commit
02a1f71a13
6 changed files with 61 additions and 5 deletions
|
|
@ -110,10 +110,12 @@ We have a script to feed your local instance of Hive with initial seed data. Thi
|
|||
|
||||
1. Use `Start Hive` to run your local Hive instance
|
||||
2. Make sure `usage` and `usage-ingestor` are running as well (with `pnpm dev`)
|
||||
3. Open Hive app, create a project and a target, then create a token
|
||||
4. Run the seed script: `FEDERATION=<0|1> TOKEN=<access_token> TARGET=<target_id> pnpm seed:schemas`
|
||||
5. This should report a dummy schema
|
||||
6. Run the usage seed to generate some dummy usage data to your local instance of Hive, allowing you
|
||||
3. (Optional) Seed a organization with many projects and users `pnpm seed:org`
|
||||
4. Open Hive app, create a project and a target, then create a token (or use the previously created
|
||||
one)
|
||||
5. Run the seed script: `FEDERATION=<0|1> TOKEN=<access_token> TARGET=<target_id> pnpm seed:schemas`
|
||||
6. This should report a dummy schema
|
||||
7. Run the usage seed to generate some dummy usage data to your local instance of Hive, allowing you
|
||||
to test features e2e: `FEDERATION=<0|1> TOKEN=<access_token> TARGET=<target_id> pnpm seed:usage`
|
||||
|
||||
> Note: You can set `STAGE=<dev|staging|local>` in order to target a specific Hive environment and
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ function applyEnv(env: Record<string, string>) {
|
|||
}
|
||||
}
|
||||
|
||||
const serverEnvVars = parse(readFileSync('../packages/services/server/.env', 'utf-8'));
|
||||
const __dirname = import.meta.dirname;
|
||||
|
||||
const serverEnvVars = parse(readFileSync(__dirname + '/../packages/services/server/.env', 'utf-8'));
|
||||
|
||||
applyEnv({
|
||||
SUPERTOKENS_CONNECTION_URI: serverEnvVars.SUPERTOKENS_CONNECTION_URI,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
"prettier": "prettier --cache --write --list-different --ignore-unknown \"**/*\"",
|
||||
"release": "pnpm build:libraries && changeset publish",
|
||||
"release:version": "changeset version && pnpm --filter hive-apollo-router-plugin --filter hive-console-sdk-rs sync-cargo-file && pnpm build:libraries && pnpm --filter @graphql-hive/cli oclif:readme",
|
||||
"seed:org": "tsx scripts/seed-organization.mts",
|
||||
"seed:schemas": "tsx scripts/seed-schemas.ts",
|
||||
"seed:usage": "tsx scripts/seed-usage.ts",
|
||||
"start": "pnpm run local:setup",
|
||||
|
|
|
|||
|
|
@ -2221,6 +2221,9 @@ importers:
|
|||
'@graphql-hive/core':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/libraries/core/dist
|
||||
'@supercharge/promise-pool':
|
||||
specifier: 3.2.0
|
||||
version: 3.2.0
|
||||
immer:
|
||||
specifier: 10.1.1
|
||||
version: 10.1.1
|
||||
|
|
@ -8318,6 +8321,10 @@ packages:
|
|||
resolution: {integrity: sha512-lkfjyAd34aeMpTKKcEVfy8IUyEsjuAT3t9EXr5yZDtdIUncnZpedl/xLV16Dkd4z+fQwixScsCCDxSMNtBOgpQ==}
|
||||
engines: {node: '>=12.16'}
|
||||
|
||||
'@supercharge/promise-pool@3.2.0':
|
||||
resolution: {integrity: sha512-pj0cAALblTZBPtMltWOlZTQSLT07jIaFNeM8TWoJD1cQMgDB9mcMlVMoetiB35OzNJpqQ2b+QEtwiR9f20mADg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
'@swc/core-darwin-arm64@1.13.5':
|
||||
resolution: {integrity: sha512-lKNv7SujeXvKn16gvQqUQI5DdyY8v7xcoO3k06/FJbHJS90zEwZdQiMNRiqpYw/orU543tPaWgz7cIYWhbopiQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
|
@ -26480,6 +26487,8 @@ snapshots:
|
|||
|
||||
'@stripe/stripe-js@5.5.0': {}
|
||||
|
||||
'@supercharge/promise-pool@3.2.0': {}
|
||||
|
||||
'@swc/core-darwin-arm64@1.13.5':
|
||||
optional: true
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
"devDependencies": {
|
||||
"@faker-js/faker": "9.9.0",
|
||||
"@graphql-hive/core": "workspace:*",
|
||||
"@supercharge/promise-pool": "3.2.0",
|
||||
"immer": "10.1.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
41
scripts/seed-organization.mts
Normal file
41
scripts/seed-organization.mts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* Script for seeding an org with lot of projects and users.
|
||||
*
|
||||
* Requirements:
|
||||
* - Docker Compose is started (pnpm start)
|
||||
* - emails, app and server service is running
|
||||
*
|
||||
* Recommended method of running this :
|
||||
* `bun scripts/seed-organization.mts`
|
||||
*
|
||||
* Afterwards, log in with the printed credentials.
|
||||
*/
|
||||
import { PromisePool } from '@supercharge/promise-pool';
|
||||
|
||||
process.env.RUN_AGAINST_LOCAL_SERVICES = '1';
|
||||
await import('../integration-tests/local-dev.ts');
|
||||
const { initSeed } = await import('../integration-tests/testkit/seed');
|
||||
|
||||
const seed = initSeed();
|
||||
|
||||
const owner = await seed.createOwner();
|
||||
const password = 'ilikebigturtlesandicannotlie47';
|
||||
|
||||
const org = await owner.createOrg();
|
||||
|
||||
console.log('Create 100 projects');
|
||||
await PromisePool.withConcurrency(10)
|
||||
.for(new Array(100).fill(null))
|
||||
.process(() => org.createProject());
|
||||
|
||||
console.log('Create 200 orgainzation members');
|
||||
await PromisePool.withConcurrency(10)
|
||||
.for(new Array(100).fill(null))
|
||||
.process(() => org.inviteAndJoinMember());
|
||||
|
||||
console.log(`
|
||||
Seed User Credentials:
|
||||
|
||||
Email: ${owner.ownerEmail}
|
||||
Password: ${password}
|
||||
`);
|
||||
Loading…
Reference in a new issue