Skip to content

Commit d836eb6

Browse files
authored
Merge pull request #85 from george0st/change
Tune unit tests
2 parents 7002f06 + 49c4a7a commit d836eb6

File tree

9 files changed

+23
-41
lines changed

9 files changed

+23
-41
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ or two other alternative ways:
2626

2727
You can see sample of relevant setting for CQL controllers:
2828
- [Cassandra setting](./nifi/cql-processor/nifi-cql/src/test/test-cassandra.json)
29-
- access with IP addresses
29+
- access with IP addresses (name/password)
3030
- [Scylla setting](./nifi/cql-processor/nifi-cql/src/test/test-scylla.json)
31-
- access with IP address (localhost)
31+
- access with IP address (without name/password)
3232
- [AstraDB setting](./nifi/cql-processor/nifi-cql/src/test/test-astra.json)
33-
- access with security connection bundle (SCB) and token
33+
- access with Security Connection Bundle (SCB) and Token
3434
- NOTE about SCB: see the file with **'.zip'** suffix
3535
- How to get the SCB? Go to the https://astra.datastax.com/...,
3636
Menu Databases/Your database/Region/[Download SCB](./docs/assets/astradb-download-SCB.png)

nifi/cql-processor/docs/todo-list.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ TO-DO list
22
==========
33

44
1. Extend checks for Write/Validate
5-
- check count write and read
65
- generate exception in case of null value for read-validate
76

87

nifi/cql-processor/nifi-cql-processors/src/main/java/org/george0st/processors/cql/PutCQL.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ public class PutCQL extends AbstractProcessor {
8383
.name("Table")
8484
.description("Table and schema name in CQL (expected format '<schema>.<table>').")
8585
.required(true)
86-
//.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
8786
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
8887
.build();
8988

nifi/cql-processor/nifi-cql-processors/src/test/java/org/george0st/processors/cql/PutCQLBase.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected FlowFile runTestWithProperty(TestSetup setup, String content, Property
125125

126126
private FlowFile coreTest(TestSetup setup, String content, boolean validate){
127127
try {
128-
long finish, start, count;
128+
long finish, start, countWrite, countRead;
129129
FlowFile result;
130130
boolean ok;
131131

@@ -136,14 +136,14 @@ private FlowFile coreTest(TestSetup setup, String content, boolean validate){
136136
finish = System.currentTimeMillis();
137137

138138
if (ok) {
139-
count = Long.parseLong(result.getAttribute(PutCQL.ATTRIBUTE_COUNT));
139+
countWrite = Long.parseLong(result.getAttribute(PutCQL.ATTRIBUTE_COUNT));
140140
System.out.printf("Source: '%s'; WRITE; '%s': %s (%d ms); Items: %d; Perf: %.1f [calls/sec]%s",
141141
result.getAttribute("CQLName"),
142142
"FlowFile",
143143
ReadableValue.fromMillisecond(finish - start),
144144
finish - start,
145-
count,
146-
count / ((finish - start) / 1000.0),
145+
countWrite,
146+
countWrite / ((finish - start) / 1000.0),
147147
System.lineSeparator());
148148

149149
if (validate) {
@@ -153,17 +153,20 @@ private FlowFile coreTest(TestSetup setup, String content, boolean validate){
153153
// validate (read value from CSV and from CQL and compare content)
154154
try (CqlSession session=testService.getSession()) {
155155
start = System.currentTimeMillis();
156-
count = (new CsvCqlValidate(session, setup, CqlTestSchema.primaryKeys)).executeContent(content);
156+
countRead = (new CsvCqlValidate(session, setup, CqlTestSchema.primaryKeys)).executeContent(content);
157157
finish = System.currentTimeMillis();
158158
}
159159
System.out.printf("Source: '%s'; VALIDATE; '%s': %s (%d ms); Items: %d; Perf: %.1f [calls/sec]%s",
160160
result.getAttribute("CQLName"),
161161
"FlowFile",
162162
ReadableValue.fromMillisecond(finish - start),
163163
finish - start,
164-
count,
165-
count / ((finish - start) / 1000.0),
164+
countRead,
165+
countRead / ((finish - start) / 1000.0),
166166
System.lineSeparator());
167+
168+
if (countWrite != countRead)
169+
throw new Exception("The amount of Write and Read operations are different");
167170
}
168171
return result;
169172
}

nifi/cql-processor/nifi-cql-processors/src/test/test-astra.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"consistencyLevel": "LOCAL_QUORUM",
1111

1212
"writeConsistencyLevel": "LOCAL_QUORUM",
13-
"batchSize": 200,
14-
"batchType": "UNLOGGED",
13+
"batchSize": 100,
14+
"batchType": "LOGGED",
1515
"table": "prftest.csv2cql_test3",
1616
"dryRun": false,
1717

nifi/cql-processor/nifi-cql-processors/src/test/test-cassandra.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"consistencyLevel": "LOCAL_ONE",
1212

1313
"writeConsistencyLevel": "LOCAL_ONE",
14-
"batchSize": 200,
15-
"batchType": "UNLOGGED",
14+
"batchSize": 100,
15+
"batchType": "LOGGED",
1616
"table": "prftest.csv2cql_test3",
1717
"dryRun": false,
1818

nifi/cql-processor/nifi-cql-processors/src/test/test-scylla.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"enable": true,
2+
"enable": false,
33
"name": "scylla",
44
"ipAddresses": ["localhost"],
55
"port": 9042,
@@ -9,8 +9,8 @@
99
"consistencyLevel": "LOCAL_ONE",
1010

1111
"writeConsistencyLevel": "LOCAL_ONE",
12-
"batchSize": 200,
13-
"batchType": "UNLOGGED",
12+
"batchSize": 100,
13+
"batchType": "LOGGED",
1414
"table": "prftest.csv2cql_test3",
1515
"dryRun": false,
1616

nifi/cql-processor/nifi-cql-processors/src/test/test-yugabyte.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"consistencyLevel": "LOCAL_ONE",
99

1010
"writeConsistencyLevel": "LOCAL_ONE",
11-
"batchSize": 200,
12-
"batchType": "UNLOGGED",
11+
"batchSize": 100,
12+
"batchType": "LOGGED",
1313
"table": "prftest.csv2cql_test3",
1414
"dryRun": false,
1515

nifi/cql-processor/nifi-cql/src/main/java/org/george0st/cql/CQLControllerService.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ public class CQLControllerService extends AbstractControllerService implements C
5050
"(e.g. '192.168.0.1, 192.168.0.2, ...' or 'localhost').")
5151
.required(false)
5252
//.defaultValue("localhost")
53-
//.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
54-
//.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
5553
.addValidator(Validator.VALID)
5654
.build();
5755

@@ -72,7 +70,6 @@ public class CQLControllerService extends AbstractControllerService implements C
7270
"NOTE: the 'username' is 'clientId' and 'password' id 'secret', these values are from " +
7371
"the file '*-token.json', downloaded from AstraDB web.")
7472
.required(false)
75-
//.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
7673
.addValidator(Validator.VALID)
7774
.build();
7875

@@ -81,19 +78,15 @@ public class CQLControllerService extends AbstractControllerService implements C
8178
.name("Username")
8279
.description("Username for the CQL connection.")
8380
.required(false)
84-
//.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
8581
.addValidator(Validator.VALID)
86-
//.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
8782
.build();
8883

8984
public static final PropertyDescriptor PASSWORD = new PropertyDescriptor
9085
.Builder()
9186
.name("Password")
9287
.description("Password for the CQL connection.")
9388
.required(false)
94-
//.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
9589
.addValidator(Validator.VALID)
96-
//.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
9790
.sensitive(true)
9891
.build();
9992

@@ -102,10 +95,7 @@ public class CQLControllerService extends AbstractControllerService implements C
10295
.name("Local Data Center")
10396
.description("Name of local data center e.g. 'dc1', 'datacenter1', etc.")
10497
.required(false)
105-
//.defaultValue("datacenter1")
106-
//.addValidator(StandardValidators.ATTRIBUTE_KEY_PROPERTY_NAME_VALIDATOR)
10798
.addValidator(Validator.VALID)
108-
//.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
10999
.build();
110100

111101
public static final PropertyDescriptor CONNECTION_TIMEOUT = new PropertyDescriptor
@@ -206,15 +196,7 @@ protected String getURI(final ConfigurationContext context) {
206196
//final String ip = context.getProperty(IP_ADDRESSES).evaluateAttributeExpressions().getValue();
207197
final String ip = context.getProperty(IP_ADDRESSES).getValue();
208198
final String secureConnectionBundl = context.getProperty(SECURE_CONNECTION_BUNDLE).getValue();
209-
210-
// final String port = context.getProperty(PORT).evaluateAttributeExpressions().getValue();
211-
// final String user = context.getProperty(USERNAME).evaluateAttributeExpressions().getValue();
212-
// if (!ip.contains("@") && user != null && passw != null) {
213-
// return uri.replaceFirst("://", "://" + URLEncoder.encode(user, StandardCharsets.UTF_8) + ":" + URLEncoder.encode(passw, StandardCharsets.UTF_8) + "@");
214-
// } else {
215-
// return uri;
216-
// }
217-
return ip != null ? ip: secureConnectionBundl;
199+
return ip != null ? ip : secureConnectionBundl;
218200
}
219201

220202
@Override
@@ -230,5 +212,4 @@ public void shutdown() {
230212
@Override
231213
public CqlSession getSession() { return cqlAccess != null ? cqlAccess.sessionBuilder.build() : null; }
232214

233-
234215
}

0 commit comments

Comments
 (0)