Skip to content

Commit dfe6ad7

Browse files
authored
feat: update the limits of plugins (#2153)
1 parent eb0ec16 commit dfe6ad7

File tree

5 files changed

+84
-34
lines changed

5 files changed

+84
-34
lines changed

controlplane/src/bin/billing.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
{
2929
"id": "field-pruning-grace-period",
3030
"limit": 0
31+
},
32+
{
33+
"id": "plugins",
34+
"description": "3 Plugins",
35+
"limit": 3
3136
}
3237
]
3338
},
@@ -72,8 +77,8 @@
7277
},
7378
{
7479
"id": "plugins",
75-
"description": "3 Plugins",
76-
"limit": 3
80+
"description": "10 Plugins",
81+
"limit": 10
7782
}
7883
]
7984
},
@@ -124,8 +129,8 @@
124129
},
125130
{
126131
"id": "plugins",
127-
"description": "15 Plugins",
128-
"limit": 15
132+
"description": "20 Plugins",
133+
"limit": 20
129134
}
130135
]
131136
},
@@ -173,7 +178,7 @@
173178
{
174179
"id": "plugins",
175180
"description": "Unlimited Plugins",
176-
"limit": 20
181+
"limit": 30
177182
}
178183
]
179184
}

controlplane/test/feature-subgraph/create-feature-subgraph.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ describe('Create feature subgraph tests', () => {
418418
test('that creating a feature subgraph from a plugin base fails when plugin limit is reached', async () => {
419419
const { client, server } = await SetupTest({
420420
dbname,
421-
setupBilling: { plan: 'launch@1' }, // Launch plan allows max 3 plugins
421+
setupBilling: { plan: 'developer@1' }, // Developer plan allows max 3 plugins
422422
});
423423

424424
const basePluginName = genID('basePlugin');

controlplane/test/plugin/validate-and-fetch-plugin-data.test.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,28 @@ describe('ValidateAndFetchPluginData', () => {
137137
setupBilling: { plan: 'developer@1' }, // Developer plan has 0 plugin limit
138138
});
139139

140-
const pluginName = genID('plugin');
141-
const label = genUniqueLabel('test');
140+
// Create 3 plugins successfully
141+
for (let i = 1; i <= 3; i++) {
142+
const pluginName = genID(`plugin-${i}`);
143+
const pluginLabel = genUniqueLabel(`team-${i}`);
144+
145+
const createPluginSubgraphResp = await client.createFederatedSubgraph({
146+
name: pluginName,
147+
namespace: DEFAULT_NAMESPACE,
148+
type: SubgraphType.GRPC_PLUGIN,
149+
labels: [pluginLabel],
150+
});
151+
152+
expect(createPluginSubgraphResp.response?.code).toBe(EnumStatusCode.OK);
153+
}
154+
155+
const fourthPluginName = genID('plugin-4');
156+
const fourthPluginLabel = genUniqueLabel('team-4');
142157

143158
const response = await client.validateAndFetchPluginData({
144-
name: pluginName,
159+
name: fourthPluginName,
145160
namespace: DEFAULT_NAMESPACE,
146-
labels: [label],
161+
labels: [fourthPluginLabel],
147162
});
148163

149164
expect(response.response?.code).toBe(EnumStatusCode.ERR_LIMIT_REACHED);

controlplane/test/subgraph/create-subgraph.test.ts

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -575,30 +575,45 @@ describe('Create subgraph tests', () => {
575575
setupBilling: { plan: 'developer@1' },
576576
});
577577

578-
const pluginName = genID('plugin');
579-
const pluginLabel = genUniqueLabel('env');
578+
// Create 3 plugins successfully
579+
for (let i = 1; i <= 3; i++) {
580+
const pluginName = genID(`plugin-${i}`);
581+
const pluginLabel = genUniqueLabel(`team-${i}`);
580582

581-
const createPluginSubgraphResp = await client.createFederatedSubgraph({
582-
name: pluginName,
583+
const createPluginSubgraphResp = await client.createFederatedSubgraph({
584+
name: pluginName,
585+
namespace: DEFAULT_NAMESPACE,
586+
type: SubgraphType.GRPC_PLUGIN,
587+
labels: [pluginLabel],
588+
});
589+
590+
expect(createPluginSubgraphResp.response?.code).toBe(EnumStatusCode.OK);
591+
}
592+
593+
const fourthPluginName = genID('plugin-4');
594+
const fourthPluginLabel = genUniqueLabel('team-4');
595+
596+
const createFourthPluginResponse = await client.createFederatedSubgraph({
597+
name: fourthPluginName,
583598
namespace: DEFAULT_NAMESPACE,
584599
type: SubgraphType.GRPC_PLUGIN,
585-
labels: [pluginLabel],
600+
labels: [fourthPluginLabel],
586601
});
587602

588-
expect(createPluginSubgraphResp.response?.code).toBe(EnumStatusCode.ERR_LIMIT_REACHED);
589-
expect(createPluginSubgraphResp.response?.details).toBe('The organization reached the limit of plugins');
603+
expect(createFourthPluginResponse.response?.code).toBe(EnumStatusCode.ERR_LIMIT_REACHED);
604+
expect(createFourthPluginResponse.response?.details).toBe('The organization reached the limit of plugins');
590605

591606
await server.close();
592607
});
593608

594-
test('Should enforce plugin limit on launch plan (max 3 plugins)', async () => {
609+
test('Should enforce plugin limit on launch plan (max 10 plugins)', async () => {
595610
const { client, server } = await SetupTest({
596611
dbname,
597612
setupBilling: { plan: 'launch@1' },
598613
});
599614

600-
// Create 3 plugins successfully
601-
for (let i = 1; i <= 3; i++) {
615+
// Create 10 plugins successfully
616+
for (let i = 1; i <= 10; i++) {
602617
const pluginName = genID(`plugin-${i}`);
603618
const pluginLabel = genUniqueLabel(`team-${i}`);
604619

@@ -612,19 +627,19 @@ describe('Create subgraph tests', () => {
612627
expect(createPluginSubgraphResp.response?.code).toBe(EnumStatusCode.OK);
613628
}
614629

615-
// The 4th plugin should fail due to limit
616-
const fourthPluginName = genID('plugin-4');
617-
const fourthPluginLabel = genUniqueLabel('team-4');
630+
// The 11th plugin should fail due to limit
631+
const eleventhPluginName = genID('plugin-11');
632+
const eleventhPluginLabel = genUniqueLabel('team-11');
618633

619-
const createFourthPluginResp = await client.createFederatedSubgraph({
620-
name: fourthPluginName,
634+
const createEleventhPluginResp = await client.createFederatedSubgraph({
635+
name: eleventhPluginName,
621636
namespace: DEFAULT_NAMESPACE,
622637
type: SubgraphType.GRPC_PLUGIN,
623-
labels: [fourthPluginLabel],
638+
labels: [eleventhPluginLabel],
624639
});
625640

626-
expect(createFourthPluginResp.response?.code).toBe(EnumStatusCode.ERR_LIMIT_REACHED);
627-
expect(createFourthPluginResp.response?.details).toBe('The organization reached the limit of plugins');
641+
expect(createEleventhPluginResp.response?.code).toBe(EnumStatusCode.ERR_LIMIT_REACHED);
642+
expect(createEleventhPluginResp.response?.details).toBe('The organization reached the limit of plugins');
628643

629644
await server.close();
630645
});
@@ -798,8 +813,8 @@ describe('Create subgraph tests', () => {
798813
setupBilling: { plan: 'launch@1' },
799814
});
800815

801-
// First, create the maximum number of plugins (3 for launch plan)
802-
for (let i = 1; i <= 3; i++) {
816+
// First, create the maximum number of plugins (10 for launch plan)
817+
for (let i = 1; i <= 10; i++) {
803818
const pluginName = genID(`plugin-${i}`);
804819
const pluginLabel = genUniqueLabel(`plugin-${i}`);
805820

controlplane/test/subgraph/publish-subgraph.test.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
genID,
1313
genUniqueLabel,
1414
} from '../../src/core/test-util.js';
15-
import { createEventDrivenGraph, createSubgraph, eventDrivenGraphSDL, SetupTest, subgraphSDL } from '../test-util.js';
15+
import { createEventDrivenGraph, createSubgraph, DEFAULT_NAMESPACE, eventDrivenGraphSDL, SetupTest, subgraphSDL } from '../test-util.js';
1616

1717
// Read the actual proto, mapping and lock files
1818
const testDataPath = path.join(process.cwd(), 'test/test-data/plugin');
@@ -476,14 +476,29 @@ describe('Publish subgraph tests', () => {
476476
test('Should enforce plugin limits when creating plugin via publish', async () => {
477477
const { client, server } = await SetupTest({
478478
dbname,
479-
setupBilling: { plan: 'developer@1' }, // Developer plan has 0 plugin limit
479+
setupBilling: { plan: 'developer@1' }, // Developer plan has 3 plugin limit
480480
});
481481

482-
const pluginName = genID('plugin');
482+
// Create 3 plugins successfully
483+
for (let i = 1; i <= 3; i++) {
484+
const pluginName = genID(`plugin-${i}`);
485+
const pluginLabel = genUniqueLabel(`team-${i}`);
486+
487+
const createPluginSubgraphResp = await client.createFederatedSubgraph({
488+
name: pluginName,
489+
namespace: DEFAULT_NAMESPACE,
490+
type: SubgraphType.GRPC_PLUGIN,
491+
labels: [pluginLabel],
492+
});
493+
494+
expect(createPluginSubgraphResp.response?.code).toBe(EnumStatusCode.OK);
495+
}
496+
497+
const fourthPluginName = genID('plugin-4');
483498

484499
// Try to publish to a non-existent plugin subgraph on developer plan
485500
const publishResponse = await client.publishFederatedSubgraph({
486-
name: pluginName,
501+
name: fourthPluginName,
487502
namespace: 'default',
488503
schema: pluginSDL,
489504
type: SubgraphType.GRPC_PLUGIN,

0 commit comments

Comments
 (0)