Skip to content

Commit

Permalink
Add a basic check for oracle-stats SQLs (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
misolt authored Jun 18, 2024
1 parent 4d37f33 commit f3cd28b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,15 @@ class StatsTaskListGenerator {

@Nonnull
ImmutableList<Task<?>> createTasks(ConnectorArguments arguments) throws IOException {
ImmutableList<OracleStatsQuery> 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<Task<?>> builder = ImmutableList.<Task<?>>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();
}

Expand All @@ -72,4 +59,19 @@ enum StatsSource {
this.value = value;
}
}

ImmutableList<String> 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");
}
}
Original file line number Diff line number Diff line change
@@ -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<String> nameList = new StatsTaskListGenerator().nativeNames();

@Theory
public void nativeNames_allNamedFilesExist(@FromDataPoints("nativeNames") String name)
throws IOException {
OracleStatsQuery.create(name, NATIVE);
}
}

0 comments on commit f3cd28b

Please sign in to comment.