Skip to content

Commit 35543de

Browse files
Deploy CloudSQL instance for performance tests (#3634)
--------- Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
1 parent b60b1dd commit 35543de

File tree

5 files changed

+81
-10
lines changed

5 files changed

+81
-10
lines changed

cluster/pulumi/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export * from './dockerConfig';
2424
export * from './serviceAccount';
2525
export * from './participantKms';
2626
export * from './config/migrationSchema';
27+
export * from './postgres';
2728
export * from './pruning';
2829
export * from './config/loadTesterConfig';
2930
export * from './config/networkWideConfig';

cluster/pulumi/common/src/postgres.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ export class CloudPostgres extends pulumi.ComponentResource implements Postgres
6565
secretName: string,
6666
cloudSqlConfig: CloudSqlConfig,
6767
active: boolean = true,
68-
opts: { disableProtection?: boolean; migrationId?: string; logicalDecoding?: boolean } = {}
68+
opts: {
69+
disableProtection?: boolean;
70+
migrationId?: string;
71+
logicalDecoding?: boolean;
72+
disableBackups?: boolean;
73+
} = {}
6974
) {
7075
const instanceLogicalName = xns.logicalName + '-' + instanceName;
7176
const instanceLogicalNameAlias = xns.logicalName + '-' + alias; // pulumi name before #12391
@@ -93,8 +98,8 @@ export class CloudPostgres extends pulumi.ComponentResource implements Postgres
9398
...(opts.logicalDecoding ? [{ name: 'cloudsql.logical_decoding', value: 'on' }] : []),
9499
],
95100
backupConfiguration: {
96-
enabled: true,
97-
pointInTimeRecoveryEnabled: true,
101+
enabled: !opts.disableBackups,
102+
pointInTimeRecoveryEnabled: !opts.disableBackups,
98103
...(spliceConfig.pulumiProjectConfig.cloudSql.backupsToRetain
99104
? {
100105
backupRetentionSettings: {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
import { CloudPostgres, ExactNamespace } from '@lfdecentralizedtrust/splice-pulumi-common';
4+
5+
export function createCloudSQLInstanceForPerformanceTests(
6+
ghaNamespace: ExactNamespace
7+
): CloudPostgres {
8+
return new CloudPostgres(
9+
ghaNamespace,
10+
'performance-test-db',
11+
'performance-test-db',
12+
'performance-test-db-secret',
13+
{
14+
enabled: true,
15+
maintenanceWindow: { day: 2, hour: 8 },
16+
protected: false,
17+
tier: 'db-custom-2-7680', // same as devnet & testnet as of Jan 2026
18+
enterprisePlus: false,
19+
},
20+
true,
21+
{
22+
disableProtection: true,
23+
disableBackups: true,
24+
logicalDecoding: false,
25+
}
26+
);
27+
}

cluster/pulumi/gha/src/runners.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ jest.mock('./config', () => ({
1515
runnerHookVersion: '1.1',
1616
},
1717
}));
18+
class FakeCloudPostgres extends pulumi.Resource {}
1819
jest.mock('@lfdecentralizedtrust/splice-pulumi-common', () => ({
1920
__esModule: true,
2021
appsAffinityAndTolerations: {},
2122
DOCKER_REPO: 'https://dummy-docker-repo.com',
2223
HELM_MAX_HISTORY_SIZE: 42,
2324
imagePullSecretByNamespaceNameForServiceAccount: () => [],
2425
infraAffinityAndTolerations: {},
26+
CloudPostgres: function CloudPostgres() {
27+
return new FakeCloudPostgres('CloudPostgres', 'cloud-postgres', true);
28+
},
2529
}));
2630
jest.mock('@lfdecentralizedtrust/splice-pulumi-common/src/config/envConfig', () => ({
2731
__esModule: true,

cluster/pulumi/gha/src/runners.ts

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import * as k8s from '@pulumi/kubernetes';
44
import {
55
appsAffinityAndTolerations,
6+
CloudPostgres,
67
DOCKER_REPO,
8+
ExactNamespace,
79
HELM_MAX_HISTORY_SIZE,
810
imagePullSecretByNamespaceNameForServiceAccount,
911
infraAffinityAndTolerations,
@@ -18,6 +20,7 @@ import yaml from 'js-yaml';
1820

1921
import { createCachePvc } from './cache';
2022
import { ghaConfig } from './config';
23+
import { createCloudSQLInstanceForPerformanceTests } from './performanceTests';
2124

2225
type ResourcesSpec = {
2326
requests?: {
@@ -403,7 +406,8 @@ function installK8sRunnerScaleSet(
403406
cachePvcName: string,
404407
resources: ResourcesSpec,
405408
serviceAccountName: string,
406-
dependsOn: Resource[]
409+
dependsOn: Resource[],
410+
performanceTestsDb: CloudPostgres
407411
): Release {
408412
const podConfigMapName = `${name}-pod-config`;
409413
// A configMap that will be mounted to runner pods and provide additional pod spec for the workflow pods
@@ -534,6 +538,21 @@ function installK8sRunnerScaleSet(
534538
name: 'ACTIONS_RUNNER_CONTAINER_HOOK_TEMPLATE',
535539
value: '/pod.yaml',
536540
},
541+
{
542+
name: 'PERFORMANCE_TESTS_DB_HOST',
543+
value: performanceTestsDb.address,
544+
},
545+
{
546+
name: 'PERFORMANCE_TESTS_DB_USER',
547+
value: 'cnadmin',
548+
},
549+
{
550+
name: 'PERFORMANCE_TESTS_DB_PASSWORD',
551+
valueFrom: {
552+
key: 'postgresPassword',
553+
name: performanceTestsDb.secretName,
554+
},
555+
},
537556
],
538557
volumeMounts: [
539558
{
@@ -701,9 +720,10 @@ function installK8sRunnerScaleSets(
701720
runnersNamespace: Namespace,
702721
tokenSecret: Secret,
703722
cachePvcName: string,
704-
serviceAccountName: string
723+
serviceAccountName: string,
724+
performanceTestsDb: CloudPostgres
705725
): void {
706-
const dependsOn = [controller, runnersNamespace, tokenSecret];
726+
const dependsOn = [controller, runnersNamespace, tokenSecret, performanceTestsDb];
707727

708728
runnerSpecs
709729
.filter(spec => spec.k8s)
@@ -715,7 +735,8 @@ function installK8sRunnerScaleSets(
715735
cachePvcName,
716736
spec.resources,
717737
serviceAccountName,
718-
dependsOn
738+
dependsOn,
739+
performanceTestsDb
719740
);
720741
});
721742
}
@@ -754,12 +775,17 @@ function installPodMonitor(runnersNamespace: Namespace) {
754775
);
755776
}
756777

778+
const GHA_NAMESPACE_NAME = 'gha-runners';
757779
export function installRunnerScaleSets(controller: k8s.helm.v3.Release): void {
758-
const runnersNamespace = new Namespace('gha-runners', {
780+
const runnersNamespace = new Namespace(GHA_NAMESPACE_NAME, {
759781
metadata: {
760-
name: 'gha-runners',
782+
name: GHA_NAMESPACE_NAME,
761783
},
762784
});
785+
const exactNs: ExactNamespace = {
786+
ns: runnersNamespace,
787+
logicalName: GHA_NAMESPACE_NAME,
788+
};
763789

764790
const tokenSecret = new k8s.core.v1.Secret(
765791
'gh-access-token',
@@ -791,7 +817,15 @@ export function installRunnerScaleSets(controller: k8s.helm.v3.Release): void {
791817
const saName = 'k8s-runners';
792818
installRunnersServiceAccount(runnersNamespace, saName);
793819

820+
const performanceTestsDb = createCloudSQLInstanceForPerformanceTests(exactNs);
794821
installDockerRunnerScaleSets(controller, runnersNamespace, tokenSecret, cachePvc, saName);
795-
installK8sRunnerScaleSets(controller, runnersNamespace, tokenSecret, cachePvcName, saName);
822+
installK8sRunnerScaleSets(
823+
controller,
824+
runnersNamespace,
825+
tokenSecret,
826+
cachePvcName,
827+
saName,
828+
performanceTestsDb
829+
);
796830
installPodMonitor(runnersNamespace);
797831
}

0 commit comments

Comments
 (0)