Skip to content

Commit

Permalink
distcp test class
Browse files Browse the repository at this point in the history
  • Loading branch information
dstreev committed May 16, 2022
1 parent 547e13f commit 7f4a36d
Show file tree
Hide file tree
Showing 2 changed files with 233 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>com.cloudera.utils.hadoop</groupId>
<artifactId>hms-mirror</artifactId>
<version>1.5.1.4.5-SNAPSHOT</version>
<version>1.5.1.5-SNAPSHOT</version>
<name>hms-mirror</name>

<url>https://github.com/dstreev/hms_mirror</url>
Expand Down
232 changes: 232 additions & 0 deletions src/test/java/com/cloudera/utils/hadoop/hms/DistcpMigrationTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
/*
* Copyright 2021 Cloudera, Inc. All Rights Reserved.
*
* 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.cloudera.utils.hadoop.hms;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class DistcpMigrationTest extends MirrorTestBase {

@AfterClass
public static void tearDownClass() throws Exception {
dataCleanup(Boolean.FALSE);
}

@Before
public void setUp() throws Exception {
super.setUp();
DataState.getInstance().setConfiguration(CDP_CDP);
if (DataState.getInstance().getPopulate() == null) {
DataState.getInstance().setPopulate(Boolean.FALSE);
}
dataSetup01();
}

@After
public void tearDown() throws Exception {
dataCleanup(Boolean.TRUE);
}

@Test
public void test_so_distcp_leg() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-db", DataState.getInstance().getWorking_db(),
"--distcp",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

@Test
public void test_so_is_distcp_leg() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-db", DataState.getInstance().getWorking_db(),
"-is", "s3a://my_intermediate_bucket",
"--distcp",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

@Test
public void test_so_cs_distcp_leg() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-db", DataState.getInstance().getWorking_db(),
"-cs", "s3a://my_common_bucket",
"--distcp",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

@Test
public void test_acid_sql_da_distcp() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-d", "SQL", "-db", DataState.getInstance().getWorking_db(),
"-mao",
"-da",
"--distcp",
"-ewd", "/warehouse/external",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

@Test
public void test_acid_sql_da_distcp_rdl() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-d", "SQL", "-db", DataState.getInstance().getWorking_db(),
"-mao",
"-da",
"-rdl",
"--distcp",
"-ewd", "/warehouse/external",
"-wd","/warehouse/managed",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

@Test
public void test_acid_sql_da_w_distcp() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-d", "SQL", "-db", DataState.getInstance().getWorking_db(),
"-mao",
"-ewd", "/warehouse/external",
"-da",
"--distcp",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

@Test
public void test_acid_sql_da_w_rdl_distcp() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-d", "SQL", "-db", DataState.getInstance().getWorking_db(),
"-mao",
"-ewd", "/warehouse/external",
"-wd", "/warehouse/managed",
"-da",
"-rdl",
"--distcp",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

@Test
public void test_acid_sql_da_w_rdl_distcp_is() {
String nameofCurrMethod = new Throwable()
.getStackTrace()[0]
.getMethodName();

String outputDir = outputDirBase + nameofCurrMethod;

String[] args = new String[]{"-d", "SQL", "-db", DataState.getInstance().getWorking_db(),
"-mao",
"-ewd", "/warehouse/external",
"-wd", "/warehouse/managed",
"-da",
"-rdl",
"-is", "s3a://my_is_bucket",
"--distcp",
"-o", outputDir, "-cfg", DataState.getInstance().getConfiguration()};
args = toExecute(args, execArgs, Boolean.FALSE);

long rtn = 0;
Mirror mirror = new Mirror();
rtn = mirror.go(args);
int check = 0;
assertTrue("Return Code Failure: " + rtn + " doesn't match: " + check, rtn == check);
}

}

0 comments on commit 7f4a36d

Please sign in to comment.