patch: Add Continued MySQL Support
Expanded packages/backend-common with MySQL Tests Updated packages/backend-tasks column types to conform to MySQL Updated packages/backend-tasks database tests with MySQL Updated packages/backend-tasks datetime column to work with MySQL Updated packages/create-app with a production MySQL App Config template Updated packages/e2e-test to allow for e2e testing with MySQL Updated plugins/app-backend some text columns to string Updated plugins/app-backend interval to work with MySQL Updated plugins/bazaar-backend to run db tests against MySQL Updated plugins/catalog-backend-module-incremental-ingestion to run db tests against MySQL Updated plugins/catalog-backend text columns to longtext to work with MySQL like issue suggested Updated plugins/code-coverage-backend text column to string Updated plugins/linguist-backend text column to string Updated plugins/tech-insights-backend text columns to string Updated plugins/tech-insights-backend db tests to include MySQL Added New E2E tests to run on pull requests to test against MySQL Co-authored-by: Alex Rocha <alexr1@vmware.com> Co-authored-by: David Alvarado <dalvarado@vmware.com> Co-authored-by: Shwetha Gururaj <gururajsh@vmware.com> Co-authored-by: Al <aberezovsky@vmware.com> Co-authored-by: Gerg <gcobb@vmware.com> Signed-off-by: Pete Levine A <lpete@vmware.com> Signed-off-by: lpete@vmware.com <lpete@vmware.com>
This commit is contained in:
committed by
lpete@vmware.com
parent
47782f4bfa
commit
cfc3ca6ce0
@@ -36,6 +36,7 @@
|
||||
"fs-extra": "10.1.0",
|
||||
"handlebars": "^4.7.3",
|
||||
"pgtools": "^1.0.0",
|
||||
"mysql2": "^2.2.5",
|
||||
"puppeteer": "^17.0.0",
|
||||
"tree-kill": "^1.2.2"
|
||||
},
|
||||
|
||||
@@ -31,7 +31,10 @@ import {
|
||||
waitForExit,
|
||||
print,
|
||||
} from '../lib/helpers';
|
||||
|
||||
import mysql from 'mysql2/promise';
|
||||
import pgtools from 'pgtools';
|
||||
|
||||
import { findPaths } from '@backstage/cli-common';
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
@@ -66,11 +69,17 @@ export async function run() {
|
||||
print('Starting the app');
|
||||
await testAppServe(pluginId, appDir);
|
||||
|
||||
if (Boolean(process.env.POSTGRES_USER)) {
|
||||
print('Testing the PostgreSQL backend startup');
|
||||
await preCleanPostgres();
|
||||
if (Boolean(process.env.POSTGRES_USER) || Boolean(process.env.MYSQL_USER)) {
|
||||
print('Testing the datbase backend startup');
|
||||
await preCleanDatabase();
|
||||
const appConfig = path.resolve(appDir, 'app-config.yaml');
|
||||
const productionConfig = path.resolve(appDir, 'app-config.production.yaml');
|
||||
let productionConfig = path.resolve(appDir, 'app-config.production.yaml');
|
||||
if (Boolean(process.env.MYSQL_HOST)) {
|
||||
productionConfig = path.resolve(
|
||||
appDir,
|
||||
'app-config.production.mysql.yaml',
|
||||
);
|
||||
}
|
||||
await testBackendStart(
|
||||
appDir,
|
||||
'--config',
|
||||
@@ -79,7 +88,7 @@ export async function run() {
|
||||
productionConfig,
|
||||
);
|
||||
}
|
||||
print('Testing the SQLite backend startup');
|
||||
print('Testing the Database backend startup');
|
||||
await testBackendStart(appDir);
|
||||
|
||||
if (process.env.CI) {
|
||||
@@ -427,24 +436,42 @@ async function testAppServe(pluginId: string, appDir: string) {
|
||||
}
|
||||
|
||||
/** Drops PG databases */
|
||||
async function dropDB(database: string) {
|
||||
const config = {
|
||||
host: process.env.POSTGRES_HOST,
|
||||
port: process.env.POSTGRES_PORT,
|
||||
user: process.env.POSTGRES_USER,
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
};
|
||||
|
||||
async function dropDB(database: string, client: string) {
|
||||
try {
|
||||
await pgtools.dropdb(config, database);
|
||||
if (client === 'postgres') {
|
||||
const config = {
|
||||
host: process.env.POSTGRES_HOST ? process.env.POSTGRES_HOST : '',
|
||||
port: process.env.POSTGRES_PORT ? process.env.POSTGRES_PORT : '',
|
||||
user: process.env.POSTGRES_USER ? process.env.POSTGRES_USER : '',
|
||||
password: process.env.POSTGRES_PASSWORD
|
||||
? process.env.POSTGRES_PASSWORD
|
||||
: '',
|
||||
};
|
||||
await pgtools.dropdb(config, database);
|
||||
} else if (client === 'mysql') {
|
||||
const connectionString =
|
||||
process.env.BACKSTAGE_TEST_DATABASE_MYSQL8_CONNECTION_STRING ?? '';
|
||||
const connection = await mysql.createConnection(connectionString);
|
||||
await connection.execute('DROP DATABASE ?', [database]);
|
||||
}
|
||||
} catch (_) {
|
||||
/* do nothing*/
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
/** Clean remnants from prior e2e runs */
|
||||
async function preCleanPostgres() {
|
||||
async function preCleanDatabase() {
|
||||
print('Dropping old DBs');
|
||||
if (Boolean(process.env.POSTGRES_HOST)) {
|
||||
await dropClientDatabases('postgres');
|
||||
}
|
||||
if (Boolean(process.env.BACKSTAGE_TEST_DATABASE_MYSQL8_CONNECTION_STRING)) {
|
||||
await dropClientDatabases('mysql');
|
||||
}
|
||||
print('Created DBs');
|
||||
}
|
||||
|
||||
async function dropClientDatabases(client: string) {
|
||||
await Promise.all(
|
||||
[
|
||||
'catalog',
|
||||
@@ -454,9 +481,8 @@ async function preCleanPostgres() {
|
||||
'proxy',
|
||||
'techdocs',
|
||||
'search',
|
||||
].map(name => dropDB(`backstage_plugin_${name}`)),
|
||||
].map(name => dropDB(`backstage_plugin_${name}`, client)),
|
||||
);
|
||||
print('Created DBs');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user