Skip to content

Commit f3cd28b

Browse files
authored
Add a basic check for oracle-stats SQLs (#436)
1 parent 4d37f33 commit f3cd28b

File tree

2 files changed

+59
-17
lines changed

2 files changed

+59
-17
lines changed

dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/oracle/StatsTaskListGenerator.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,15 @@ class StatsTaskListGenerator {
3535

3636
@Nonnull
3737
ImmutableList<Task<?>> createTasks(ConnectorArguments arguments) throws IOException {
38-
ImmutableList<OracleStatsQuery> queries =
39-
ImmutableList.of(
40-
OracleStatsQuery.create("db-features", NATIVE),
41-
OracleStatsQuery.create("db-instances", NATIVE),
42-
OracleStatsQuery.create("db-objects", NATIVE),
43-
// The version of db-objects that gets SYNONYM objects, for which owner is PUBLIC.
44-
// A JOIN is performed to exclude objects which appear in the cdb_synonyms table.
45-
OracleStatsQuery.create("db-objects-synonym-public", NATIVE),
46-
OracleStatsQuery.create("pdbs-info", NATIVE),
47-
OracleStatsQuery.create("app-schemas-pdbs", NATIVE),
48-
OracleStatsQuery.create("app-schemas-summary", NATIVE),
49-
OracleStatsQuery.create("used-space-details", NATIVE),
50-
OracleStatsQuery.create("hist-cmd-types", STATSPACK)
51-
// TODO: add entries for other SQLs to this list
52-
);
53-
5438
ImmutableList.Builder<Task<?>> builder = ImmutableList.<Task<?>>builder();
5539
builder.add(new DumpMetadataTask(arguments, scope.formatName()));
5640
builder.add(new FormatTask(scope.formatName()));
57-
for (OracleStatsQuery item : queries) {
41+
for (String name : nativeNames()) {
42+
OracleStatsQuery item = OracleStatsQuery.create(name, NATIVE);
5843
builder.add(StatsJdbcTask.fromQuery(item));
5944
}
45+
OracleStatsQuery statspack = OracleStatsQuery.create("hist-cmd-types", STATSPACK);
46+
builder.add(StatsJdbcTask.fromQuery(statspack));
6047
return builder.build();
6148
}
6249

@@ -72,4 +59,19 @@ enum StatsSource {
7259
this.value = value;
7360
}
7461
}
62+
63+
ImmutableList<String> nativeNames() {
64+
// TODO: add entries for other SQLs to this list
65+
return ImmutableList.of(
66+
"db-features",
67+
"db-instances",
68+
"db-objects",
69+
// The version of db-objects that gets SYNONYM objects, for which owner is PUBLIC.
70+
// A JOIN is performed to exclude objects which appear in the cdb_synonyms table.
71+
"db-objects-synonym-public",
72+
"pdbs-info",
73+
"app-schemas-pdbs",
74+
"app-schemas-summary",
75+
"used-space-details");
76+
}
7577
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2022-2024 Google LLC
3+
* Copyright 2013-2021 CompilerWorks
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.google.edwmigration.dumper.application.dumper.connector.oracle;
18+
19+
import static com.google.edwmigration.dumper.application.dumper.connector.oracle.StatsTaskListGenerator.StatsSource.NATIVE;
20+
21+
import com.google.common.collect.ImmutableList;
22+
import java.io.IOException;
23+
import org.junit.experimental.theories.DataPoints;
24+
import org.junit.experimental.theories.FromDataPoints;
25+
import org.junit.experimental.theories.Theories;
26+
import org.junit.experimental.theories.Theory;
27+
import org.junit.runner.RunWith;
28+
29+
@RunWith(Theories.class)
30+
public class StatsTaskListGeneratorTest {
31+
32+
@DataPoints("nativeNames")
33+
public static final ImmutableList<String> nameList = new StatsTaskListGenerator().nativeNames();
34+
35+
@Theory
36+
public void nativeNames_allNamedFilesExist(@FromDataPoints("nativeNames") String name)
37+
throws IOException {
38+
OracleStatsQuery.create(name, NATIVE);
39+
}
40+
}

0 commit comments

Comments
 (0)