From c1441b7d2f2faf70ccff34331ab0c1dd3eb27d94 Mon Sep 17 00:00:00 2001 From: Mitsunori Komatsu Date: Fri, 13 Jun 2025 15:11:28 +0900 Subject: [PATCH 1/2] Add old method signatures of `SchemaLoader`'s `load()`, `unload()` and `repairAll()` for backward compatibility (#2760) --- .../scalar/db/schemaloader/SchemaLoader.java | 211 ++++++ .../db/schemaloader/SchemaLoaderTest.java | 608 ++++++++++++++++++ 2 files changed, 819 insertions(+) diff --git a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java index 3347d0b959..c58c470681 100644 --- a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java +++ b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java @@ -440,6 +440,217 @@ private static void repairTables( } } + /** + * Creates tables defined in the schema file. See {@link #load(Properties, Path, Map, boolean, + * boolean)} for details. + * + * @param configProperties ScalarDB config properties. + * @param schemaFilePath path to schema file. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Properties configProperties, + @Nullable Path schemaFilePath, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configProperties, schemaFilePath, options, createCoordinatorTables, false); + } + + /** + * Creates tables defined in the schema file. See {@link #load(Path, Path, Map, boolean, boolean)} + * for details. + * + * @param configFilePath path to ScalarDB config file. + * @param schemaFilePath path to schema file. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Path configFilePath, + @Nullable Path schemaFilePath, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configFilePath, schemaFilePath, options, createCoordinatorTables, false); + } + + /** + * Creates tables defined in the schema. See {@link #load(Properties, String, Map, boolean, + * boolean)} for details. + * + * @param configProperties ScalarDB config properties. + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Properties configProperties, + @Nullable String serializedSchemaJson, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configProperties, serializedSchemaJson, options, createCoordinatorTables, false); + } + + /** + * Creates tables defined in the schema. See {@link #load(Path, String, Map, boolean, boolean)} + * for details. + * + * @param configFilePath path to ScalarDB config file. + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Path configFilePath, + @Nullable String serializedSchemaJson, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configFilePath, serializedSchemaJson, options, createCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema file. See {@link #unload(Properties, Path, boolean, + * boolean)} for details. + * + * @param configProperties ScalarDB config properties. + * @param schemaFilePath path to schema file. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Properties configProperties, @Nullable Path schemaFilePath, boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configProperties, schemaFilePath, deleteCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema file. See {@link #unload(Path, Path, boolean, boolean)} for + * details. + * + * @param configFilePath path to ScalarDB config file. + * @param schemaFilePath path to schema file. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Path configFilePath, @Nullable Path schemaFilePath, boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configFilePath, schemaFilePath, deleteCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema. See {@link #unload(Properties, String, boolean, boolean)} + * for details. + * + * @param configProperties ScalarDB config properties. + * @param serializedSchemaJson serialized json string schema. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Properties configProperties, + @Nullable String serializedSchemaJson, + boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configProperties, serializedSchemaJson, deleteCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema. See {@link #unload(Path, String, boolean, boolean)} for + * details. + * + * @param configFilePath path to ScalarDB config file. + * @param serializedSchemaJson serialized json string schema. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Path configFilePath, @Nullable String serializedSchemaJson, boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configFilePath, serializedSchemaJson, deleteCoordinatorTables, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Properties, String, Map, boolean, boolean)} + * for details. + * + * @param configProperties ScalarDB config properties + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Properties configProperties, + String serializedSchemaJson, + Map options, + boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configProperties, serializedSchemaJson, options, repairCoordinatorTable, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Path, String, Map, boolean, boolean)} for + * details. + * + * @param configProperties ScalarDB properties. + * @param schemaPath path to the schema file. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Properties configProperties, + Path schemaPath, + Map options, + boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configProperties, schemaPath, options, repairCoordinatorTable, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Path, String, Map, boolean, boolean)} for + * details. + * + * @param configPath path to the ScalarDB config. + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Path configPath, + String serializedSchemaJson, + Map options, + boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configPath, serializedSchemaJson, options, repairCoordinatorTable, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Path, Path, Map, boolean, boolean)} for + * details. + * + * @param configPath path to the ScalarDB config. + * @param schemaPath path to the schema file. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Path configPath, Path schemaPath, Map options, boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configPath, schemaPath, options, repairCoordinatorTable, false); + } + /** * Alter the tables defined in the schema. Supported alter operations are: * diff --git a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java index 0764d05eed..1a68d70138 100644 --- a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java +++ b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java @@ -911,6 +911,614 @@ public void tearDown() throws Exception { } } + @Test + public void + load_WithConfigFileAndSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (Path) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (Path) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (String) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (String) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (Path) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (Path) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (String) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (String) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + unload_WithConfigFileAndSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, schemaFilePath, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, schemaFilePath, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (Path) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (Path) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, SERIALIZED_SCHEMA_JSON, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, SERIALIZED_SCHEMA_JSON, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (String) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (String) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, schemaFilePath, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, schemaFilePath, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (Path) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (Path) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, SERIALIZED_SCHEMA_JSON, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, SERIALIZED_SCHEMA_JSON, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (String) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (String) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + repairAll_WithConfigFilePathAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigFilePathAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + + @Test + public void + repairAll_WithConfigFilePathAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigFilePathAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + @Test public void alterTables_WithConfigFilePathAndSerializedSchema_ShouldCallParserAndOperatorProperly() From 546e9f76e33b2c0c76e838a95511dd7846538469 Mon Sep 17 00:00:00 2001 From: Mitsunori Komatsu Date: Fri, 13 Jun 2025 15:27:27 +0900 Subject: [PATCH 2/2] Fix compile error --- .../scalar/db/schemaloader/SchemaLoader.java | 30 +++++++------- .../db/schemaloader/SchemaLoaderTest.java | 40 ++++++++----------- 2 files changed, 31 insertions(+), 39 deletions(-) diff --git a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java index c58c470681..7bf815b987 100644 --- a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java +++ b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java @@ -579,8 +579,8 @@ public static void unload( } /** - * Repair namespaces and tables. See {@link #repairAll(Properties, String, Map, boolean, boolean)} - * for details. + * Repair namespaces and tables. See {@link #repairTables(Properties, String, Map, boolean, + * boolean)} for details. * * @param configProperties ScalarDB config properties * @param serializedSchemaJson serialized json string schema. @@ -588,18 +588,18 @@ public static void unload( * @param repairCoordinatorTable repair coordinator tables or not. * @throws SchemaLoaderException thrown when repairing fails. */ - public static void repairAll( + public static void repairTables( Properties configProperties, String serializedSchemaJson, Map options, boolean repairCoordinatorTable) throws SchemaLoaderException { - repairAll(configProperties, serializedSchemaJson, options, repairCoordinatorTable, false); + repairTables(configProperties, serializedSchemaJson, options, repairCoordinatorTable, false); } /** - * Repair namespaces and tables. See {@link #repairAll(Path, String, Map, boolean, boolean)} for - * details. + * Repair namespaces and tables. See {@link #repairTables(Path, String, Map, boolean, boolean)} + * for details. * * @param configProperties ScalarDB properties. * @param schemaPath path to the schema file. @@ -607,18 +607,18 @@ public static void repairAll( * @param repairCoordinatorTable repair coordinator tables or not. * @throws SchemaLoaderException thrown when repairing fails. */ - public static void repairAll( + public static void repairTables( Properties configProperties, Path schemaPath, Map options, boolean repairCoordinatorTable) throws SchemaLoaderException { - repairAll(configProperties, schemaPath, options, repairCoordinatorTable, false); + repairTables(configProperties, schemaPath, options, repairCoordinatorTable, false); } /** - * Repair namespaces and tables. See {@link #repairAll(Path, String, Map, boolean, boolean)} for - * details. + * Repair namespaces and tables. See {@link #repairTables(Path, String, Map, boolean, boolean)} + * for details. * * @param configPath path to the ScalarDB config. * @param serializedSchemaJson serialized json string schema. @@ -626,17 +626,17 @@ public static void repairAll( * @param repairCoordinatorTable repair coordinator tables or not. * @throws SchemaLoaderException thrown when repairing fails. */ - public static void repairAll( + public static void repairTables( Path configPath, String serializedSchemaJson, Map options, boolean repairCoordinatorTable) throws SchemaLoaderException { - repairAll(configPath, serializedSchemaJson, options, repairCoordinatorTable, false); + repairTables(configPath, serializedSchemaJson, options, repairCoordinatorTable, false); } /** - * Repair namespaces and tables. See {@link #repairAll(Path, Path, Map, boolean, boolean)} for + * Repair namespaces and tables. See {@link #repairTables(Path, Path, Map, boolean, boolean)} for * details. * * @param configPath path to the ScalarDB config. @@ -645,10 +645,10 @@ public static void repairAll( * @param repairCoordinatorTable repair coordinator tables or not. * @throws SchemaLoaderException thrown when repairing fails. */ - public static void repairAll( + public static void repairTables( Path configPath, Path schemaPath, Map options, boolean repairCoordinatorTable) throws SchemaLoaderException { - repairAll(configPath, schemaPath, options, repairCoordinatorTable, false); + repairTables(configPath, schemaPath, options, repairCoordinatorTable, false); } /** diff --git a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java index 1a68d70138..54139c5f03 100644 --- a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java +++ b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java @@ -1393,128 +1393,120 @@ public void tearDown() throws Exception { @Test public void - repairAll_WithConfigFilePathAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigFilePathAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configFilePath, SERIALIZED_SCHEMA_JSON, options, true); + SchemaLoader.repairTables(configFilePath, SERIALIZED_SCHEMA_JSON, options, true); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator).repairCoordinatorTables(options); } @Test public void - repairAll_WithConfigFilePathAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigFilePathAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configFilePath, SERIALIZED_SCHEMA_JSON, options, false); + SchemaLoader.repairTables(configFilePath, SERIALIZED_SCHEMA_JSON, options, false); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator, never()).repairCoordinatorTables(anyMap()); } @Test public void - repairAll_WithConfigPropertiesAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigPropertiesAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configProperties, SERIALIZED_SCHEMA_JSON, options, true); + SchemaLoader.repairTables(configProperties, SERIALIZED_SCHEMA_JSON, options, true); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator).repairCoordinatorTables(options); } @Test public void - repairAll_WithConfigPropertiesAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigPropertiesAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configProperties, SERIALIZED_SCHEMA_JSON, options, false); + SchemaLoader.repairTables(configProperties, SERIALIZED_SCHEMA_JSON, options, false); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator, never()).repairCoordinatorTables(anyMap()); } @Test public void - repairAll_WithConfigPropertiesAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigPropertiesAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configProperties, schemaFilePath, options, true); + SchemaLoader.repairTables(configProperties, schemaFilePath, options, true); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator).repairCoordinatorTables(options); } @Test public void - repairAll_WithConfigPropertiesAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigPropertiesAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configProperties, schemaFilePath, options, false); + SchemaLoader.repairTables(configProperties, schemaFilePath, options, false); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator, never()).repairCoordinatorTables(anyMap()); } @Test public void - repairAll_WithConfigFilePathAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigFilePathAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configFilePath, schemaFilePath, options, true); + SchemaLoader.repairTables(configFilePath, schemaFilePath, options, true); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator).repairCoordinatorTables(options); } @Test public void - repairAll_WithConfigFilePathAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + repairTables_WithConfigFilePathAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() throws Exception { // Arrange // Act - SchemaLoader.repairAll(configFilePath, schemaFilePath, options, false); + SchemaLoader.repairTables(configFilePath, schemaFilePath, options, false); // Assert verify(parser).parse(); - verify(operator).repairNamespaces(anyList()); verify(operator).repairTables(anyList()); verify(operator, never()).repairCoordinatorTables(anyMap()); }