You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/08/21 18:11:13 UTC

(shardingsphere) branch master updated: Add RollbackMigrationE2EIT (#32618)

This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a12544452c7 Add RollbackMigrationE2EIT (#32618)
a12544452c7 is described below

commit a12544452c75bd10e9939855f929ef17c5db38f1
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Aug 22 02:11:07 2024 +0800

    Add RollbackMigrationE2EIT (#32618)
---
 .../migration/general/RollbackMigrationE2EIT.java  | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/RollbackMigrationE2EIT.java b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/RollbackMigrationE2EIT.java
new file mode 100644
index 00000000000..2021aa08266
--- /dev/null
+++ b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/migration/general/RollbackMigrationE2EIT.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.test.e2e.data.pipeline.cases.migration.general;
+
+import org.apache.shardingsphere.data.pipeline.scenario.migration.MigrationJobType;
+import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.test.e2e.data.pipeline.cases.PipelineContainerComposer;
+import org.apache.shardingsphere.test.e2e.data.pipeline.cases.migration.AbstractMigrationE2EIT;
+import org.apache.shardingsphere.test.e2e.data.pipeline.framework.helper.PipelineCaseHelper;
+import org.apache.shardingsphere.test.e2e.data.pipeline.framework.param.PipelineE2ECondition;
+import org.apache.shardingsphere.test.e2e.data.pipeline.framework.param.PipelineE2ESettings;
+import org.apache.shardingsphere.test.e2e.data.pipeline.framework.param.PipelineE2ETestCaseArgumentsProvider;
+import org.apache.shardingsphere.test.e2e.data.pipeline.framework.param.PipelineTestParameter;
+import org.apache.shardingsphere.test.e2e.data.pipeline.util.AutoIncrementKeyGenerateAlgorithm;
+import org.junit.jupiter.api.condition.EnabledIf;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+import java.sql.Connection;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Rollback migration E2E IT.
+ */
+@PipelineE2ESettings(fetchSingle = true, database = @PipelineE2ESettings.PipelineE2EDatabaseSettings(type = "MySQL", scenarioFiles = "env/common/none.xml"))
+class RollbackMigrationE2EIT extends AbstractMigrationE2EIT {
+    
+    @ParameterizedTest(name = "{0}")
+    @EnabledIf("isEnabled")
+    @ArgumentsSource(PipelineE2ETestCaseArgumentsProvider.class)
+    void assertIllegalTimeTypesValueMigrationSuccess(final PipelineTestParameter testParam) throws Exception {
+        try (PipelineContainerComposer containerComposer = new PipelineContainerComposer(testParam, new MigrationJobType())) {
+            String sql = "CREATE TABLE t_order (order_id BIGINT PRIMARY KEY, user_id INT, status VARCHAR(50))";
+            containerComposer.sourceExecuteWithLog(sql);
+            try (Connection connection = containerComposer.getSourceDataSource().getConnection()) {
+                PipelineCaseHelper.batchInsertOrderRecordsWithGeneralColumns(connection, new AutoIncrementKeyGenerateAlgorithm(), "t_order", 10);
+            }
+            addMigrationSourceResource(containerComposer);
+            addMigrationTargetResource(containerComposer);
+            startMigration(containerComposer, "t_order", "t_order");
+            String jobId = listJobId(containerComposer).get(0);
+            containerComposer.proxyExecuteWithLog(String.format("ROLLBACK MIGRATION %s", jobId), 2);
+            assertTrue(listJobId(containerComposer).isEmpty());
+        }
+    }
+    
+    private static boolean isEnabled() {
+        return PipelineE2ECondition.isEnabled(TypedSPILoader.getService(DatabaseType.class, "MySQL"));
+    }
+}