summaryrefslogtreecommitdiffstats
path: root/config/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'config/src/test/java/com')
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/BasicTest.java10
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java7
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java223
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java3
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstanceTest.java2
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java2
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigSetSubscriptionTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigSetTest.java2
-rwxr-xr-xconfig/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java2
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java2
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/DefaultConfigTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java39
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/UnicodeTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java1
-rw-r--r--config/src/test/java/com/yahoo/config/subscription/impl/JRTConfigRequesterTest.java23
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java1
-rwxr-xr-xconfig/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java1
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java1
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java1
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java1
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java3
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/ErrorTypeTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/LZ4CompressionTest.java74
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java5
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java4
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/SlimeUtilsTest.java82
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/TimingValuesTest.java24
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java34
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java288
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java57
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java308
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java1
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java2
-rw-r--r--config/src/test/java/com/yahoo/vespa/config/protocol/TraceTest.java2
42 files changed, 369 insertions, 853 deletions
diff --git a/config/src/test/java/com/yahoo/config/subscription/BasicTest.java b/config/src/test/java/com/yahoo/config/subscription/BasicTest.java
index 3b8b7db6487..5b145d40b7f 100644
--- a/config/src/test/java/com/yahoo/config/subscription/BasicTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/BasicTest.java
@@ -1,13 +1,13 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.subscription;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.is;
import com.yahoo.foo.AppConfig;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class BasicTest {
@@ -17,7 +17,8 @@ public class BasicTest {
ConfigHandle<AppConfig> h = s.subscribe(AppConfig.class, "raw:times 0");
s.nextConfig(0);
AppConfig c = h.getConfig();
- assertThat(c.times(), is(0));
+ assertEquals(0, c.times());
+ s.close();
}
@Test
@@ -26,6 +27,7 @@ public class BasicTest {
ConfigHandle<AppConfig> h = s.subscribe(AppConfig.class, "raw:times 2");
s.nextGeneration(0);
AppConfig c = h.getConfig();
- assertThat(c.times(), is(2));
+ assertEquals(2, c.times());
+ s.close();
}
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java b/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java
index d4280c6300f..c8693227920 100644
--- a/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/CfgConfigPayloadBuilderTest.java
@@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author hmusum
* @author Vegard Sjonfjell
- * @since 5.1
*/
public class CfgConfigPayloadBuilderTest {
@@ -135,7 +134,7 @@ public class CfgConfigPayloadBuilderTest {
" 'boolVal': 'true'",
" },",
" {",
- " 'stringVal': 'blue a=\\\'escaped\\\'',",
+ " 'stringVal': 'blue a=\\'escaped\\'',",
" 'boolVal': 'false'",
" }",
" ],",
@@ -182,7 +181,7 @@ public class CfgConfigPayloadBuilderTest {
assertDeserializedConfigEqualsJson("a b=\"escaped\"",
inputJson(
"{",
- " 'a': 'b=\\\'escaped\\\''",
+ " 'a': 'b=\\'escaped\\''",
"}"
)
);
@@ -305,7 +304,7 @@ public class CfgConfigPayloadBuilderTest {
}
private static void assertDeserializedConfigEqualsJson(String serializedConfig, String expectedJson) {
- assertDeserializedConfigEqualsJson(Arrays.asList(serializedConfig), expectedJson);
+ assertDeserializedConfigEqualsJson(List.of(serializedConfig), expectedJson);
}
private static void assertDeserializedConfigEqualsJson(List<String> inputConfig, String expectedJson) {
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java
index 2d0a40bcdc4..49fd25b6476 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstancePayloadTest.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.fail;
/**
* @author gjoranv
- * @since 5.1.6
*/
public class ConfigInstancePayloadTest {
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java
index 8d9b2d96b04..95ffb31fe7d 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializationTest.java
@@ -3,7 +3,6 @@ package com.yahoo.config.subscription;
import com.yahoo.config.ConfigInstance;
import com.yahoo.foo.FunctionTestConfig;
-import com.yahoo.config.codegen.DefLine;
import com.yahoo.vespa.config.ConfigPayload;
import org.junit.Test;
@@ -18,14 +17,6 @@ import static org.junit.Assert.assertThat;
*/
public class ConfigInstanceSerializationTest {
- private DefLine.Type stringType = new DefLine.Type("string");
- private DefLine.Type intType = new DefLine.Type("int");
- private DefLine.Type longType = new DefLine.Type("long");
- private DefLine.Type boolType = new DefLine.Type("bool");
- private DefLine.Type doubleType = new DefLine.Type("double");
- private DefLine.Type fileType = new DefLine.Type("file");
- private DefLine.Type refType = new DefLine.Type("reference");
-
@Test
public void require_symmetrical_serialization_and_deserialization_with_builder() {
FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
@@ -40,218 +31,4 @@ public class ConfigInstanceSerializationTest {
assertThat(ConfigInstance.serialize(config), is(ConfigInstance.serialize(config2)));
}
-/** Looks like everything in the commented block tests unused api's.. remove?
-
- @Test
- public void testSerializeAgainstConfigDefinitionAllowNothing() {
- FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
- InnerCNode def = new InnerCNode("function-test");
- List<String> payload = Validator.serialize(config, def);
- Assert.assertEquals(payload.size(), 0);
- }
-
- @Test
- public void testSerializeAgainstConfigDefinitionAllLeaves() {
- FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
- InnerCNode def = new InnerCNode("function-test");
- def.children().put("bool_val", LeafCNode.newInstance(boolType, def, "bool_val"));
- def.children().put("bool_with_def", LeafCNode.newInstance(boolType, def, "bool_with_def"));
- def.children().put("int_val", LeafCNode.newInstance(intType, def, "int_val"));
- def.children().put("int_with_def", LeafCNode.newInstance(intType, def, "int_with_def"));
- def.children().put("long_val", LeafCNode.newInstance(longType, def, "long_val"));
- def.children().put("long_with_def", LeafCNode.newInstance(longType, def, "long_with_def"));
- def.children().put("double_val", LeafCNode.newInstance(doubleType, def, "double_val"));
- def.children().put("double_with_def", LeafCNode.newInstance(doubleType, def, "double_with_def"));
- def.children().put("string_val", LeafCNode.newInstance(stringType, def, "string_val"));
- def.children().put("stringwithdef", LeafCNode.newInstance(stringType, def, "stringwithdef"));
- def.children().put("enum_val", LeafCNode.newInstance(enumType(new String[]{"FOO", "BAR", "FOOBAR"}), def, "enum_val"));
- def.children().put("enumwithdef", LeafCNode.newInstance(enumType(new String[]{"FOO2", "BAR2", "FOOBAR2"}), def, "enumwithdef", "BAR2"));
- def.children().put("refval", LeafCNode.newInstance(refType, def, "refval"));
- def.children().put("refwithdef", LeafCNode.newInstance(refType, def, "refwithdef"));
- def.children().put("fileVal", LeafCNode.newInstance(fileType, def, "fileVal"));
-
- List<String> payload = Validator.serialize(config, def);
- String plString = payload.toString();
- Assert.assertTrue(plString.matches(".*bool_val false.*"));
- Assert.assertTrue(plString.matches(".*bool_with_def true.*"));
- Assert.assertTrue(plString.matches(".*int_val 5.*"));
- Assert.assertTrue(plString.matches(".*int_with_def -14.*"));
- Assert.assertTrue(plString.matches(".*long_val 12345678901.*"));
- Assert.assertTrue(plString.matches(".*long_with_def -9876543210.*"));
- Assert.assertTrue(plString.matches(".*double_val 41\\.23.*"));
- Assert.assertTrue(plString.matches(".*double_with_def -12.*"));
- Assert.assertTrue(plString.matches(".*string_val \"foo\".*"));
- Assert.assertTrue(plString.matches(".*stringwithdef \"bar and foo\".*"));
- Assert.assertTrue(plString.matches(".*enum_val FOOBAR.*"));
- Assert.assertTrue(plString.matches(".*enumwithdef BAR2.*"));
- Assert.assertTrue(plString.matches(".*refval \\:parent\\:.*"));
- Assert.assertTrue(plString.matches(".*refwithdef \\:parent\\:.*"));
- Assert.assertTrue(plString.matches(".*fileVal \"etc\".*"));
- }
-
- @Test
- public void testSerializeAgainstConfigDefinitionSomeLeaves() {
- FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
- InnerCNode def = new InnerCNode("function-test");
- def.children().put("stringwithdef", LeafCNode.newInstance(stringType, def, "stringwithdef"));
- def.children().put("long_with_def", LeafCNode.newInstance(longType, def, "long_with_def"));
- // But not double_with_def etc, and no structs/arrays
- List<String> payload = Validator.serialize(config, def);
- String plString = payload.toString();
- Assert.assertTrue(plString.matches(".*long_with_def \\-9876543210.*"));
- Assert.assertTrue(plString.matches(".*stringwithdef \"bar and foo\".*"));
- Assert.assertFalse(plString.matches(".*double_with_def.*"));
- Assert.assertFalse(plString.matches(".*fileVal \"etc\".*"));
- Assert.assertFalse(plString.matches(".*basicStruct.*"));
- }
-
- @Test
- public void testSerializationAgainstConfigDefinitionAddedValsInDef() {
- FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
- InnerCNode def = new InnerCNode("function-test");
- def.children().put("stringwithdef", LeafCNode.newInstance(stringType, def, "stringwithdef"));
- def.children().put("someotherstring", LeafCNode.newInstance(stringType, def, "someotherstring", "some other"));
- def.children().put("long_with_def", LeafCNode.newInstance(longType, def, "long_with_def"));
- def.children().put("some_other_long", LeafCNode.newInstance(longType, def, "some_other_long", "88"));
- def.children().put("some_other_enum", LeafCNode.newInstance(enumType(new String[]{"hey", "ho", "lets", "go"}), def, "some_other_enum", "lets"));
- def.children().put("int_val_nofdef", LeafCNode.newInstance(intType, def, "int_val_nodef", null));
-
- // But not double_with_def etc, and no structs/arrays
- List<String> payload = Validator.serialize(config, def);
- String plString = payload.toString();
- Assert.assertTrue(plString.matches(".*long_with_def \\-9876543210.*"));
- Assert.assertTrue(plString.matches(".*stringwithdef \"bar and foo\".*"));
- Assert.assertTrue(plString.matches(".*.someotherstring \"some other\".*"));
- Assert.assertTrue(plString.matches(".*some_other_long 88.*"));
- Assert.assertTrue(plString.matches(".*some_other_enum lets.*"));
- Assert.assertFalse(plString.matches(".*double_with_def.*"));
- Assert.assertFalse(plString.matches(".*fileVal \"etc\".*"));
- Assert.assertFalse(plString.matches(".*basicStruct.*"));
- Assert.assertFalse(plString.matches(".*int_val_nodef.*"));
- }
-
- @Test
- public void testSerializeAgainstConfigDefinitionMismatchAllWays() {
- FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
-
- // Create all sorts of mismatches in the def schema used to serialize
- InnerCNode def = new InnerCNode("function-test");
- def.children().put("long_with_def", LeafCNode.newInstance(longType, def, "long_with_def"));
- def.children().put("stringwithdef", LeafCNode.newInstance(intType, def, "stringwithdef"));
- def.children().put("basicStruct", LeafCNode.newInstance(intType, def, "basicStruct"));
- InnerCNode doubleValWrong = new InnerCNode("double_val");
- doubleValWrong.children().put("foo", LeafCNode.newInstance(intType, def, "foo"));
- def.children().put("double_val", doubleValWrong);
- InnerCNode myArray = new InnerCNode("myarray");
- myArray.children().put("intval", LeafCNode.newInstance(stringType, myArray, "foo"));
- InnerCNode myStruct = new InnerCNode("myStruct");
- myStruct.children().put("a", LeafCNode.newInstance(stringType, myStruct, "foo"));
- myArray.children().put("myStruct", myStruct);
- def.children().put("myarray", myArray);
-
- List<String> payload = Validator.serialize(config, def);
- String plString = payload.toString();
- Assert.assertTrue(plString.matches(".*long_with_def.*"));
- Assert.assertFalse(plString.matches(".*stringwithdef.*"));
- Assert.assertFalse(plString.matches(".*basicStruct.*"));
- Assert.assertFalse(plString.matches(".*double_val.*"));
- Assert.assertFalse(plString.matches(".*intval.*"));
- Assert.assertFalse(plString.matches(".*\\.a.*"));
- }
-
- @Test
- public void testSerializeAgainstConfigDefinitionComplex() {
- FunctionTestConfig config = ConfigInstancePayloadTest.createVariableAccessConfigWithBuilder();
-
- // Build a pretty complex def programatically
- InnerCNode def = new InnerCNode("function-test");
- def.children().put("stringwithdef", LeafCNode.newInstance(stringType, def, "stringwithdef"));
- def.children().put("someUnknownStringNoDefault", LeafCNode.newInstance(stringType, def, "someUnknownStringNoDefault"));
- InnerCNode basicStruct = new InnerCNode("basicStruct");
- basicStruct.children().put("foo", LeafCNode.newInstance(stringType, def, "foo")); // but not bar
- InnerCNode rootStruct = new InnerCNode("rootStruct");
- InnerCNode inner1 = new InnerCNode("inner1");
- InnerCNode someUnknwonStruct = new InnerCNode("someUnknownStruct");
- InnerCNode someUnknownInner = new InnerCNode("someUnknownInner");
- InnerCNode innerArr = new InnerCNode("innerArr");
- rootStruct.children().put("inner1", inner1);
- rootStruct.children().put("someUnknownStruct", someUnknwonStruct);
- rootStruct.children().put("someUnknownInner", someUnknownInner);
- rootStruct.children().put("innerArr", innerArr);
- InnerCNode myarray = new InnerCNode("myarray");
- InnerCNode unknownInner = new InnerCNode("unknownInner");
- def.children().put("basicStruct", basicStruct);
- def.children().put("rootStruct", rootStruct);
- def.children().put("myarray", myarray);
- def.children().put("unknownInner", unknownInner);
- inner1.children().put("index", LeafCNode.newInstance(intType, inner1, "index"));
- inner1.children().put("someUnknownInt", LeafCNode.newInstance(intType, inner1, "someUnknownInt", "-98"));
- inner1.children().put("someUnknownIntNoDefault", LeafCNode.newInstance(intType, inner1, "someUnknownIntNoDefault"));
- inner1.children().put("someUnknownEnum", LeafCNode.newInstance(enumType(new String[]{"goo", "go", "gorilla"}), inner1, "someUnknownEnum", "go"));
- inner1.children().put("someUnknownEnumNoDefault", LeafCNode.newInstance(enumType(new String[]{"foo", "bar", "baz"}), inner1, "someUnknownEnumNoDefault"));
- someUnknwonStruct.children().put("anint", LeafCNode.newInstance(intType, someUnknwonStruct, "anint", "3"));// But no instances of this in config
- someUnknownInner.children().put("along", LeafCNode.newInstance(longType, someUnknownInner, "along", "234"));// No instance in config
- innerArr.children().put("boolVal", LeafCNode.newInstance(boolType, innerArr, "boolVal"));
- innerArr.children().put("someUnknownDouble", LeafCNode.newInstance(doubleType, innerArr, "someUnknownDouble", "-675.789"));
- innerArr.children().put("someUnknownDoubleNoDefault", LeafCNode.newInstance(doubleType, innerArr, "someUnknownDoubleNoDefault"));
- myarray.children().put("fileVal", LeafCNode.newInstance(fileType, myarray, "fileVal"));
- myarray.children().put("stringval", new InnerCNode("stringval[]"));
- // TODO make sure default for file is not allowed
- //myarray.children().put("someUnknownFile", LeafCNode.newInstance(fileType, myarray, "someUnknownFile", "opt/"));
- unknownInner.children().put("aDouble", LeafCNode.newInstance(doubleType, unknownInner, "aDouble", "1234"));
- def.children().put("longarr", new InnerCNode("longarr[]"));
- def.children().put("boolarr", new InnerCNode("boolarr[]"));
- def.children().put("doublearr", new InnerCNode("doublearr[]"));
- def.children().put("stringarr", new InnerCNode("stringarr[]"));
- def.children().put("fileArr", new InnerCNode("fileArr[]"));
- def.children().put("refarr", new InnerCNode("refarr[]"));
- def.children().put("enumarr", new InnerCNode("enumarr[]"));
- List<String> payload = Validator.serialize(config, def);
- String plString = payload.toString();
- Assert.assertFalse(plString.matches(".*long_with_def \\-9876543210.*"));
- Assert.assertFalse(plString.matches(".*someUnknownStringNoDefault.*"));
- Assert.assertTrue(plString.matches(".*stringwithdef \"bar and foo\".*"));
- Assert.assertFalse(plString.matches(".*double_with_def.*"));
- Assert.assertFalse(plString.matches(".*fileVal etc.*"));
- Assert.assertTrue(plString.matches(".*basicStruct\\.foo \"basicFoo\".*"));
- Assert.assertFalse(plString.matches(".*basicStruct\\.bar.*"));
- Assert.assertFalse(plString.matches(".*rootStruct\\.inner0.*"));
- Assert.assertFalse(plString.matches(".*unknownInner.*"));
- Assert.assertFalse(plString.matches(".*rootStruct\\.someUnknownStruct.*"));
- Assert.assertFalse(plString.matches(".*rootStruct\\.someUnknownInner.*"));
- Assert.assertFalse(plString.matches(".*rootStruct\\.inner1\\.name.*"));
- Assert.assertTrue(plString.matches(".*rootStruct\\.inner1\\.index 12.*"));
- Assert.assertTrue(plString.matches(".*rootStruct\\.inner1\\.someUnknownInt -98.*"));
- Assert.assertTrue(plString.matches(".*rootStruct\\.inner1\\.someUnknownEnum go.*"));
- Assert.assertTrue(plString.matches(".*rootStruct\\.innerArr\\[0\\]\\.boolVal true.*"));
- Assert.assertFalse(plString.matches(".*someUnknownEnumNoDefault.*"));
- Assert.assertFalse(plString.matches(".*someUnknownDoubleNoDefault.*"));
- Assert.assertFalse(plString.matches(".*someUnknownIntNoDefault.*"));
- Assert.assertTrue(plString.matches(".*rootStruct\\.innerArr\\[0\\]\\.someUnknownDouble -675.789.*"));
- Assert.assertFalse(plString.matches(".*rootStruct\\.innerArr\\[0\\]\\.stringVal*"));
- Assert.assertFalse(plString.matches(".*myarray\\[0\\].intval.*"));
- Assert.assertTrue(plString.matches(".*myarray\\[0\\].fileVal \"file0\".*"));
- //assertTrue(plString.matches(".*myarray\\[0\\].someUnknownFile \"opt/\".*"));
- Assert.assertTrue(plString.matches(".*myarray\\[0\\].stringval\\[0\\] \"baah\".*"));
- Assert.assertTrue(plString.matches(".*myarray\\[0\\].stringval\\[1\\] \"yikes\".*"));
- Assert.assertTrue(plString.matches(".*myarray\\[1\\].fileVal \"file1\".*"));
- Assert.assertFalse(plString.matches(".*myarray\\[1\\].enumVal.*"));
- Assert.assertFalse(plString.matches(".*myarray\\[1\\].refVal.*"));
- Assert.assertTrue(plString.matches(".*boolarr\\[0\\] false.*"));
- Assert.assertTrue(plString.matches(".*longarr\\[0\\] 9223372036854775807.*"));
- Assert.assertTrue(plString.matches(".*longarr\\[1\\] -9223372036854775808.*"));
- Assert.assertTrue(plString.matches(".*doublearr\\[0\\] 2344\\.0.*"));
- Assert.assertTrue(plString.matches(".*doublearr\\[1\\] 123\\.0.*"));
- Assert.assertTrue(plString.matches(".*stringarr\\[0\\] \"bar\".*"));
- Assert.assertTrue(plString.matches(".*enumarr\\[0\\] VALUES.*"));
- Assert.assertTrue(plString.matches(".*refarr\\[0\\] \\:parent\\:.*"));
- Assert.assertTrue(plString.matches(".*refarr\\[1\\] \\:parent.*"));
- Assert.assertTrue(plString.matches(".*refarr\\[2\\] parent\\:.*"));
- Assert.assertTrue(plString.matches(".*fileArr\\[0\\] \"bin\".*"));
- }
-
- private DefLine.Type enumType(String[] strings) {
- return new DefLine.Type("enum").setEnumArray(strings);
- }
-**/
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java
index ee8682efe3c..7c08d0175a1 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java
@@ -21,9 +21,9 @@ import static org.junit.Assert.fail;
/**
* @author Ulf Lilleengen
* @author Vegard Sjonfjell
- * @since 5.1
*/
public class ConfigInstanceSerializerTest {
+
@Test
public void test_that_leaf_types_are_serialized_to_json_types() {
SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder();
@@ -225,4 +225,5 @@ public class ConfigInstanceSerializerTest {
assertJsonEquals(baos.toString(), expectedJson);
}
+
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceTest.java
index 1da53e4c3b9..4da0c3f51e0 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceTest.java
@@ -12,7 +12,7 @@ import static org.junit.Assert.fail;
/**
* Tests different aspects of the ConfigInstance class and its underlying Nodes.
*
- * @author <a href="gv@yahoo-inc.com">G. Voldengen</a>
+ * @author gjoranv
*/
public class ConfigInstanceTest {
private ConfigSourceSet sourceSet = new ConfigSourceSet("config-instance-test");
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java
index 078be819d33..3bdaee09eaf 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInstanceUtilTest.java
@@ -22,7 +22,6 @@ import static com.yahoo.foo.FunctionTestConfig.*;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ConfigInstanceUtilTest {
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java
index 35f4f14b4f4..a80da63afc9 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigInterruptedExceptionTest.java
@@ -8,9 +8,9 @@ import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ConfigInterruptedExceptionTest {
+
@Test
public void require_that_throwable_is_preserved() {
ConfigInterruptedException e = new ConfigInterruptedException(new RuntimeException("foo"));
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSetSubscriptionTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSetSubscriptionTest.java
index 21cdfbe7d30..db30e7b7389 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigSetSubscriptionTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSetSubscriptionTest.java
@@ -128,6 +128,7 @@ public class ConfigSetSubscriptionTest {
assertEquals(hA0.getConfig().times(), 8800);
assertEquals(hA1.getConfig().times(), 890);
assertEquals(hS.getConfig().stringVal(), "new StringVal");
+ subscriber.close();
}
@Test
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSetTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSetTest.java
index a120f19c17b..48a51bbc02c 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigSetTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSetTest.java
@@ -10,9 +10,9 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ConfigSetTest {
+
@Test
public void testToString() {
ConfigSet set = new ConfigSet();
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java
index 38d4a6a4571..0879c330f45 100755
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSourceSetTest.java
@@ -13,6 +13,7 @@ import static org.junit.Assert.*;
* @author <a href="gv@yahoo-inc.com">G. Voldengen</a>
*/
public class ConfigSourceSetTest {
+
@Test
public void testEquals() {
assertEquals(new ConfigSourceSet(), new ConfigSourceSet());
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java
index 933a9fd130a..c8d4c081fc9 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigSubscriptionTest.java
@@ -60,6 +60,7 @@ public class ConfigSubscriptionTest {
assertEquals(c1, c1);
assertNotEquals(c1, c2);
+ sub.close();
}
@Test
@@ -70,6 +71,7 @@ public class ConfigSubscriptionTest {
sub.nextConfig();
assertTrue(handle.getConfig().boolval());
//assertTrue(sub.getSource() instanceof RawSource);
+ sub.close();
}
// Test that subscription is closed and subscriptionHandles is empty if we get an exception
diff --git a/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java b/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java
index 43e3cf658f3..555434837c8 100644
--- a/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/ConfigURITest.java
@@ -12,9 +12,9 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ConfigURITest {
+
@Test
public void testDefaultUri() {
ConfigURI uri = ConfigURI.createFromId("foo");
diff --git a/config/src/test/java/com/yahoo/config/subscription/DefaultConfigTest.java b/config/src/test/java/com/yahoo/config/subscription/DefaultConfigTest.java
index 85346264837..1bcf09a4028 100644
--- a/config/src/test/java/com/yahoo/config/subscription/DefaultConfigTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/DefaultConfigTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
* @author hmusum
*/
public class DefaultConfigTest {
+
static final String CONFIG_ID = "raw:" +
"nondefaultstring ####-------missing--------\n" +
"defaultstring \"thedefault\"\n" +
diff --git a/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java b/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java
index cb25de89bfb..9c83f2f3c9a 100644
--- a/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/GenericConfigSubscriberTest.java
@@ -1,7 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.subscription;
-import java.util.*;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import com.yahoo.config.subscription.impl.GenericConfigHandle;
import com.yahoo.config.subscription.impl.GenericConfigSubscriber;
@@ -14,14 +17,16 @@ import com.yahoo.vespa.config.protocol.CompressionType;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
*
* Test cases for the "generic" (class-less) subscription mechanism.
*
* @author Ulf Lilleengen
- * @since 5.1
*/
public class GenericConfigSubscriberTest {
@@ -29,9 +34,9 @@ public class GenericConfigSubscriberTest {
public void testSubscribeGeneric() {
Map<ConfigSourceSet, JRTConfigRequester> requesters = new HashMap<>();
ConfigSourceSet sourceSet = new ConfigSourceSet("blabla");
- requesters.put(sourceSet, JRTConfigRequester.get(new MockConnection(), JRTConfigRequesterTest.getTestTimingValues()));
+ requesters.put(sourceSet, new JRTConfigRequester(new MockConnection(), JRTConfigRequesterTest.getTestTimingValues()));
GenericConfigSubscriber sub = new GenericConfigSubscriber(requesters);
- final List<String> defContent = Arrays.asList("myVal int");
+ final List<String> defContent = List.of("myVal int");
GenericConfigHandle handle = sub.subscribe(new ConfigKey<>("simpletypes", "id", "config"), defContent, sourceSet, JRTConfigRequesterTest.getTestTimingValues());
assertTrue(sub.nextConfig());
assertTrue(handle.isChanged());
@@ -44,32 +49,38 @@ public class GenericConfigSubscriberTest {
public void testGenericRequesterPooling() {
ConfigSourceSet source1 = new ConfigSourceSet("tcp/foo:78");
ConfigSourceSet source2 = new ConfigSourceSet("tcp/bar:79");
- JRTConfigRequester req1 = JRTConfigRequester.get(new JRTConnectionPool(source1), JRTConfigRequesterTest.getTestTimingValues());
- JRTConfigRequester req2 = JRTConfigRequester.get(new JRTConnectionPool(source2), JRTConfigRequesterTest.getTestTimingValues());
+ JRTConfigRequester req1 = JRTConfigRequester.create(source1, JRTConfigRequesterTest.getTestTimingValues());
+ JRTConfigRequester req2 = JRTConfigRequester.create(source2, JRTConfigRequesterTest.getTestTimingValues());
Map<ConfigSourceSet, JRTConfigRequester> requesters = new LinkedHashMap<>();
requesters.put(source1, req1);
requesters.put(source2, req2);
GenericConfigSubscriber sub = new GenericConfigSubscriber(requesters);
assertEquals(sub.requesters().get(source1).getConnectionPool().getCurrent().getAddress(), "tcp/foo:78");
assertEquals(sub.requesters().get(source2).getConnectionPool().getCurrent().getAddress(), "tcp/bar:79");
-
+ for (JRTConfigRequester requester : requesters.values()) {
+ requester.close();
+ }
}
@Test(expected=UnsupportedOperationException.class)
public void testOverriddenSubscribeInvalid1() {
- GenericConfigSubscriber sub = new GenericConfigSubscriber();
- sub.subscribe(null, null);
+ createSubscriber().subscribe(null, null);
}
@Test(expected=UnsupportedOperationException.class)
public void testOverriddenSubscribeInvalid2() {
- GenericConfigSubscriber sub = new GenericConfigSubscriber();
- sub.subscribe(null, null, 0L);
+ createSubscriber().subscribe(null, null, 0L);
}
@Test(expected=UnsupportedOperationException.class)
public void testOverriddenSubscribeInvalid3() {
- GenericConfigSubscriber sub = new GenericConfigSubscriber();
- sub.subscribe(null, null, "");
+ createSubscriber().subscribe(null, null, "");
+ }
+
+ private GenericConfigSubscriber createSubscriber() {
+ return new GenericConfigSubscriber(Map.of(
+ new ConfigSourceSet("blabla"),
+ new JRTConfigRequester(new MockConnection(), JRTConfigRequesterTest.getTestTimingValues())));
}
+
}
diff --git a/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java b/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java
index 5e60c273ee4..430de894629 100644
--- a/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/NamespaceTest.java
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertThat;
* @author gjoranv
*/
public class NamespaceTest {
+
@Test
public void verifyConfigClassWithExplicitNamespace() {
NamespaceConfig config = new ConfigGetter<>(NamespaceConfig.class).getConfig("raw: a 0\n");
diff --git a/config/src/test/java/com/yahoo/config/subscription/UnicodeTest.java b/config/src/test/java/com/yahoo/config/subscription/UnicodeTest.java
index 6512b5ea29e..f1bd164c874 100644
--- a/config/src/test/java/com/yahoo/config/subscription/UnicodeTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/UnicodeTest.java
@@ -13,6 +13,7 @@ import static org.junit.Assert.assertEquals;
* @author Harald Musum
*/
public class UnicodeTest {
+
/**
* Reads a config from a file which is exactly like one returned from
* the config server given only default values for this config.
diff --git a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java
index 2f550fc8e1e..71e7a9f08d7 100644
--- a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.1.7
*/
public class FileConfigSubscriptionTest {
private File TEST_TYPES_FILE;
diff --git a/config/src/test/java/com/yahoo/config/subscription/impl/JRTConfigRequesterTest.java b/config/src/test/java/com/yahoo/config/subscription/impl/JRTConfigRequesterTest.java
index 757dd99f43b..4211345dff7 100644
--- a/config/src/test/java/com/yahoo/config/subscription/impl/JRTConfigRequesterTest.java
+++ b/config/src/test/java/com/yahoo/config/subscription/impl/JRTConfigRequesterTest.java
@@ -1,10 +1,12 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.subscription.impl;
+import com.yahoo.config.subscription.ConfigSourceSet;
import com.yahoo.foo.SimpletypesConfig;
import com.yahoo.config.subscription.ConfigSubscriber;
import com.yahoo.jrt.Request;
import com.yahoo.vespa.config.ConfigKey;
+import com.yahoo.vespa.config.ConnectionPool;
import com.yahoo.vespa.config.ErrorCode;
import com.yahoo.vespa.config.ErrorType;
import com.yahoo.vespa.config.TimingValues;
@@ -17,6 +19,8 @@ import java.util.Random;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -349,4 +353,23 @@ public class JRTConfigRequesterTest {
}
}
+ @Test
+ public void testManagedPool() {
+ ConfigSourceSet sourceSet = ConfigSourceSet.createDefault();
+ TimingValues timingValues = new TimingValues();
+ JRTConfigRequester requester1 = JRTConfigRequester.create(sourceSet, timingValues);
+ JRTConfigRequester requester2 = JRTConfigRequester.create(sourceSet, timingValues);
+ assertNotSame(requester1, requester2);
+ assertSame(requester1.getConnectionPool(), requester2.getConnectionPool());
+ ConnectionPool firstPool = requester1.getConnectionPool();
+ requester1.close();
+ requester2.close();
+ requester1 = JRTConfigRequester.create(sourceSet, timingValues);
+ assertNotSame(firstPool, requester1.getConnectionPool());
+ requester2 = JRTConfigRequester.create(new ConfigSourceSet("test-managed-pool-2"), timingValues);
+ assertNotSame(requester1.getConnectionPool(), requester2.getConnectionPool());
+ requester1.close();
+ requester2.close();
+ }
+
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java
index c77985c91d8..137d2894164 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigBuilderMergeTest.java
@@ -18,7 +18,6 @@ import static org.junit.Assert.assertThat;
* SEO keywords: test override() on builders. overrideTest, testOverride
*
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ConfigBuilderMergeTest {
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java
index bb65fdaa153..fce61cc802c 100755
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigCacheKeyTest.java
@@ -12,6 +12,7 @@ import static org.junit.Assert.*;
* @author hmusum
*/
public class ConfigCacheKeyTest {
+
@Test
public void testConfigCacheKey() {
final String defMd5 = "md5";
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java
index dba73223097..810b9f58829 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigDefinitionBuilderTest.java
@@ -12,7 +12,6 @@ import java.io.IOException;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
-
/**
* Unit tests for ConfigDefinitionBuilder.
*
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java
index 3cc030d944b..5198759d3e2 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigFileFormatterTest.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ConfigFileFormatterTest {
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java
index eb0c47e3b0a..c13d3ec9b9b 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadBuilderTest.java
@@ -17,7 +17,6 @@ import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ConfigPayloadBuilderTest {
diff --git a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java
index f1b0adc03e7..b3db6e2ab43 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ConfigPayloadTest.java
@@ -24,8 +24,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
- * @author Ulf Lilleengen 3
- * @since 5.1
+ * @author Ulf Lilleengen
*/
public class ConfigPayloadTest {
diff --git a/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java b/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java
index e67489b4030..6ab3059f1c0 100644
--- a/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/DefaultValueApplierTest.java
@@ -16,9 +16,9 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class DefaultValueApplierTest {
+
public Slime apply(Slime slime, String ... extraFields) {
StringBuilder defBuilder = new StringBuilder();
defBuilder.append("namespace=test").append("\n");
diff --git a/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java b/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java
index 8e6cc1fc6a0..64210eaa4b8 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ErrorCodeTest.java
@@ -8,9 +8,9 @@ import static org.junit.Assert.assertThat;
/**
* @author hmusum
- * @since 5.1.9
*/
public class ErrorCodeTest {
+
@Test
public void basic() {
assertThat(ErrorCode.getName(ErrorCode.INTERNAL_ERROR), is("INTERNAL_ERROR"));
diff --git a/config/src/test/java/com/yahoo/vespa/config/ErrorTypeTest.java b/config/src/test/java/com/yahoo/vespa/config/ErrorTypeTest.java
index 450d7e8d6d8..a0b2c1185a7 100644
--- a/config/src/test/java/com/yahoo/vespa/config/ErrorTypeTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/ErrorTypeTest.java
@@ -8,7 +8,6 @@ import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class ErrorTypeTest {
@@ -32,4 +31,5 @@ public class ErrorTypeTest {
assertThat(ErrorType.getErrorType(ErrorCode.ILLEGAL_SUB_FLAG), is(ErrorType.FATAL));
assertThat(ErrorType.getErrorType(0xdeadc0de), is(ErrorType.FATAL));
}
+
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java b/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java
index ee7845086c2..2c60ff95fee 100644
--- a/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/GenericConfigBuilderTest.java
@@ -13,9 +13,9 @@ import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
- * @since 5.1
*/
public class GenericConfigBuilderTest {
+
@Test
public void require_that_builder_can_be_overridden() throws IOException {
ConfigPayloadBuilder ba = new ConfigPayloadBuilder();
diff --git a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
index 8a403b45003..cc46301e869 100644
--- a/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/JRTConnectionPoolTest.java
@@ -70,7 +70,7 @@ public class JRTConnectionPoolTest {
// Tests that the number of times each connection is used is close to equal
private void assertConnectionDistributionIsFair(Map<String, Integer> connectionsUsedPerHost) {
- double devianceDueToRandomSourceSelection = 0.13;
+ double devianceDueToRandomSourceSelection = 0.14;
final int size = 1000;
int minHostCount = (int) (size/2 * (1 - devianceDueToRandomSourceSelection));
int maxHostCount = (int) (size/2 * (1 + devianceDueToRandomSourceSelection));
diff --git a/config/src/test/java/com/yahoo/vespa/config/LZ4CompressionTest.java b/config/src/test/java/com/yahoo/vespa/config/LZ4CompressionTest.java
deleted file mode 100644
index a3125c73bea..00000000000
--- a/config/src/test/java/com/yahoo/vespa/config/LZ4CompressionTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.config;
-
-import net.jpountz.lz4.LZ4Compressor;
-import net.jpountz.lz4.LZ4Factory;
-import net.jpountz.lz4.LZ4SafeDecompressor;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-
-/**
- * To run this test, place a payload in src/test/ca.json. The file is not checked in because it is huge.
- *
- * @author Ulf Lilleengen
- * @since 5.12
- */
-public class LZ4CompressionTest {
- private static LZ4Factory factory = LZ4Factory.safeInstance();
-
- @Test
- @Ignore
- public void testCompression() throws IOException {
- byte[] data = getInput();
- System.out.println("High compressor");
- for (int i = 0; i < 10; i++) {
- timeCompressor(factory.highCompressor(), data);
- }
- System.out.println("Fast compressor");
- for (int i = 0; i < 10; i++) {
- timeCompressor(factory.fastCompressor(), data);
- }
- }
-
- private byte[] getInput() throws IOException {
- byte[] data = Files.readAllBytes(FileSystems.getDefault().getPath("src/test/ca.json"));
- System.out.println("Input size: " + data.length);
- return data;
- }
-
- private void timeCompressor(LZ4Compressor lz4Compressor, byte[] data) {
- long start = System.currentTimeMillis();
- byte[] compressed = lz4Compressor.compress(data);
- long end = System.currentTimeMillis();
- System.out.println("Compression took " + (end - start) + " millis, and size of data is " + compressed.length + " bytes");
- }
-
- @Test
- @Ignore
- public void testDecompression() throws IOException {
- byte[] data = getInput();
- byte[] outputbuffer = new byte[data.length];
- byte[] hcCompressedData = factory.highCompressor().compress(data);
- System.out.println("High compressor");
- for (int i = 0; i < 10; i++) {
- timeDecompressor(hcCompressedData, factory.safeDecompressor(), outputbuffer);
- }
- byte[] fastCompressedData = factory.fastCompressor().compress(data);
- System.out.println("Fast compressor");
- for (int i = 0; i < 10; i++) {
- timeDecompressor(fastCompressedData, factory.safeDecompressor(), outputbuffer);
- }
- }
-
- private void timeDecompressor(byte[] compressedData, LZ4SafeDecompressor decompressor, byte[] outputbuffer) {
- long start = System.currentTimeMillis();
- decompressor.decompress(compressedData, outputbuffer);
- long end = System.currentTimeMillis();
- System.out.println("Decompression took " + (end - start) + " millis");
- }
-
-}
diff --git a/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java b/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java
index 06bbaad4271..903b6f3b489 100644
--- a/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/LZ4PayloadCompressorTest.java
@@ -9,9 +9,9 @@ import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
- * @since 5.19
*/
public class LZ4PayloadCompressorTest {
+
@Test
public void testCompression() {
assertCompression("hei hallo der");
@@ -23,8 +23,7 @@ public class LZ4PayloadCompressorTest {
LZ4PayloadCompressor compressor = new LZ4PayloadCompressor();
byte[] data = Utf8.toBytes(input);
byte[] compressed = compressor.compress(data);
- byte[] output = new byte[data.length];
- compressor.decompress(compressed, output);
+ byte[] output = compressor.decompress(compressed, data.length);
assertThat(data, is(output));
}
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java b/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java
index a564fea8b2e..3f6c54ea46e 100644
--- a/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/RawConfigTest.java
@@ -113,11 +113,11 @@ public class RawConfigTest {
assertThat(config.getDefMd5(), is(defMd5));
config = new RawConfig(key, null, payload, configMd5, generation, false, null, Optional.empty());
assertNull(config.getDefMd5());
- config = new RawConfig(key, null, payload, configMd5, generation, false, Arrays.asList(""), Optional.empty());
+ config = new RawConfig(key, null, payload, configMd5, generation, false,List.of(""), Optional.empty());
assertThat(config.getDefMd5(), is(defMd5ForEmptyDefContent));
config = new RawConfig(key, "", payload, configMd5, generation, false, null, Optional.empty());
assertThat(config.getDefMd5(), is(""));
- config = new RawConfig(key, "", payload, configMd5, generation, false, Arrays.asList(""), Optional.empty());
+ config = new RawConfig(key, "", payload, configMd5, generation, false, List.of(""), Optional.empty());
assertThat(config.getDefMd5(), is(defMd5ForEmptyDefContent));
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/SlimeUtilsTest.java b/config/src/test/java/com/yahoo/vespa/config/SlimeUtilsTest.java
deleted file mode 100644
index ff7b640630e..00000000000
--- a/config/src/test/java/com/yahoo/vespa/config/SlimeUtilsTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.config;
-
-import com.yahoo.slime.Cursor;
-import com.yahoo.slime.Slime;
-import com.yahoo.text.Utf8;
-import org.junit.Test;
-
-import java.io.IOException;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Ulf Lilleengen
- * @since 5.8
- */
-public class SlimeUtilsTest {
- @Test
- public void test_copying_slime_types_into_cursor() {
- Slime slime = new Slime();
- Cursor root = slime.setObject();
- root.setString("foo", "foobie");
- Cursor subobj = root.setObject("bar");
-
- Slime slime2 = new Slime();
- Cursor root2 = slime2.setObject();
- root2.setString("a", "a");
- root2.setLong("b", 2);
- root2.setBool("c", true);
- root2.setDouble("d", 3.14);
- root2.setData("e", new byte[]{0x64});
- root2.setNix("f");
-
- SlimeUtils.copyObject(slime2.get(), subobj);
-
- assertThat(root.toString(), is("{\"foo\":\"foobie\",\"bar\":{\"a\":\"a\",\"b\":2,\"c\":true,\"d\":3.14,\"e\":\"0x64\",\"f\":null}}"));
- }
-
- @Test
- public void test_copying_slime_arrays_into_cursor() {
- Slime slime = new Slime();
- Cursor root = slime.setObject();
- root.setString("foo", "foobie");
- Cursor subobj = root.setObject("bar");
-
- Slime slime2 = new Slime();
- Cursor root2 = slime2.setObject();
- Cursor array = root2.setArray("a");
- array.addString("foo");
- array.addLong(4);
- array.addBool(true);
- array.addDouble(3.14);
- array.addNix();
- array.addData(new byte[]{0x64});
- Cursor objinner = array.addObject();
- objinner.setString("inner", "binner");
-
- SlimeUtils.copyObject(slime2.get(), subobj);
-
- assertThat(root.toString(), is("{\"foo\":\"foobie\",\"bar\":{\"a\":[\"foo\",4,true,3.14,null,\"0x64\",{\"inner\":\"binner\"}]}}"));
- }
-
- @Test
- public void test_slime_to_json() throws IOException {
- Slime slime = new Slime();
- Cursor root = slime.setObject();
- root.setString("foo", "foobie");
- root.setObject("bar");
- String json = Utf8.toString(SlimeUtils.toJsonBytes(slime));
- assertThat(json, is("{\"foo\":\"foobie\",\"bar\":{}}"));
- }
-
- @Test
- public void test_json_to_slime() {
- byte[] json = Utf8.toBytes("{\"foo\":\"foobie\",\"bar\":{}}");
- Slime slime = SlimeUtils.jsonToSlime(json);
- assertThat(slime.get().field("foo").asString(), is("foobie"));
- assertTrue(slime.get().field("bar").valid());
- }
-}
diff --git a/config/src/test/java/com/yahoo/vespa/config/TimingValuesTest.java b/config/src/test/java/com/yahoo/vespa/config/TimingValuesTest.java
deleted file mode 100644
index 3b97c360c4b..00000000000
--- a/config/src/test/java/com/yahoo/vespa/config/TimingValuesTest.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.config;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.junit.Assert.assertThat;
-
-/**
- * Note: Most of the functionality is tested implicitly by other tests
- *
- * @author hmusum
- */
-public class TimingValuesTest {
- @Test
- public void basic() {
- TimingValues tv = new TimingValues();
- TimingValues tv2 = new TimingValues(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1);
- assertThat(tv.getRandom(), is(not(tv2.getRandom())));
- TimingValues copy = new TimingValues(tv2);
- assertThat(copy.toString(), is(tv2.toString())); // No equals method, just using toString to compare
- }
-}
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java
index 91adc544d88..a56c7ef2daa 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/ConfigResponseTest.java
@@ -2,9 +2,6 @@
package com.yahoo.vespa.config.protocol;
import com.yahoo.foo.SimpletypesConfig;
-import com.yahoo.config.codegen.DefParser;
-import com.yahoo.config.codegen.InnerCNode;
-import com.yahoo.text.StringUtilities;
import com.yahoo.text.Utf8Array;
import com.yahoo.vespa.config.ConfigPayload;
import com.yahoo.vespa.config.LZ4PayloadCompressor;
@@ -12,10 +9,10 @@ import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.StringReader;
-import java.util.List;
+import java.nio.charset.StandardCharsets;
import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -27,17 +24,16 @@ public class ConfigResponseTest {
@Test
public void require_that_slime_response_is_initialized() throws IOException {
ConfigPayload configPayload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
- DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
- InnerCNode targetDef = dParser.getTree();
- ConfigResponse response = SlimeConfigResponse.fromConfigPayload(configPayload, targetDef, 3, false, "mymd5");
- List<String> payload = response.getLegacyPayload();
+ ConfigResponse response = SlimeConfigResponse.fromConfigPayload(configPayload, 3, false, "mymd5");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ response.serialize(baos, CompressionType.UNCOMPRESSED);
+ String payload = baos.toString(StandardCharsets.UTF_8);
assertNotNull(payload);
- assertThat(payload.size(), is(6));
- assertThat(payload.get(0), is("boolval false"));
+ assertEquals("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}", payload);
assertThat(response.getGeneration(), is(3L));
assertThat(response.getConfigMd5(), is("mymd5"));
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos = new ByteArrayOutputStream();
response.serialize(baos, CompressionType.UNCOMPRESSED);
assertThat(baos.toString(), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
@@ -45,19 +41,15 @@ public class ConfigResponseTest {
@Test
public void require_that_slime_response_decompresses_on_serialize() throws IOException {
ConfigPayload configPayload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
- DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
- InnerCNode targetDef = dParser.getTree();
Utf8Array data = configPayload.toUtf8Array(true);
Utf8Array bytes = new Utf8Array(new LZ4PayloadCompressor().compress(data.getBytes()));
- ConfigResponse response = new SlimeConfigResponse(bytes, targetDef, 3, false, "mymd5", CompressionInfo.create(CompressionType.LZ4, data.getByteLength()));
- List<String> payload = response.getLegacyPayload();
+ ConfigResponse response = new SlimeConfigResponse(bytes, 3, false, "mymd5", CompressionInfo.create(CompressionType.LZ4, data.getByteLength()));
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ response.serialize(baos, CompressionType.UNCOMPRESSED);
+ String payload = baos.toString(StandardCharsets.UTF_8);
assertNotNull(payload);
- assertThat(payload.size(), is(6));
- assertThat(payload.get(0), is("boolval false"));
- assertThat(response.getGeneration(), is(3L));
- assertThat(response.getConfigMd5(), is("mymd5"));
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ baos = new ByteArrayOutputStream();
response.serialize(baos, CompressionType.UNCOMPRESSED);
assertThat(baos.toString(), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java
deleted file mode 100644
index 75ba1392fd1..00000000000
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestBase.java
+++ /dev/null
@@ -1,288 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.config.protocol;
-
-import com.yahoo.foo.SimpletypesConfig;
-import com.yahoo.config.subscription.ConfigSet;
-import com.yahoo.config.subscription.ConfigSourceSet;
-import com.yahoo.config.subscription.ConfigSubscriber;
-import com.yahoo.config.subscription.impl.GenericConfigSubscriber;
-import com.yahoo.config.subscription.impl.JRTConfigRequester;
-import com.yahoo.config.subscription.impl.JRTConfigSubscription;
-import com.yahoo.config.subscription.impl.MockConnection;
-import com.yahoo.jrt.Request;
-import com.yahoo.slime.Inspector;
-import com.yahoo.slime.JsonDecoder;
-import com.yahoo.slime.Slime;
-import com.yahoo.test.ManualClock;
-import com.yahoo.text.Utf8;
-import com.yahoo.vespa.config.ConfigKey;
-import com.yahoo.vespa.config.ConfigPayload;
-import com.yahoo.vespa.config.ErrorCode;
-import com.yahoo.vespa.config.RawConfig;
-import com.yahoo.vespa.config.TimingValues;
-import com.yahoo.vespa.config.util.ConfigUtils;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Ulf Lilleengen
- * @since 5.3
- */
-public abstract class JRTConfigRequestBase {
-
- protected String defName = "mydef";
- protected String defNamespace = "my.name.space";
- protected String hostname = "myhost";
- protected String configId = "config/id";
- protected String defMd5 = "595f44fec1e92a71d3e9e77456ba80d1";
- protected long currentGeneration = 3;
- protected final Optional<VespaVersion> vespaVersion = Optional.of(VespaVersion.fromString("5.38.24"));
- protected long timeout = 5000;
- protected Trace trace ;
- protected String configMd5 = ConfigUtils.getMd5(createPayload().getData());
- protected JRTClientConfigRequest clientReq;
- protected JRTServerConfigRequest serverReq;
-
- @Before
- public void setupRequest() throws IOException {
- clientReq = createReq();
- serverReq = createReq(clientReq.getRequest());
- assertTrue(serverReq.validateParameters());
- }
-
- private JRTClientConfigRequest createReq() throws IOException {
- trace = Trace.createNew(3, new ManualClock());
- trace.trace(1, "hei");
- return createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace);
- }
-
- private JRTClientConfigRequest createReq(Payload payload) throws IOException {
- trace = Trace.createNew(3, new ManualClock());
- trace.trace(1, "hei");
- return createReq(defName, defNamespace, defMd5, hostname, configId, ConfigUtils.getMd5(payload.getData()), currentGeneration, timeout, trace);
- }
-
- protected abstract JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5,
- String hostname, String configId, String configMd5,
- long currentGeneration, long timeout, Trace trace);
- protected abstract JRTServerConfigRequest createReq(Request request);
- protected abstract JRTClientConfigRequest createReq(JRTConfigSubscription<SimpletypesConfig> sub, Trace aNew);
- protected abstract JRTClientConfigRequest createFromRaw(RawConfig rawConfig, long serverTimeout, Trace aNew);
-
- protected void request_is_parsed_base() {
- String [] expectedContent = new String[]{
- "namespace=my.name.space",
- "myfield string"
- };
- System.out.println(serverReq.toString());
- assertThat(serverReq.getConfigKey().getName(), is(defName));
- assertThat(serverReq.getConfigKey().getNamespace(), is(defNamespace));
- assertThat(serverReq.getConfigKey().getMd5(), is(defMd5));
- assertThat(serverReq.getConfigKey().getConfigId(), is(configId));
- assertThat(serverReq.getDefContent().asStringArray(), is(expectedContent));
- assertFalse(serverReq.noCache());
- assertTrue(serverReq.getRequestTrace().toString().contains("hi"));
- assertThat(serverReq.getRequestConfigMd5(), is(configMd5));
- assertThat(serverReq.getRequestGeneration(), is(currentGeneration));
- }
-
- @Test
- public void delay_mechanisms_functions() {
- assertFalse(serverReq.isDelayedResponse());
- serverReq.setDelayedResponse(true);
- assertTrue(serverReq.isDelayedResponse());
- serverReq.setDelayedResponse(false);
- assertFalse(serverReq.isDelayedResponse());
- }
-
- public JRTServerConfigRequest next_request_is_correct_base() {
- String [] expectedContent = new String[]{
- "namespace=my.name.space",
- "myfield string"
- };
- JRTServerConfigRequest next = createReq(clientReq.nextRequest(6).getRequest());
- assertThat(next.getConfigKey().getName(), is(defName));
- assertThat(next.getConfigKey().getNamespace(), is(defNamespace));
- assertThat(next.getConfigKey().getMd5(), is(defMd5));
- assertThat(next.getConfigKey().getConfigId(), is(configId));
- assertThat(next.getDefContent().asStringArray(), is(expectedContent));
- assertFalse(next.noCache());
- assertThat(next.getTimeout(), is(6L));
- assertThat(next.getTimeout(), is(6L));
- return next;
- }
-
-
- @Test
- public void next_request_when_error_is_correct() {
- serverReq.addOkResponse(createPayload(), 999999, false, "newmd5");
- serverReq.addErrorResponse(ErrorCode.OUTDATED_CONFIG, "error message");
- System.out.println(serverReq);
- JRTClientConfigRequest next = clientReq.nextRequest(6);
- System.out.println(next);
- // Should use config md5 and generation from the request, not the response
- // when there are errors
- assertThat(next.getRequestConfigMd5(), is(clientReq.getRequestConfigMd5()));
- assertThat(next.getRequestGeneration(), is(clientReq.getRequestGeneration()));
- }
-
- @Test
- public void ok_response_is_added() {
- Payload payload = createPayload("vale");
- String md5 = ConfigUtils.getMd5(payload.getData());
- long generation = 4L;
- serverReq.addOkResponse(payload, generation, false, md5);
- assertTrue(clientReq.validateResponse());
- assertThat(clientReq.getNewPayload().withCompression(CompressionType.UNCOMPRESSED).getData().toString(), is(payload.getData().toString()));
- assertThat(clientReq.getNewGeneration(), is(4L));
- assertThat(clientReq.getNewConfigMd5(), is(md5));
- assertTrue(clientReq.hasUpdatedConfig());
- assertTrue(clientReq.hasUpdatedGeneration());
- }
-
- @Test
- public void error_response_adds_common_elements() {
- serverReq.addErrorResponse(ErrorCode.APPLICATION_NOT_LOADED, ErrorCode.getName(ErrorCode.APPLICATION_NOT_LOADED));
- assertThat(serverReq.getRequest().returnValues().size(), is(1));
- Slime data = new JsonDecoder().decode(new Slime(), Utf8.toBytes(serverReq.getRequest().returnValues().get(0).asString()));
- Inspector response = data.get();
- assertThat(response.field(SlimeResponseData.RESPONSE_DEF_NAME).asString(), is(defName));
- assertThat(response.field(SlimeResponseData.RESPONSE_DEF_NAMESPACE).asString(), is(defNamespace));
- assertThat(response.field(SlimeResponseData.RESPONSE_DEF_MD5).asString(), is(defMd5));
- assertThat(response.field(SlimeResponseData.RESPONSE_CONFIGID).asString(), is(configId));
- assertThat(response.field(SlimeResponseData.RESPONSE_CLIENT_HOSTNAME).asString(), is(hostname));
- Trace t = Trace.fromSlime(response.field(SlimeResponseData.RESPONSE_TRACE));
- assertThat(t.toString(), is(trace.toString()));
- }
-
- @Test
- public void generation_only_is_updated() {
- Payload payload = createPayload();
- serverReq.addOkResponse(payload, 4L, false, ConfigUtils.getMd5(payload.getData()));
- boolean value = clientReq.validateResponse();
- assertTrue(clientReq.errorMessage(), value);
- assertFalse(clientReq.hasUpdatedConfig());
- assertTrue(clientReq.hasUpdatedGeneration());
- }
-
- protected static Payload createPayload() {
- return createPayload("bar");
- }
-
- private static Payload createPayload(String value) {
- Slime slime = new Slime();
- slime.setObject().setString("myfield", value);
- return Payload.from(new ConfigPayload(slime));
- }
-
- @Test
- public void nothing_is_updated() {
- Payload payload = createPayload();
- serverReq.addOkResponse(payload, currentGeneration, false, configMd5);
- assertTrue(clientReq.validateResponse());
- assertFalse(clientReq.hasUpdatedConfig());
- assertFalse(clientReq.hasUpdatedGeneration());
- }
-
- @Test
- public void payload_is_empty() throws IOException {
- Payload payload = Payload.from(ConfigPayload.empty());
- clientReq = createReq(payload);
- serverReq = createReq(clientReq.getRequest());
- serverReq.addOkResponse(payload, currentGeneration, false, ConfigUtils.getMd5(payload.getData()));
- boolean val = clientReq.validateResponse();
- assertTrue(clientReq.errorMessage(), val);
- assertFalse(clientReq.hasUpdatedConfig());
- assertFalse(clientReq.hasUpdatedGeneration());
- }
-
- @Test
- public void request_interface_is_implemented() {
- JRTClientConfigRequest request = clientReq;
- assertFalse(request.containsPayload());
- assertFalse(request.isError());
- assertThat(request.errorCode(), is(clientReq.getRequest().errorCode()));
- assertThat(request.errorMessage(), is(clientReq.getRequest().errorMessage()));
- assertNotNull(request.getRequest());
- assertFalse(request.validateResponse());
- //assertNull(request.getNewPayload().getData());
- assertThat(request.getTimeout(), is(timeout));
- assertFalse(request.hasUpdatedConfig());
- assertFalse(request.hasUpdatedGeneration());
- }
-
- @Test
- public void created_from_subscription() {
- ConfigSubscriber subscriber = new ConfigSubscriber();
- JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, new ConfigSet(), new TimingValues());
- JRTClientConfigRequest request = createReq(sub, Trace.createNew(9));
- assertThat(request.getConfigKey().getName(), is(SimpletypesConfig.CONFIG_DEF_NAME));
- JRTServerConfigRequest serverRequest = createReq(request.getRequest());
- assertTrue(serverRequest.validateParameters());
- }
-
- @Test
- public void created_from_existing_subscription() {
- System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", getProtocolVersion());
- MockConnection connection = new MockConnection(new MockConnection.AbstractResponseHandler() {
- @Override
- protected void createResponse() {
- JRTServerConfigRequest serverRequest = createReq(request);
- serverRequest.addOkResponse(createPayload(), currentGeneration, false, configMd5);
- }
- });
-
- ConfigSourceSet src = new ConfigSourceSet();
- ConfigSubscriber subscriber = new GenericConfigSubscriber(Collections.singletonMap(src, JRTConfigRequester.get(connection, new TimingValues())));
- JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, src, new TimingValues());
- sub.subscribe(120_0000);
- assertTrue(sub.nextConfig(120_0000));
- sub.close();
- JRTClientConfigRequest nextReq = createReq(sub, Trace.createNew());
- SimpletypesConfig config = sub.getConfigState().getConfig();
- assertThat(nextReq.getRequestConfigMd5(), is(config.getConfigMd5()));
- assertThat(nextReq.getRequestGeneration(), is(currentGeneration));
- System.setProperty("VESPA_CONFIG_PROTOCOL_VERSION", "");
- }
-
- protected abstract String getProtocolVersion();
-
- @Test
- public void created_from_raw() throws IOException {
- RawConfig rawConfig = new RawConfig(new ConfigKey<>(defName, configId, defNamespace), defMd5);
- long serverTimeout = 100000L;
- JRTClientConfigRequest request = createFromRaw(rawConfig, serverTimeout, Trace.createNew(9));
- assertThat(request.getConfigKey().getName(), is(defName));
- JRTServerConfigRequest serverRequest = createReq(request.getRequest());
- assertTrue(serverRequest.validateParameters());
- assertThat(serverRequest.getTimeout(), is(serverTimeout));
- assertThat(serverRequest.getDefContent().asList(), is(rawConfig.getDefContent()));
- }
-
-
- @Test
- public void parameters_are_validated() throws IOException {
- assertTrue(serverReq.validateParameters());
- assertValidationFail(createReq("35#$#!$@#", defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, "abcd.o#$*(!&$", defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, "34", hostname, configId, "34", currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, "34", currentGeneration, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, -34, timeout, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, -23, trace));
- assertValidationFail(createReq(defName, defNamespace, defMd5, "", configId, configMd5, currentGeneration, timeout, trace));
- }
-
- private void assertValidationFail(JRTClientConfigRequest req) {
- assertFalse(createReq(req.getRequest()).validateParameters());
- }
-}
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java
index 35332176774..04f3a7abe29 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestFactoryTest.java
@@ -20,41 +20,6 @@ public class JRTConfigRequestFactoryTest {
private static VespaVersion defaultVespaVersion = JRTConfigRequestFactory.getCompiledVespaVersion();
@Test
- public void testGetProtocolVersion() {
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "", ""), is("3"));
-
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "", ""), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "1", ""), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "", "1"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "1", ""), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "", "1"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "1", "1"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "1", "1"), is("1"));
-
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "", ""), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "2", ""), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "", "2"), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "2", ""), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "", "2"), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "2", "2"), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "2", "2"), is("2"));
-
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "2", ""), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "", "2"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "1", "2"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "1", ""), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "", "1"), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("", "2", "1"), is("2"));
-
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "2", "2"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "1", "2"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("1", "2", "1"), is("1"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "1", "1"), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "1", "2"), is("2"));
- assertThat(JRTConfigRequestFactory.getProtocolVersion("2", "2", "1"), is("2"));
- }
-
- @Test
public void testCompressionType() {
assertThat(JRTConfigRequestFactory.getCompressionType("", "", ""), is(CompressionType.LZ4));
@@ -102,19 +67,8 @@ public class JRTConfigRequestFactoryTest {
JRTConfigSubscription<FunctionTestConfig> sub = new JRTConfigSubscription<>(
new ConfigKey<>(clazz, configId), subscriber, new ConfigSet(), new TimingValues());
- // Default vespa version
JRTClientConfigRequest request = JRTConfigRequestFactory.createFromSub(sub);
- assertThat(request.getProtocolVersion(), is(3L));
assertThat(request.getVespaVersion().get(), is(defaultVespaVersion));
-
- // Create with vespa version set
- String version = "5.37.38";
- System.setProperty(JRTConfigRequestFactory.VESPA_VERSION, version);
- request = JRTConfigRequestFactory.createFromSub(sub);
- assertThat(request.getProtocolVersion(), is(3L));
- assertThat(request.getVespaVersion().get(), is(VespaVersion.fromString(version)));
-
- System.clearProperty(JRTConfigRequestFactory.VESPA_VERSION);
}
@Test
@@ -123,19 +77,8 @@ public class JRTConfigRequestFactoryTest {
final String configId = "foo";
RawConfig config = new RawConfig(new ConfigKey<>(clazz, configId), "595f44fec1e92a71d3e9e77456ba80d1");
- // Default vespa version
JRTClientConfigRequest request = JRTConfigRequestFactory.createFromRaw(config, 1000);
- assertThat(request.getProtocolVersion(), is(3L));
assertThat(request.getVespaVersion().get(), is(defaultVespaVersion));
-
- // Create with vespa version set
- String version = "5.37.38";
- System.setProperty(JRTConfigRequestFactory.VESPA_VERSION, version);
- request = JRTConfigRequestFactory.createFromRaw(config, 1000);
- assertThat(request.getProtocolVersion(), is(3L));
- assertThat(request.getVespaVersion().get(), is(VespaVersion.fromString(version)));
-
- System.clearProperty(JRTConfigRequestFactory.VESPA_VERSION);
}
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java
index d50a92efc1a..4d1ba2f8793 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/JRTConfigRequestV3Test.java
@@ -1,59 +1,58 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.protocol;
+import com.yahoo.config.subscription.ConfigSet;
+import com.yahoo.config.subscription.ConfigSourceSet;
+import com.yahoo.config.subscription.ConfigSubscriber;
+import com.yahoo.config.subscription.impl.GenericConfigSubscriber;
+import com.yahoo.config.subscription.impl.JRTConfigRequester;
+import com.yahoo.config.subscription.impl.MockConnection;
import com.yahoo.foo.SimpletypesConfig;
import com.yahoo.config.subscription.impl.JRTConfigSubscription;
import com.yahoo.jrt.Request;
+import com.yahoo.slime.Inspector;
+import com.yahoo.slime.JsonDecoder;
+import com.yahoo.slime.Slime;
+import com.yahoo.test.ManualClock;
+import com.yahoo.text.Utf8;
import com.yahoo.vespa.config.*;
import com.yahoo.vespa.config.util.ConfigUtils;
+import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.Optional;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.19
*/
-public class JRTConfigRequestV3Test extends JRTConfigRequestBase {
+public class JRTConfigRequestV3Test {
- @Override
- protected JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5,
- String hostname, String configId, String configMd5,
- long currentGeneration, long timeout, Trace trace) {
- return JRTClientConfigRequestV3.createWithParams(ConfigKey.createFull(defName, configId, defNamespace, defMd5),
- DefContent.fromList(Arrays.asList("namespace=my.name.space", "myfield string")),
- hostname,
- configMd5,
- currentGeneration,
- timeout,
- trace,
- CompressionType.LZ4,
- vespaVersion);
- }
-
- @Override
- protected JRTServerConfigRequest createReq(Request request) {
- return JRTServerConfigRequestV3.createFromRequest(request);
- }
-
- @Override
- protected JRTClientConfigRequest createReq(JRTConfigSubscription<SimpletypesConfig> sub, Trace aNew) {
- return JRTClientConfigRequestV3.createFromSub(sub, aNew, CompressionType.LZ4, vespaVersion);
- }
+ private final Optional<VespaVersion> vespaVersion = Optional.of(VespaVersion.fromString("5.38.24"));
+ private String defName = "mydef";
+ private String defNamespace = "my.name.space";
+ private String hostname = "myhost";
+ private String configId = "config/id";
+ private String defMd5 = "595f44fec1e92a71d3e9e77456ba80d1";
+ private long currentGeneration = 3;
+ private long timeout = 5000;
+ private Trace trace ;
+ private String configMd5 = ConfigUtils.getMd5(createPayload().getData());
+ private JRTClientConfigRequest clientReq;
+ private JRTServerConfigRequest serverReq;
- @Override
- protected JRTClientConfigRequest createFromRaw(RawConfig rawConfig, long serverTimeout, Trace aNew) {
- return JRTClientConfigRequestV3.createFromRaw(rawConfig, serverTimeout, aNew, CompressionType.LZ4, vespaVersion);
- }
-
- @Override
- protected String getProtocolVersion() {
- return "3";
+ @Before
+ public void setupRequest() {
+ clientReq = createReq();
+ serverReq = createReq(clientReq.getRequest());
+ assertTrue(serverReq.validateParameters());
}
@Test
@@ -71,11 +70,250 @@ public class JRTConfigRequestV3Test extends JRTConfigRequestBase {
@Test
public void emptypayload() {
ConfigPayload payload = ConfigPayload.empty();
- SlimeConfigResponse response = SlimeConfigResponse.fromConfigPayload(payload, null, 0, false, ConfigUtils.getMd5(payload));
+ SlimeConfigResponse response = SlimeConfigResponse.fromConfigPayload(payload, 0, false, ConfigUtils.getMd5(payload));
serverReq.addOkResponse(serverReq.payloadFromResponse(response), response.getGeneration(), false, response.getConfigMd5());
assertTrue(clientReq.validateResponse());
assertTrue(clientReq.hasUpdatedGeneration());
assertThat(clientReq.getNewPayload().withCompression(CompressionType.UNCOMPRESSED).getData().toString(), is("{}"));
assertFalse(clientReq.responseIsInternalRedeploy());
}
+
+ @Test
+ public void delay_mechanisms_function() {
+ assertFalse(serverReq.isDelayedResponse());
+ serverReq.setDelayedResponse(true);
+ assertTrue(serverReq.isDelayedResponse());
+ serverReq.setDelayedResponse(false);
+ assertFalse(serverReq.isDelayedResponse());
+ }
+
+ @Test
+ public void next_request_when_error_is_correct() {
+ serverReq.addOkResponse(createPayload(), 999999, false, "newmd5");
+ serverReq.addErrorResponse(ErrorCode.OUTDATED_CONFIG, "error message");
+ System.out.println(serverReq);
+ JRTClientConfigRequest next = clientReq.nextRequest(6);
+ System.out.println(next);
+ // Should use config md5 and generation from the request, not the response
+ // when there are errors
+ assertThat(next.getRequestConfigMd5(), is(clientReq.getRequestConfigMd5()));
+ assertThat(next.getRequestGeneration(), is(clientReq.getRequestGeneration()));
+ }
+
+ @Test
+ public void ok_response_is_added() {
+ Payload payload = createPayload("vale");
+ String md5 = ConfigUtils.getMd5(payload.getData());
+ long generation = 4L;
+ serverReq.addOkResponse(payload, generation, false, md5);
+ assertTrue(clientReq.validateResponse());
+ assertThat(clientReq.getNewPayload().withCompression(CompressionType.UNCOMPRESSED).getData().toString(), is(payload.getData().toString()));
+ assertThat(clientReq.getNewGeneration(), is(4L));
+ assertThat(clientReq.getNewConfigMd5(), is(md5));
+ assertTrue(clientReq.hasUpdatedConfig());
+ assertTrue(clientReq.hasUpdatedGeneration());
+ }
+
+ @Test
+ public void error_response_adds_common_elements() {
+ serverReq.addErrorResponse(ErrorCode.APPLICATION_NOT_LOADED, ErrorCode.getName(ErrorCode.APPLICATION_NOT_LOADED));
+ assertThat(serverReq.getRequest().returnValues().size(), is(1));
+ Slime data = new JsonDecoder().decode(new Slime(), Utf8.toBytes(serverReq.getRequest().returnValues().get(0).asString()));
+ Inspector response = data.get();
+ assertThat(response.field(SlimeResponseData.RESPONSE_DEF_NAME).asString(), is(defName));
+ assertThat(response.field(SlimeResponseData.RESPONSE_DEF_NAMESPACE).asString(), is(defNamespace));
+ assertThat(response.field(SlimeResponseData.RESPONSE_DEF_MD5).asString(), is(defMd5));
+ assertThat(response.field(SlimeResponseData.RESPONSE_CONFIGID).asString(), is(configId));
+ assertThat(response.field(SlimeResponseData.RESPONSE_CLIENT_HOSTNAME).asString(), is(hostname));
+ Trace t = Trace.fromSlime(response.field(SlimeResponseData.RESPONSE_TRACE));
+ assertThat(t.toString(), is(trace.toString()));
+ }
+
+ @Test
+ public void generation_only_is_updated() {
+ Payload payload = createPayload();
+ serverReq.addOkResponse(payload, 4L, false, ConfigUtils.getMd5(payload.getData()));
+ boolean value = clientReq.validateResponse();
+ assertTrue(clientReq.errorMessage(), value);
+ assertFalse(clientReq.hasUpdatedConfig());
+ assertTrue(clientReq.hasUpdatedGeneration());
+ }
+
+ @Test
+ public void nothing_is_updated() {
+ Payload payload = createPayload();
+ serverReq.addOkResponse(payload, currentGeneration, false, configMd5);
+ assertTrue(clientReq.validateResponse());
+ assertFalse(clientReq.hasUpdatedConfig());
+ assertFalse(clientReq.hasUpdatedGeneration());
+ }
+
+ @Test
+ public void payload_is_empty() {
+ Payload payload = Payload.from(ConfigPayload.empty());
+ clientReq = createReq(payload);
+ serverReq = createReq(clientReq.getRequest());
+ serverReq.addOkResponse(payload, currentGeneration, false, ConfigUtils.getMd5(payload.getData()));
+ boolean val = clientReq.validateResponse();
+ assertTrue(clientReq.errorMessage(), val);
+ assertFalse(clientReq.hasUpdatedConfig());
+ assertFalse(clientReq.hasUpdatedGeneration());
+ }
+
+ @Test
+ public void request_interface_is_implemented() {
+ JRTClientConfigRequest request = clientReq;
+ assertFalse(request.isError());
+ assertThat(request.errorCode(), is(clientReq.getRequest().errorCode()));
+ assertThat(request.errorMessage(), is(clientReq.getRequest().errorMessage()));
+ assertNotNull(request.getRequest());
+ assertFalse(request.validateResponse());
+ //assertNull(request.getNewPayload().getData());
+ assertThat(request.getTimeout(), is(timeout));
+ assertFalse(request.hasUpdatedConfig());
+ assertFalse(request.hasUpdatedGeneration());
+ }
+
+ @Test
+ public void created_from_subscription() {
+ ConfigSubscriber subscriber = new ConfigSubscriber();
+ JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, new ConfigSet(), new TimingValues());
+ JRTClientConfigRequest request = createReq(sub, Trace.createNew(9));
+ assertThat(request.getConfigKey().getName(), is(SimpletypesConfig.CONFIG_DEF_NAME));
+ JRTServerConfigRequest serverRequest = createReq(request.getRequest());
+ assertTrue(serverRequest.validateParameters());
+ }
+
+ @Test
+ public void created_from_existing_subscription() {
+ MockConnection connection = new MockConnection(new MockConnection.AbstractResponseHandler() {
+ @Override
+ public void createResponse() {
+ JRTServerConfigRequest serverRequest = createReq(request);
+ serverRequest.addOkResponse(createPayload(), currentGeneration, false, configMd5);
+ }
+ });
+
+ ConfigSourceSet src = new ConfigSourceSet();
+ ConfigSubscriber subscriber = new GenericConfigSubscriber(Collections.singletonMap(src, new JRTConfigRequester(connection, new TimingValues())));
+ JRTConfigSubscription<SimpletypesConfig> sub = new JRTConfigSubscription<>(new ConfigKey<>(SimpletypesConfig.class, configId), subscriber, src, new TimingValues());
+ sub.subscribe(120_0000);
+ assertTrue(sub.nextConfig(120_0000));
+ sub.close();
+ JRTClientConfigRequest nextReq = createReq(sub, Trace.createNew());
+ SimpletypesConfig config = sub.getConfigState().getConfig();
+ assertThat(nextReq.getRequestConfigMd5(), is(config.getConfigMd5()));
+ assertThat(nextReq.getRequestGeneration(), is(currentGeneration));
+ }
+
+ @Test
+ public void created_from_raw() {
+ RawConfig rawConfig = new RawConfig(new ConfigKey<>(defName, configId, defNamespace), defMd5);
+ long serverTimeout = 100000L;
+ JRTClientConfigRequest request = createFromRaw(rawConfig, serverTimeout, Trace.createNew(9));
+ assertThat(request.getConfigKey().getName(), is(defName));
+ JRTServerConfigRequest serverRequest = createReq(request.getRequest());
+ assertTrue(serverRequest.validateParameters());
+ assertThat(serverRequest.getTimeout(), is(serverTimeout));
+ assertThat(serverRequest.getDefContent().asList(), is(rawConfig.getDefContent()));
+ }
+
+ @Test
+ public void parameters_are_validated() {
+ assertTrue(serverReq.validateParameters());
+ assertValidationFail(createReq("35#$#!$@#", defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace));
+ assertValidationFail(createReq(defName, "abcd.o#$*(!&$", defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace));
+ assertValidationFail(createReq(defName, defNamespace, "34", hostname, configId, "34", currentGeneration, timeout, trace));
+ assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, "34", currentGeneration, timeout, trace));
+ assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, -34, timeout, trace));
+ assertValidationFail(createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, -23, trace));
+ assertValidationFail(createReq(defName, defNamespace, defMd5, "", configId, configMd5, currentGeneration, timeout, trace));
+ }
+
+ private void assertValidationFail(JRTClientConfigRequest req) {
+ assertFalse(createReq(req.getRequest()).validateParameters());
+ }
+
+ private static Payload createPayload() {
+ return createPayload("bar");
+ }
+
+ private static Payload createPayload(String value) {
+ Slime slime = new Slime();
+ slime.setObject().setString("myfield", value);
+ return Payload.from(new ConfigPayload(slime));
+ }
+
+ private JRTClientConfigRequest createReq(String defName, String defNamespace, String defMd5,
+ String hostname, String configId, String configMd5,
+ long currentGeneration, long timeout, Trace trace) {
+ return JRTClientConfigRequestV3.createWithParams(ConfigKey.createFull(defName, configId, defNamespace, defMd5),
+ DefContent.fromList(Arrays.asList("namespace=my.name.space", "myfield string")),
+ hostname,
+ configMd5,
+ currentGeneration,
+ timeout,
+ trace,
+ CompressionType.LZ4,
+ vespaVersion);
+ }
+
+ private JRTServerConfigRequest createReq(Request request) {
+ return JRTServerConfigRequestV3.createFromRequest(request);
+ }
+
+ private JRTClientConfigRequest createReq(JRTConfigSubscription<SimpletypesConfig> sub, Trace aNew) {
+ return JRTClientConfigRequestV3.createFromSub(sub, aNew, CompressionType.LZ4, vespaVersion);
+ }
+
+ private JRTClientConfigRequest createFromRaw(RawConfig rawConfig, long serverTimeout, Trace aNew) {
+ return JRTClientConfigRequestV3.createFromRaw(rawConfig, serverTimeout, aNew, CompressionType.LZ4, vespaVersion);
+ }
+
+ private JRTClientConfigRequest createReq() {
+ trace = Trace.createNew(3, new ManualClock());
+ trace.trace(1, "hei");
+ return createReq(defName, defNamespace, defMd5, hostname, configId, configMd5, currentGeneration, timeout, trace);
+ }
+
+ private JRTClientConfigRequest createReq(Payload payload) {
+ trace = Trace.createNew(3, new ManualClock());
+ trace.trace(1, "hei");
+ return createReq(defName, defNamespace, defMd5, hostname, configId, ConfigUtils.getMd5(payload.getData()), currentGeneration, timeout, trace);
+ }
+
+ private void request_is_parsed_base() {
+ String [] expectedContent = new String[]{
+ "namespace=my.name.space",
+ "myfield string"
+ };
+ System.out.println(serverReq.toString());
+ assertThat(serverReq.getConfigKey().getName(), is(defName));
+ assertThat(serverReq.getConfigKey().getNamespace(), is(defNamespace));
+ assertThat(serverReq.getConfigKey().getMd5(), is(defMd5));
+ assertThat(serverReq.getConfigKey().getConfigId(), is(configId));
+ assertThat(serverReq.getDefContent().asStringArray(), is(expectedContent));
+ assertFalse(serverReq.noCache());
+ assertTrue(serverReq.getRequestTrace().toString().contains("hi"));
+ assertThat(serverReq.getRequestConfigMd5(), is(configMd5));
+ assertThat(serverReq.getRequestGeneration(), is(currentGeneration));
+ }
+
+ private JRTServerConfigRequest next_request_is_correct_base() {
+ String [] expectedContent = new String[]{
+ "namespace=my.name.space",
+ "myfield string"
+ };
+ JRTServerConfigRequest next = createReq(clientReq.nextRequest(6).getRequest());
+ assertThat(next.getConfigKey().getName(), is(defName));
+ assertThat(next.getConfigKey().getNamespace(), is(defNamespace));
+ assertThat(next.getConfigKey().getMd5(), is(defMd5));
+ assertThat(next.getConfigKey().getConfigId(), is(configId));
+ assertThat(next.getDefContent().asStringArray(), is(expectedContent));
+ assertFalse(next.noCache());
+ assertThat(next.getTimeout(), is(6L));
+ assertThat(next.getTimeout(), is(6L));
+ return next;
+ }
+
}
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java
index e5fc5190ad1..c52245ecb35 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/PayloadTest.java
@@ -15,7 +15,6 @@ import static org.junit.Assert.assertThat;
/**
* @author Ulf Lilleengen
- * @since 5.21
*/
public class PayloadTest {
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java
index f2d9edc7c35..22baab85c1c 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/SlimeTraceSerializerTest.java
@@ -21,9 +21,9 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.5
*/
public class SlimeTraceSerializerTest {
+
@Test
public void test_serializer() throws IOException {
TraceNode root = new TraceNode(null, 1);
diff --git a/config/src/test/java/com/yahoo/vespa/config/protocol/TraceTest.java b/config/src/test/java/com/yahoo/vespa/config/protocol/TraceTest.java
index 596983eebb8..4b191d85121 100644
--- a/config/src/test/java/com/yahoo/vespa/config/protocol/TraceTest.java
+++ b/config/src/test/java/com/yahoo/vespa/config/protocol/TraceTest.java
@@ -9,7 +9,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.3
*/
public class TraceTest {
@@ -58,4 +57,5 @@ public class TraceTest {
assertTrue(trace2Str.contains("barbaz"));
assertTrue(trace2Str.contains("quux"));
}
+
}