NIFI-10592 This closes #6486. fix flaky tests using wrong map impl.

Signed-off-by: Joe Witt <joewitt@apache.org>
This commit is contained in:
Yanni 2022-10-04 00:23:00 -05:00 committed by Joe Witt
parent 209ca78abc
commit bcec883344
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
3 changed files with 13 additions and 11 deletions

View File

@ -26,7 +26,7 @@ import javax.json.JsonObjectBuilder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -64,12 +64,12 @@ public class TestAzureLogAnalyticsProvenanceReportingTask {
final Map<String, Object> config = Collections.emptyMap();
final JsonBuilderFactory factory = Json.createBuilderFactory(config);
final JsonObjectBuilder builder = factory.createObjectBuilder();
Map<String, String> values = new HashMap<String, String>();
Map<String, String> values = new LinkedHashMap<String, String>();
values.put("TestKeyString1", "StringValue1");
values.put("TestKeyString2", "StringValue2");
AzureLogAnalyticsProvenanceReportingTask.addField(builder, factory, "TestKeyString", values, true);
javax.json.JsonObject actualJson = builder.build();
String expectedjsonString = "{\"TestKeyString\":{\"TestKeyString2\":\"StringValue2\",\"TestKeyString1\":\"StringValue1\"}}";
String expectedjsonString = "{\"TestKeyString\":{\"TestKeyString1\":\"StringValue1\",\"TestKeyString2\":\"StringValue2\"}}";
JsonObject expectedJson = new Gson().fromJson(expectedjsonString, JsonObject.class);
assertEquals(expectedJson.toString(), actualJson.toString());
}

View File

@ -53,7 +53,7 @@ import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -80,12 +80,12 @@ public class TestPrometheusRecordSink {
);
RecordSchema recordSchema = new SimpleRecordSchema(recordFields);
Map<String, Object> row1 = new HashMap<>();
Map<String, Object> row1 = new LinkedHashMap<>();
row1.put("field1", 15);
row1.put("field2", BigDecimal.valueOf(12.34567D));
row1.put("field3", "Hello");
Map<String, Object> row2 = new HashMap<>();
Map<String, Object> row2 = new LinkedHashMap<>();
row2.put("field1", 6);
row2.put("field2", BigDecimal.valueOf(0.1234567890123456789D));
row2.put("field3", "World!");
@ -95,7 +95,7 @@ public class TestPrometheusRecordSink {
new MapRecord(recordSchema, row2)
));
Map<String, String> attributes = new HashMap<>();
Map<String, String> attributes = new LinkedHashMap<>();
attributes.put("a", "Hello");
WriteResult writeResult = sink.sendData(recordSet, attributes, true);
assertNotNull(writeResult);
@ -104,8 +104,10 @@ public class TestPrometheusRecordSink {
final String content = getMetrics();
assertTrue(content.contains("field1{field3=\"Hello\",} 15.0\nfield1{field3=\"World!\",} 6.0\n"));
assertTrue(content.contains("field2{field3=\"Hello\",} 12.34567\nfield2{field3=\"World!\",} 0.12345678901234568\n"));
assertTrue(content.contains("field1{field3=\"Hello\",} 15.0\nfield1{field3=\"World!\",} 6.0\n")
|| content.contains("field1{field3=\"World!\",} 6.0\nfield1{field3=\"Hello\",} 15.0\n"));
assertTrue(content.contains("field2{field3=\"Hello\",} 12.34567\nfield2{field3=\"World!\",} 0.12345678901234568\n")
|| content.contains("field2{field3=\"World!\",} 0.12345678901234568\nfield2{field3=\"Hello\",} 12.34567\n"));
try {
sink.onStopped();

View File

@ -36,7 +36,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@ -149,7 +149,7 @@ public class DistributedMapCacheTest {
for (int i = 0; (i < 3); ++i) {
client.put(key + i, value + i, serializer, serializer);
}
final Set<String> keys = new HashSet<>(Arrays.asList("keySubMap0", "keySubMap1", "keySubMap2"));
final Set<String> keys = new LinkedHashSet<>(Arrays.asList("keySubMap0", "keySubMap1", "keySubMap2"));
final Map<String, String> subMap = client.subMap(keys, serializer, deserializer);
assertEquals(3, subMap.size());
for (int i = 0; (i < 3); ++i) {