Skip to content

Commit

Permalink
Merge pull request #52 from keboola/more-logging-ondra
Browse files Browse the repository at this point in the history
More logging
  • Loading branch information
ondrajodas authored Oct 23, 2024
2 parents 6d6bacf + a26ccde commit 0134e97
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@ private function migrateSecrets(): void
}

foreach ($component['configurations'] as $config) {
$this->logger->info(
sprintf(
'%sMigrating configuration "%s" of component "%s"',
$this->dryRun ? '[dry-run] ' : '',
$config['id'],
$component['id'],
),
['secrets'],
);
$response = $this->migrationsClient
->migrateConfiguration(
$this->sourceProjectToken,
Expand Down
34 changes: 32 additions & 2 deletions tests/phpunit/MigrateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,23 +335,38 @@ public function testMigrateSecretsSuccess(): void
$logsHandler->getRecords(),
fn(array $record) => in_array('secrets', $record['context'] ?? [], true)
);
self::assertCount(5, $records);
self::assertCount(8, $records);

$record = array_shift($records);
self::assertSame('Migrating configurations with secrets', $record['message']);
$record = array_shift($records);
self::assertSame('Components "gooddata-writer" is obsolete, skipping migration...', $record['message']);
$record = array_shift($records);
self::assertSame(
'Migrating configuration "101" of component "some-component"',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Configuration with ID \'101\' successfully migrated to stack \'dest-stack\'.',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Migrating configuration "102" of component "some-component"',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Configuration with ID \'102\' successfully migrated to stack \'dest-stack\'.',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Migrating configuration "201" of component "another-component"',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Configuration with ID \'201\' successfully migrated to stack \'dest-stack\'.',
$record['message']
Expand Down Expand Up @@ -540,21 +555,36 @@ public function testMigrateSnowflakeWritersWithSharedWorkspacesSuccess(): void
$logsHandler->getRecords(),
fn(array $record) => in_array('secrets', $record['context'] ?? [], true)
);
self::assertCount(5, $records);
self::assertCount(8, $records);

$record = array_shift($records);
self::assertSame('Migrating configurations with secrets', $record['message']);
$record = array_shift($records);
self::assertSame(
'Migrating configuration "101" of component "keboola.wr-db-snowflake"',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Configuration with ID \'101\' successfully migrated to stack \'dest-stack\'.',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Migrating configuration "102" of component "keboola.wr-db-snowflake"',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Configuration with ID \'102\' successfully migrated to stack \'dest-stack\'.',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Migrating configuration "103" of component "keboola.wr-db-snowflake"',
$record['message']
);
$record = array_shift($records);
self::assertSame(
'Used existing Snowflake workspace \'USER_01\' for configuration with ID \'103\' '
. '(keboola.wr-db-snowflake).',
Expand Down

0 comments on commit 0134e97

Please sign in to comment.