Skip to content

Commit 2d8e0ed

Browse files
committed
Merge remote-tracking branch 'origin/issue/CDM-13' into issue/97
2 parents 23bfc39 + 7f34748 commit 2d8e0ed

File tree

12 files changed

+51
-74
lines changed

12 files changed

+51
-74
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build and test jar with integration tests
2+
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
3+
on: [push]
4+
jobs:
5+
Explore-GitHub-Actions:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v3
9+
- name: Set up JDK 8
10+
uses: actions/setup-java@v3
11+
with:
12+
java-version: '8'
13+
distribution: 'temurin'
14+
cache: maven
15+
- name: Build with Maven
16+
run: mvn -B package --file pom.xml
17+
18+
- name: Test SIT with cdm
19+
working-directory: SIT
20+
run: |
21+
echo "Testing SIT with cdm"
22+
chmod o+rx ./environment.sh
23+
make -f Makefile

SIT/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

2-
all: setup test_smoke env_teardown
2+
all: set_permissions setup test_smoke env_teardown
33

4+
set_permissions:
5+
chmod -R 777 ./*.sh
46
setup: build env_setup
57

68
reset: build env_reset
@@ -13,7 +15,7 @@ test_smoke: reset test_smoke_cmd
1315
test_smoke_cmd:
1416
./test.sh -p smoke
1517

16-
env_setup:
18+
env_setup:
1719
./environment.sh -m setup -j ../target/cassandra-data-migrator*.jar
1820
env_reset:
1921
./environment.sh -m reset -j ../target/cassandra-data-migrator*.jar

SIT/cdm.sh

100644100755
File mode changed.

SIT/common.sh

100644100755
File mode changed.

SIT/environment.sh

100644100755
File mode changed.

SIT/test.sh

100644100755
File mode changed.

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<connector.version>3.2.0</connector.version>
1717
<cassandra.version>3.11.13</cassandra.version>
1818
<junit.version>5.9.1</junit.version>
19-
<mockito.version>2.28.2</mockito.version>
2019
</properties>
2120

2221
<distributionManagement>

src/main/java/datastax/astra/migrate/CopyJobSession.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public void getDataAndInsert(BigInteger min, BigInteger max) {
6767
printCounts(false);
6868
}
6969

70+
// exclusion filter below
7071
if (cqlHelper.hasFilterColumn()) {
7172
String col = (String) cqlHelper.getData(cqlHelper.getFilterColType(), cqlHelper.getFilterColIndex(), originRow);
7273
if (col.trim().equalsIgnoreCase(cqlHelper.getFilterColValue())) {

src/main/java/datastax/astra/migrate/MigrateDataType.java

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ public MigrateDataType(String dataType) {
4040
}
4141
this.typeClass = getType(this.type);
4242

43+
if (this.type >= minType && this.type <= maxType) {
44+
isValid = true;
45+
for (Object o : subTypes) {
46+
if (null == o || Object.class == o) {
47+
isValid = false;
48+
}
49+
}
50+
}
51+
else {
52+
isValid = false;
53+
}
54+
this.typeClass = getType(this.type);
55+
4356
if (this.type >= minType && this.type <= maxType) {
4457
isValid = true;
4558
for (Object o : subTypes) {
@@ -138,64 +151,6 @@ public boolean isValid() {
138151
return isValid;
139152
}
140153

141-
public boolean parse(String s) {
142-
try {
143-
switch (this.type) {
144-
case 0:
145-
return true;
146-
case 1:
147-
Integer.parseInt(s);
148-
return true;
149-
case 2:
150-
Long.parseLong(s);
151-
return true;
152-
case 3:
153-
Double.parseDouble(s);
154-
return true;
155-
case 4:
156-
Instant.parse(s);
157-
return true;
158-
case 9:
159-
UUID.fromString(s);
160-
return true;
161-
case 10:
162-
Boolean.parseBoolean(s);
163-
return true;
164-
case 12:
165-
Float.parseFloat(s);
166-
return true;
167-
case 13:
168-
Byte.parseByte(s);
169-
return true;
170-
case 14:
171-
BigDecimal.valueOf(Double.parseDouble(s));
172-
return true;
173-
case 15:
174-
LocalDate.parse(s);
175-
return true;
176-
case 17:
177-
BigInteger.valueOf(Long.parseLong(s));
178-
return true;
179-
case 18:
180-
LocalTime.parse(s);
181-
return true;
182-
case 19:
183-
Short.parseShort(s);
184-
return true;
185-
case 5: // Map
186-
case 6: // List
187-
case 7: // ByteBuffer
188-
case 8: // Set
189-
case 11: // TupleValue
190-
case 16: // UDT
191-
default:
192-
throw new IllegalArgumentException("MigrateDataType " + this.type + "(" + this.typeClass.getName() + ") cannot currently parse this type");
193-
}
194-
} catch (NumberFormatException e) {
195-
return false;
196-
}
197-
}
198-
199154
@Override
200155
public boolean equals(Object o) {
201156
if (this == o) return true;

src/main/java/datastax/astra/migrate/Util.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,19 @@
1414
public class Util {
1515

1616
public static String getSparkProp(SparkConf sc, String prop) {
17-
if (!sc.contains(prop)) {
18-
return sc.get(prop.replace("origin", "source").replace("target", "destination"));
17+
String retVal = PropertyHelper.getInstance(sc).getAsString(prop);
18+
if (StringUtils.isEmpty(retVal) && (prop.contains("origin") || prop.contains("target"))) {
19+
retVal = PropertyHelper.getInstance(sc).getAsString(prop.replace("origin", "source").replace("target", "destination"));
1920
}
2021
if (!KnownProperties.isKnown(prop)) {
2122
throw new IllegalArgumentException("Unknown property: " + prop + "; this is a bug in the code: the property is not configured in KnownProperties.java");
2223
}
23-
return PropertyHelper.getInstance(sc).getAsString(prop);
24+
return retVal;
2425
}
2526

2627
public static String getSparkPropOr(SparkConf sc, String prop, String defaultVal) {
27-
if (!sc.contains(prop)) {
28-
return sc.get(prop.replace("origin", "source").replace("target", "destination"), defaultVal);
29-
}
3028
String retVal = getSparkProp(sc,prop);
31-
if (null == retVal) {
32-
PropertyHelper.getInstance(sc).setProperty(prop, defaultVal);
33-
return getSparkProp(sc,prop);
34-
}
35-
return retVal;
29+
return StringUtils.isEmpty(retVal) ? defaultVal : retVal;
3630
}
3731

3832
public static String getSparkPropOrEmpty(SparkConf sc, String prop) {

0 commit comments

Comments
 (0)