@red-hat-developer-hub/e2e-test-utils 2.1.5 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deployment/rhdh/deployment.js +9 -9
- package/dist/deployment/rhdh/types.d.ts +6 -2
- package/dist/deployment/rhdh/types.d.ts.map +1 -1
- package/dist/utils/plugin-metadata.d.ts +25 -7
- package/dist/utils/plugin-metadata.d.ts.map +1 -1
- package/dist/utils/plugin-metadata.js +46 -8
- package/dist/utils/tests/plugin-metadata.test.js +64 -8
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import os from "os";
|
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { test, request, expect } from "@playwright/test";
|
|
8
8
|
import { mergeYamlFilesIfExists, deepMerge } from "../../utils/merge-yamls.js";
|
|
9
|
-
import { generatePluginsFromMetadata, processPluginsForDeployment, getNormalizedPluginMergeKey,
|
|
9
|
+
import { generatePluginsFromMetadata, processPluginsForDeployment, getNormalizedPluginMergeKey, disablePlugins, } from "../../utils/plugin-metadata.js";
|
|
10
10
|
import { envsubst } from "../../utils/common.js";
|
|
11
11
|
import { runOnce } from "../../playwright/run-once.js";
|
|
12
12
|
import cloneDeepWith from "lodash.clonedeepwith";
|
|
@@ -127,7 +127,7 @@ export class RHDHDeployment {
|
|
|
127
127
|
async _buildDynamicPluginsConfig() {
|
|
128
128
|
const userConfigPath = this.deploymentConfig.dynamicPlugins;
|
|
129
129
|
const userConfigExists = userConfigPath && fs.existsSync(userConfigPath);
|
|
130
|
-
const
|
|
130
|
+
const disabledPlugins = disablePlugins(this.deploymentConfig.disablePlugins);
|
|
131
131
|
let config;
|
|
132
132
|
if (userConfigExists) {
|
|
133
133
|
this._log(`Using user config: ${userConfigPath}`);
|
|
@@ -140,9 +140,9 @@ export class RHDHDeployment {
|
|
|
140
140
|
}
|
|
141
141
|
// Process for deployment: inject metadata (PR only) + resolve all packages to OCI
|
|
142
142
|
let result = await processPluginsForDeployment(config, WorkspacePaths.metadataDir);
|
|
143
|
-
// Disable
|
|
143
|
+
// Disable default plugins (PR builds only) — covers wrapper + OCI DPDY forms
|
|
144
144
|
if (process.env.GIT_PR_NUMBER) {
|
|
145
|
-
result = deepMerge(result,
|
|
145
|
+
result = deepMerge(result, disabledPlugins, {
|
|
146
146
|
arrayMergeStrategy: "concat",
|
|
147
147
|
});
|
|
148
148
|
}
|
|
@@ -242,7 +242,7 @@ export class RHDHDeployment {
|
|
|
242
242
|
}
|
|
243
243
|
async rolloutRestart() {
|
|
244
244
|
this._log(`Restarting RHDH deployment in namespace ${this.deploymentConfig.namespace}...`);
|
|
245
|
-
await $ `oc rollout restart deployment -l
|
|
245
|
+
await $ `oc rollout restart deployment -l ${this._labelSelector} -n ${this.deploymentConfig.namespace}`;
|
|
246
246
|
this._log(`RHDH deployment restarted successfully in namespace ${this.deploymentConfig.namespace}`);
|
|
247
247
|
await this.waitUntilReady();
|
|
248
248
|
}
|
|
@@ -253,9 +253,9 @@ export class RHDHDeployment {
|
|
|
253
253
|
*/
|
|
254
254
|
async scaleDownAndRestart() {
|
|
255
255
|
const namespace = this.deploymentConfig.namespace;
|
|
256
|
-
await $ `oc scale deployment -l
|
|
257
|
-
await $ `oc wait --for=delete pod -l
|
|
258
|
-
await $ `oc scale deployment -l
|
|
256
|
+
await $ `oc scale deployment -l ${this._labelSelector} --replicas=0 -n ${namespace}`;
|
|
257
|
+
await $ `oc wait --for=delete pod -l ${this._labelSelector} -n ${namespace} --timeout=120s || true`;
|
|
258
|
+
await $ `oc scale deployment -l ${this._labelSelector} --replicas=1 -n ${namespace}`;
|
|
259
259
|
}
|
|
260
260
|
async waitUntilReady(timeout = 500) {
|
|
261
261
|
const namespace = this.deploymentConfig.namespace;
|
|
@@ -361,7 +361,7 @@ export class RHDHDeployment {
|
|
|
361
361
|
appConfig: input.appConfig ?? WorkspacePaths.appConfig,
|
|
362
362
|
secrets: input.secrets ?? WorkspacePaths.secrets,
|
|
363
363
|
dynamicPlugins: input.dynamicPlugins ?? WorkspacePaths.dynamicPlugins,
|
|
364
|
-
|
|
364
|
+
disablePlugins: input.disablePlugins ?? [],
|
|
365
365
|
useNewFrontendSystem,
|
|
366
366
|
};
|
|
367
367
|
if (method === "helm") {
|
|
@@ -10,7 +10,11 @@ export type DeploymentOptions = {
|
|
|
10
10
|
method?: DeploymentMethod;
|
|
11
11
|
valueFile?: string;
|
|
12
12
|
subscription?: string;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Default RHDH plugins to disable during PR builds (wrapper path + OCI
|
|
15
|
+
* `{{inherit}}`). Accepts display names, local paths, or OCI refs.
|
|
16
|
+
*/
|
|
17
|
+
disablePlugins?: string[];
|
|
14
18
|
/** When true, merge new-frontend-system (app-next) layers. When omitted, auto-detect: namespace ends with `-app-next` or `USE_NEW_FRONTEND_SYSTEM=true`. Pass false to disable. */
|
|
15
19
|
useNewFrontendSystem?: boolean;
|
|
16
20
|
};
|
|
@@ -29,7 +33,7 @@ export type DeploymentConfigBase = {
|
|
|
29
33
|
appConfig: string;
|
|
30
34
|
secrets: string;
|
|
31
35
|
dynamicPlugins: string;
|
|
32
|
-
|
|
36
|
+
disablePlugins: string[];
|
|
33
37
|
/** New frontend system (Backstage app-next / NFS shell). */
|
|
34
38
|
useNewFrontendSystem: boolean;
|
|
35
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/deployment/rhdh/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,UAAU,CAAC;AACnD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,SAAS,CAAC,EAAE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nB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,4DAA4D;IAC5D,oBAAoB,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GACjD,CAAC,oBAAoB,GAAG,wBAAwB,CAAC,CAAC"}
|
|
@@ -80,15 +80,33 @@ export declare function getNormalizedPluginMergeKey(entry: {
|
|
|
80
80
|
package?: string;
|
|
81
81
|
}): string;
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* - package: ./dynamic-plugins/dist/$plugin-name
|
|
86
|
-
* - disabled: true
|
|
83
|
+
* Normalizes a disablePlugins entry to a DPDY display name.
|
|
84
|
+
* Accepts bare names, local wrapper paths, or OCI refs.
|
|
87
85
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
86
|
+
* Examples:
|
|
87
|
+
* - red-hat-developer-hub-backstage-plugin-global-header
|
|
88
|
+
* - ./dynamic-plugins/dist/backstage-plugin-kubernetes-dynamic
|
|
89
|
+
* - oci://registry.access.redhat.com/rhdh/backstage-community-plugin-tekton:{{inherit}}
|
|
90
90
|
*/
|
|
91
|
-
export declare function
|
|
91
|
+
export declare function normalizeDisablePluginName(plugin: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Generates dynamic-plugins configuration that disables default RHDH plugins
|
|
94
|
+
* listed in `disablePlugins`. For each
|
|
95
|
+
* normalized plugin name it emits two entries:
|
|
96
|
+
* - local wrapper path: ./dynamic-plugins/dist/$plugin-name (older RHDH)
|
|
97
|
+
* - OCI DPDY path: oci://<registry>/$plugin-name:{{inherit}} (RHDH 1.11+)
|
|
98
|
+
*
|
|
99
|
+
* Both are needed because DPDY moved from wrapper paths to OCI {{inherit}}
|
|
100
|
+
* refs; disabling only the wrapper leaves the OCI default enabled and causes
|
|
101
|
+
* mountPoints / config conflicts with the workspace's PR OCI image.
|
|
102
|
+
*
|
|
103
|
+
* Registry resolution: NIGHTLY_DPDY_OCI_REGISTRY, else
|
|
104
|
+
* registry.access.redhat.com/rhdh.
|
|
105
|
+
*
|
|
106
|
+
* @param plugins plugin names, wrapper paths, and/or OCI refs to disable
|
|
107
|
+
* @returns Dynamic plugins configuration that disables listed plugins
|
|
108
|
+
*/
|
|
109
|
+
export declare function disablePlugins(plugins: string[]): DynamicPluginsConfig;
|
|
92
110
|
/**
|
|
93
111
|
* Auto-generates plugin entries from workspace metadata files.
|
|
94
112
|
* Creates raw entries with local paths and disabled: false.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-metadata.d.ts","sourceRoot":"","sources":["../../src/utils/plugin-metadata.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAgBD,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAID;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAqBtC;AAoBD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,GAAG,CAAC,MAA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;;;;;;GAmBG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,oBAAoB,EAC5B,YAAY,GAAE,MAA8B,EAC5C,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,OAAO,CAAC,oBAAoB,CAAC,CAsC/B"}
|
|
@@ -367,21 +367,59 @@ function injectMetadataConfig(dynamicPluginsConfig, metadataMap) {
|
|
|
367
367
|
}
|
|
368
368
|
// ── Public API ────────────────────────────────────────────────────────────────
|
|
369
369
|
/**
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* - package: ./dynamic-plugins/dist/$plugin-name
|
|
373
|
-
* - disabled: true
|
|
370
|
+
* Normalizes a disablePlugins entry to a DPDY display name.
|
|
371
|
+
* Accepts bare names, local wrapper paths, or OCI refs.
|
|
374
372
|
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
373
|
+
* Examples:
|
|
374
|
+
* - red-hat-developer-hub-backstage-plugin-global-header
|
|
375
|
+
* - ./dynamic-plugins/dist/backstage-plugin-kubernetes-dynamic
|
|
376
|
+
* - oci://registry.access.redhat.com/rhdh/backstage-community-plugin-tekton:{{inherit}}
|
|
377
377
|
*/
|
|
378
|
-
export function
|
|
378
|
+
export function normalizeDisablePluginName(plugin) {
|
|
379
|
+
const trimmed = plugin.trim();
|
|
380
|
+
if (!trimmed)
|
|
381
|
+
return "";
|
|
382
|
+
if (trimmed.startsWith("oci://") ||
|
|
383
|
+
trimmed.startsWith("./") ||
|
|
384
|
+
trimmed.includes("/")) {
|
|
385
|
+
return extractPluginName(trimmed);
|
|
386
|
+
}
|
|
387
|
+
return trimmed.replace(/-dynamic$/, "");
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Generates dynamic-plugins configuration that disables default RHDH plugins
|
|
391
|
+
* listed in `disablePlugins`. For each
|
|
392
|
+
* normalized plugin name it emits two entries:
|
|
393
|
+
* - local wrapper path: ./dynamic-plugins/dist/$plugin-name (older RHDH)
|
|
394
|
+
* - OCI DPDY path: oci://<registry>/$plugin-name:{{inherit}} (RHDH 1.11+)
|
|
395
|
+
*
|
|
396
|
+
* Both are needed because DPDY moved from wrapper paths to OCI {{inherit}}
|
|
397
|
+
* refs; disabling only the wrapper leaves the OCI default enabled and causes
|
|
398
|
+
* mountPoints / config conflicts with the workspace's PR OCI image.
|
|
399
|
+
*
|
|
400
|
+
* Registry resolution: NIGHTLY_DPDY_OCI_REGISTRY, else
|
|
401
|
+
* registry.access.redhat.com/rhdh.
|
|
402
|
+
*
|
|
403
|
+
* @param plugins plugin names, wrapper paths, and/or OCI refs to disable
|
|
404
|
+
* @returns Dynamic plugins configuration that disables listed plugins
|
|
405
|
+
*/
|
|
406
|
+
export function disablePlugins(plugins) {
|
|
379
407
|
const pluginConfig = {
|
|
380
408
|
plugins: [],
|
|
381
409
|
};
|
|
410
|
+
const registry = process.env.NIGHTLY_DPDY_OCI_REGISTRY || DEFAULT_DPDY_OCI_REGISTRY;
|
|
411
|
+
const seen = new Set();
|
|
382
412
|
for (const plugin of plugins) {
|
|
413
|
+
const name = normalizeDisablePluginName(plugin);
|
|
414
|
+
if (!name || seen.has(name))
|
|
415
|
+
continue;
|
|
416
|
+
seen.add(name);
|
|
417
|
+
pluginConfig.plugins.push({
|
|
418
|
+
package: `./dynamic-plugins/dist/${name}`,
|
|
419
|
+
disabled: true,
|
|
420
|
+
});
|
|
383
421
|
pluginConfig.plugins.push({
|
|
384
|
-
package:
|
|
422
|
+
package: `oci://${registry}/${name}:{{inherit}}`,
|
|
385
423
|
disabled: true,
|
|
386
424
|
});
|
|
387
425
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure utility function tests — no env vars, no file system fixtures.
|
|
3
|
-
* Tests: extractPluginName, getNormalizedPluginMergeKey,
|
|
3
|
+
* Tests: extractPluginName, getNormalizedPluginMergeKey, disablePlugins, generatePluginsFromMetadata
|
|
4
4
|
*/
|
|
5
5
|
import { describe, it } from "node:test";
|
|
6
6
|
import assert from "node:assert";
|
|
7
7
|
import fs from "fs-extra";
|
|
8
|
-
import { extractPluginName, getNormalizedPluginMergeKey,
|
|
8
|
+
import { extractPluginName, getNormalizedPluginMergeKey, disablePlugins, normalizeDisablePluginName, generatePluginsFromMetadata, } from "../plugin-metadata.js";
|
|
9
9
|
import { createMetadataFixture } from "./helpers.js";
|
|
10
10
|
// ── extractPluginName ────────────────────────────────────────────────────────
|
|
11
11
|
describe("extractPluginName", () => {
|
|
@@ -58,26 +58,82 @@ describe("getNormalizedPluginMergeKey", () => {
|
|
|
58
58
|
assert.strictEqual(getNormalizedPluginMergeKey({ package: undefined }), "");
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
|
-
// ──
|
|
62
|
-
describe("
|
|
61
|
+
// ── disablePlugins ───────────────────────────────────────────────────────────
|
|
62
|
+
describe("normalizeDisablePluginName", () => {
|
|
63
|
+
it("keeps bare display names and strips -dynamic", () => {
|
|
64
|
+
assert.strictEqual(normalizeDisablePluginName("backstage-plugin-kubernetes"), "backstage-plugin-kubernetes");
|
|
65
|
+
assert.strictEqual(normalizeDisablePluginName("backstage-plugin-kubernetes-backend-dynamic"), "backstage-plugin-kubernetes-backend");
|
|
66
|
+
});
|
|
67
|
+
it("extracts names from wrapper paths and OCI refs", () => {
|
|
68
|
+
assert.strictEqual(normalizeDisablePluginName("./dynamic-plugins/dist/backstage-plugin-kubernetes-dynamic"), "backstage-plugin-kubernetes");
|
|
69
|
+
assert.strictEqual(normalizeDisablePluginName("oci://registry.access.redhat.com/rhdh/red-hat-developer-hub-backstage-plugin-global-header:{{inherit}}"), "red-hat-developer-hub-backstage-plugin-global-header");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe("disablePlugins", () => {
|
|
63
73
|
it("returns empty plugins array for empty input", () => {
|
|
64
|
-
const result =
|
|
74
|
+
const result = disablePlugins([]);
|
|
65
75
|
assert.deepStrictEqual(result, { plugins: [] });
|
|
66
76
|
});
|
|
67
|
-
it("creates disabled
|
|
68
|
-
|
|
77
|
+
it("creates disabled local wrapper and OCI {{inherit}} entries per plugin", () => {
|
|
78
|
+
delete process.env.NIGHTLY_DPDY_OCI_REGISTRY;
|
|
79
|
+
const result = disablePlugins([
|
|
69
80
|
"backstage-community-plugin-tech-radar",
|
|
70
81
|
"backstage-plugin-kubernetes",
|
|
71
82
|
]);
|
|
72
|
-
assert.strictEqual(result.plugins.length,
|
|
83
|
+
assert.strictEqual(result.plugins.length, 4);
|
|
73
84
|
assert.deepStrictEqual(result.plugins[0], {
|
|
74
85
|
package: "./dynamic-plugins/dist/backstage-community-plugin-tech-radar",
|
|
75
86
|
disabled: true,
|
|
76
87
|
});
|
|
77
88
|
assert.deepStrictEqual(result.plugins[1], {
|
|
89
|
+
package: "oci://registry.access.redhat.com/rhdh/backstage-community-plugin-tech-radar:{{inherit}}",
|
|
90
|
+
disabled: true,
|
|
91
|
+
});
|
|
92
|
+
assert.deepStrictEqual(result.plugins[2], {
|
|
93
|
+
package: "./dynamic-plugins/dist/backstage-plugin-kubernetes",
|
|
94
|
+
disabled: true,
|
|
95
|
+
});
|
|
96
|
+
assert.deepStrictEqual(result.plugins[3], {
|
|
97
|
+
package: "oci://registry.access.redhat.com/rhdh/backstage-plugin-kubernetes:{{inherit}}",
|
|
98
|
+
disabled: true,
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
it("normalizes mixed input forms and deduplicates", () => {
|
|
102
|
+
delete process.env.NIGHTLY_DPDY_OCI_REGISTRY;
|
|
103
|
+
const result = disablePlugins([
|
|
104
|
+
"./dynamic-plugins/dist/backstage-plugin-kubernetes-dynamic",
|
|
105
|
+
"backstage-plugin-kubernetes",
|
|
106
|
+
"oci://registry.access.redhat.com/rhdh/backstage-plugin-kubernetes:{{inherit}}",
|
|
107
|
+
]);
|
|
108
|
+
assert.strictEqual(result.plugins.length, 2);
|
|
109
|
+
assert.deepStrictEqual(result.plugins[0], {
|
|
78
110
|
package: "./dynamic-plugins/dist/backstage-plugin-kubernetes",
|
|
79
111
|
disabled: true,
|
|
80
112
|
});
|
|
113
|
+
assert.deepStrictEqual(result.plugins[1], {
|
|
114
|
+
package: "oci://registry.access.redhat.com/rhdh/backstage-plugin-kubernetes:{{inherit}}",
|
|
115
|
+
disabled: true,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
it("uses NIGHTLY_DPDY_OCI_REGISTRY for OCI disable entries when set", () => {
|
|
119
|
+
process.env.NIGHTLY_DPDY_OCI_REGISTRY = "quay.io/rhdh";
|
|
120
|
+
try {
|
|
121
|
+
const result = disablePlugins([
|
|
122
|
+
"red-hat-developer-hub-backstage-plugin-global-header",
|
|
123
|
+
]);
|
|
124
|
+
assert.strictEqual(result.plugins.length, 2);
|
|
125
|
+
assert.deepStrictEqual(result.plugins[0], {
|
|
126
|
+
package: "./dynamic-plugins/dist/red-hat-developer-hub-backstage-plugin-global-header",
|
|
127
|
+
disabled: true,
|
|
128
|
+
});
|
|
129
|
+
assert.deepStrictEqual(result.plugins[1], {
|
|
130
|
+
package: "oci://quay.io/rhdh/red-hat-developer-hub-backstage-plugin-global-header:{{inherit}}",
|
|
131
|
+
disabled: true,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
delete process.env.NIGHTLY_DPDY_OCI_REGISTRY;
|
|
136
|
+
}
|
|
81
137
|
});
|
|
82
138
|
});
|
|
83
139
|
// ── generatePluginsFromMetadata ──────────────────────────────────────────────
|