From f3cd28ba5345ff0c8a8c19eface048772525776e Mon Sep 17 00:00:00 2001 From: misolt <159779777+misolt@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:59:10 +0200 Subject: [PATCH] Add a basic check for oracle-stats SQLs (#436) --- .../oracle/StatsTaskListGenerator.java | 36 +++++++++-------- .../oracle/StatsTaskListGeneratorTest.java | 40 +++++++++++++++++++ 2 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGeneratorTest.java diff --git a/dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGenerator.java b/dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGenerator.java index 846a8fa90..6f5c82d1d 100644 --- a/dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGenerator.java +++ b/dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGenerator.java @@ -35,28 +35,15 @@ class StatsTaskListGenerator { @Nonnull ImmutableList> createTasks(ConnectorArguments arguments) throws IOException { - ImmutableList queries = - ImmutableList.of( - OracleStatsQuery.create("db-features", NATIVE), - OracleStatsQuery.create("db-instances", NATIVE), - OracleStatsQuery.create("db-objects", NATIVE), - // The version of db-objects that gets SYNONYM objects, for which owner is PUBLIC. - // A JOIN is performed to exclude objects which appear in the cdb_synonyms table. - OracleStatsQuery.create("db-objects-synonym-public", NATIVE), - OracleStatsQuery.create("pdbs-info", NATIVE), - OracleStatsQuery.create("app-schemas-pdbs", NATIVE), - OracleStatsQuery.create("app-schemas-summary", NATIVE), - OracleStatsQuery.create("used-space-details", NATIVE), - OracleStatsQuery.create("hist-cmd-types", STATSPACK) - // TODO: add entries for other SQLs to this list - ); - ImmutableList.Builder> builder = ImmutableList.>builder(); builder.add(new DumpMetadataTask(arguments, scope.formatName())); builder.add(new FormatTask(scope.formatName())); - for (OracleStatsQuery item : queries) { + for (String name : nativeNames()) { + OracleStatsQuery item = OracleStatsQuery.create(name, NATIVE); builder.add(StatsJdbcTask.fromQuery(item)); } + OracleStatsQuery statspack = OracleStatsQuery.create("hist-cmd-types", STATSPACK); + builder.add(StatsJdbcTask.fromQuery(statspack)); return builder.build(); } @@ -72,4 +59,19 @@ enum StatsSource { this.value = value; } } + + ImmutableList nativeNames() { + // TODO: add entries for other SQLs to this list + return ImmutableList.of( + "db-features", + "db-instances", + "db-objects", + // The version of db-objects that gets SYNONYM objects, for which owner is PUBLIC. + // A JOIN is performed to exclude objects which appear in the cdb_synonyms table. + "db-objects-synonym-public", + "pdbs-info", + "app-schemas-pdbs", + "app-schemas-summary", + "used-space-details"); + } } diff --git a/dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGeneratorTest.java b/dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGeneratorTest.java new file mode 100644 index 000000000..e5e28291e --- /dev/null +++ b/dumper/app/src/test/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGeneratorTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022-2024 Google LLC + * Copyright 2013-2021 CompilerWorks + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.edwmigration.dumper.application.dumper.connector.oracle; + +import static com.google.edwmigration.dumper.application.dumper.connector.oracle.StatsTaskListGenerator.StatsSource.NATIVE; + +import com.google.common.collect.ImmutableList; +import java.io.IOException; +import org.junit.experimental.theories.DataPoints; +import org.junit.experimental.theories.FromDataPoints; +import org.junit.experimental.theories.Theories; +import org.junit.experimental.theories.Theory; +import org.junit.runner.RunWith; + +@RunWith(Theories.class) +public class StatsTaskListGeneratorTest { + + @DataPoints("nativeNames") + public static final ImmutableList nameList = new StatsTaskListGenerator().nativeNames(); + + @Theory + public void nativeNames_allNamedFilesExist(@FromDataPoints("nativeNames") String name) + throws IOException { + OracleStatsQuery.create(name, NATIVE); + } +}