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:
Greg Cobb
2023-06-08 15:31:26 -07:00
committed by lpete@vmware.com
parent 47782f4bfa
commit cfc3ca6ce0
30 changed files with 307 additions and 47 deletions
@@ -26,7 +26,7 @@ exports.up = async function up(knex) {
await knex.schema.createTable('backstage_backend_tasks__tasks', table => {
table.comment('Tasks used for scheduling work on multiple workers');
table
.text('id')
.string('id')
.primary()
.notNullable()
.comment('The unique ID of this particular task');
@@ -43,7 +43,7 @@ jest.setTimeout(60_000);
describe('migrations', () => {
const databases = TestDatabases.create({
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3'],
ids: ['POSTGRES_13', 'POSTGRES_9', 'MYSQL_8', 'SQLITE_3'],
});
it.each(databases.eachSupportedId())(
@@ -36,7 +36,7 @@ jest.setTimeout(60_000);
describe('PluginTaskManagerImpl', () => {
const databases = TestDatabases.create({
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3'],
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3', 'MYSQL_8'],
});
beforeAll(async () => {
@@ -42,6 +42,7 @@ describe('PluginTaskSchedulerJanitor', () => {
'POSTGRES_13',
'POSTGRES_9',
'SQLITE_3',
'MYSQL_8',
],
});
@@ -25,7 +25,7 @@ jest.setTimeout(60_000);
describe('TaskScheduler', () => {
const logger = getVoidLogger();
const databases = TestDatabases.create({
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3'],
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3', 'MYSQL_8'],
});
async function createDatabase(
@@ -28,7 +28,7 @@ jest.setTimeout(60_000);
describe('TaskWorker', () => {
const logger = getVoidLogger();
const databases = TestDatabases.create({
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3'],
ids: ['POSTGRES_13', 'POSTGRES_9', 'SQLITE_3', 'MYSQL_8'],
});
beforeEach(() => {
+18 -9
View File
@@ -175,11 +175,15 @@ export class TaskWorker {
const time = new CronTime(settings.cadence)
.sendAt()
.minus({ seconds: 1 }) // immediately, if "* * * * * *"
.toUTC()
.toISO();
startAt = this.knex.client.config.client.includes('sqlite3')
? this.knex.raw('datetime(?)', [time])
: this.knex.raw(`?`, [time]);
.toUTC();
if (this.knex.client.config.client.includes('sqlite3')) {
startAt = this.knex.raw('datetime(?)', [time.toISO()]);
} else if (this.knex.client.config.client.includes('mysql')) {
startAt = this.knex.raw(`?`, [time.toSQL({ includeOffset: false })]);
} else {
startAt = this.knex.raw(`?`, [time.toISO()]);
}
} else {
startAt = this.knex.fn.now();
}
@@ -279,11 +283,16 @@ export class TaskWorker {
let nextRun: Knex.Raw;
if (isCron) {
const time = new CronTime(settings.cadence).sendAt().toUTC().toISO();
const time = new CronTime(settings.cadence).sendAt().toUTC();
this.logger.debug(`task: ${this.taskId} will next occur around ${time}`);
nextRun = this.knex.client.config.client.includes('sqlite3')
? this.knex.raw('datetime(?)', [time])
: this.knex.raw(`?`, [time]);
if (this.knex.client.config.client.includes('sqlite3')) {
nextRun = this.knex.raw('datetime(?)', [time.toISO()]);
} else if (this.knex.client.config.client.includes('mysql')) {
nextRun = this.knex.raw(`?`, [time.toSQL({ includeOffset: false })]);
} else {
nextRun = this.knex.raw(`?`, [time.toISO()]);
}
} else {
const dt = Duration.fromISO(settings.cadence).as('seconds');
this.logger.debug(