aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-01-27 08:53:21 +0100
committerGitHub <noreply@github.com>2021-01-27 08:53:21 +0100
commitd7359f7c72ff06889af594431baf4075e2b4da78 (patch)
treee915ef0fab20774984afbf355158016bcdcb3004 /documentapi/src/test/java/com/yahoo
parentfb99ec84858f2c68fcc0d22bc182c0aad3c0cb83 (diff)
Revert "Jonmv/document protocol super config"
Diffstat (limited to 'documentapi/src/test/java/com/yahoo')
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java8
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java22
-rw-r--r--documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java20
3 files changed, 20 insertions, 30 deletions
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java
index 5aa3994a757..f324245b612 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTest.java
@@ -5,7 +5,6 @@ import org.junit.Ignore;
import org.junit.Test;
public class ContentPolicyTest extends Simulator {
-
/**
* Verify that a resent message with failures doesn't ruin overall performance. (By dumping the cached state too often
* so other requests are sent to wrong target)
@@ -18,7 +17,6 @@ public class ContentPolicyTest extends Simulator {
+ "Last correctnode 99, wrongnode 1, downnode 0, worked 92, failed 8",
new PersistentFailureTestParameters().addBadNode(new BadNode(3, FailureType.TRANSIENT_ERROR)));
}
-
/**
* Verify that a resent message with failures doesn't ruin overall performance. (By dumping the cached state too often
* so other requests are sent to wrong target)
@@ -31,7 +29,6 @@ public class ContentPolicyTest extends Simulator {
+ "Last correctnode 99, wrongnode 1, downnode 0, worked 92, failed 8",
new PersistentFailureTestParameters().addBadNode(new BadNode(3, FailureType.FATAL_ERROR)));
}
-
/**
* Verify that a node responding with old cluster state doesn't ruin overall performance (By dumping/switching cached
* state too often)
@@ -44,7 +41,6 @@ public class ContentPolicyTest extends Simulator {
+ "Last correctnode 100, wrongnode 0, downnode 0, worked 100, failed 0",
new PersistentFailureTestParameters().addBadNode(new BadNode(3, FailureType.OLD_CLUSTER_STATE).setDownInCurrentState()));
}
-
/**
* Verify that a reset cluster state version doesn't keep sending requests to the wrong node.
* We expect a few failures in first half. We should have detected the issue before second half, so there all should be fine.
@@ -56,7 +52,6 @@ public class ContentPolicyTest extends Simulator {
+ "Last correctnode .*, wrongnode 0, downnode 0, worked .*, failed 0",
new PersistentFailureTestParameters().addBadNode(new BadNode(3, FailureType.RESET_CLUSTER_STATE).setDownInCurrentState()));
}
-
/**
* Verify that a reset cluster state version doesn't keep sending requests to the wrong node.
* We expect a few failures in first half. We should have detected the issue before second half, so there all should be fine.
@@ -75,7 +70,6 @@ public class ContentPolicyTest extends Simulator {
+ "Last correctnode .*, wrongnode 100, downnode 100, worked 0, failed 100",
new PersistentFailureTestParameters().addBadNode(new BadNode(3, FailureType.RESET_CLUSTER_STATE_NO_GOOD_NODES).setDownInCurrentState()));
}
-
/**
* Verify that a reset cluster state version doesn't keep sending requests to the wrong node.
* We expect a few failures in first half. We should have detected the issue before second half, so there all should be fine.
@@ -92,7 +86,6 @@ public class ContentPolicyTest extends Simulator {
+ "Last correctnode .*, wrongnode 91, downnode 0, worked 0, failed 100",
new PersistentFailureTestParameters().addBadNode(new BadNode(3, FailureType.RESET_CLUSTER_STATE_NO_GOOD_NODES)));
}
-
/**
* Verify that a reset cluster state version doesn't keep sending requests to the wrong node.
* Another scenario where we have a node coming up in correct state.
@@ -105,7 +98,6 @@ public class ContentPolicyTest extends Simulator {
+ "Last correctnode .*, wrongnode 0, downnode 0, worked .*, failed 0",
new PersistentFailureTestParameters().newNodeAdded().addBadNode(new BadNode(3, FailureType.RESET_CLUSTER_STATE).setDownInCurrentState()));
}
-
/** Test node that is not in slobrok. Until fleetcontroller detects this, we expect 10% of the requests to go to wrong node. */
@Test
@Ignore // FIXME test has been implicitly disabled for ages, figure out and fix
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java
index 6d2477e1871..479e0b0f422 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/ContentPolicyTestEnvironment.java
@@ -34,13 +34,11 @@ import java.util.TreeSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
public abstract class ContentPolicyTestEnvironment {
- protected ContentPolicyTestFactory policyFactory;
+ protected StoragePolicyTestFactory policyFactory;
protected PolicyTestFrame frame;
private Set<Integer> nodes;
protected static int[] bucketOneNodePreference = new int[]{ 3, 5, 7, 6, 8, 0, 9, 2, 1, 4 };
@@ -53,7 +51,7 @@ public abstract class ContentPolicyTestEnvironment {
frame = new PolicyTestFrame(manager);
nodes = new TreeSet<>();
DocumentProtocol protocol = (DocumentProtocol) frame.getMessageBus().getProtocol((Utf8Array)DocumentProtocol.NAME);
- policyFactory = new ContentPolicyTestFactory(nodes);
+ policyFactory = new StoragePolicyTestFactory(nodes);
protocol.putRoutingPolicyFactory("storage", policyFactory);
frame.setMessage(createMessage("id:ns:testdoc:n=1:foo"));
frame.setHop(new HopSpec("test", "[storage:cluster=foo]"));
@@ -106,7 +104,7 @@ public abstract class ContentPolicyTestEnvironment {
public static class TestHostFetcher extends ContentPolicy.HostFetcher {
private final String clusterName;
- private final RandomGen randomizer = new RandomGen(1234);
+ private RandomGen randomizer = new RandomGen(1234);
private final Set<Integer> nodes;
private Integer avoidPickingAtRandom = null;
@@ -123,14 +121,13 @@ public abstract class ContentPolicyTestEnvironment {
try{
if (distributor == null) {
if (nodes.size() == 1) {
- assertNotSame(avoidPickingAtRandom, nodes.iterator().next());
+ assertTrue(avoidPickingAtRandom != nodes.iterator().next());
distributor = nodes.iterator().next();
} else {
Iterator<Integer> it = nodes.iterator();
for (int i = 0, n = randomizer.nextInt(nodes.size() - 1); i<n; ++i) it.next();
distributor = it.next();
- if (avoidPickingAtRandom != null && avoidPickingAtRandom.equals(distributor))
- distributor = it.next();
+ if (avoidPickingAtRandom != null && distributor == avoidPickingAtRandom) distributor = it.next();
}
}
if (nodes.contains(distributor)) {
@@ -140,7 +137,8 @@ public abstract class ContentPolicyTestEnvironment {
}
} catch (RuntimeException e) {
e.printStackTrace();
- throw new AssertionError(e.getMessage());
+ assertTrue(e.getMessage(), false);
+ throw e;
}
}
}
@@ -162,12 +160,12 @@ public abstract class ContentPolicyTestEnvironment {
public Distribution createDistribution(SlobrokPolicy policy) { return distribution; }
}
- public static class ContentPolicyTestFactory implements RoutingPolicyFactory {
+ public static class StoragePolicyTestFactory implements RoutingPolicyFactory {
private Set<Integer> nodes;
- private final LinkedList<TestParameters> parameterInstances = new LinkedList<>();
+ private final LinkedList<TestParameters> parameterInstances = new LinkedList<TestParameters>();
private Integer avoidPickingAtRandom = null;
- public ContentPolicyTestFactory(Set<Integer> nodes) {
+ public StoragePolicyTestFactory(Set<Integer> nodes) {
this.nodes = nodes;
}
public DocumentProtocolRoutingPolicy createPolicy(String parameters) {
diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java
index be880e69781..d23dd9ea998 100644
--- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java
+++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/test/storagepolicy/Simulator.java
@@ -31,7 +31,7 @@ public abstract class Simulator extends ContentPolicyTestEnvironment {
RESET_CLUSTER_STATE_NO_GOOD_NODES,
NODE_NOT_IN_SLOBROK
};
- private int getIdealTarget(String idString, String clusterState) {
+ private Integer getIdealTarget(String idString, String clusterState) {
DocumentId did = new DocumentId(idString);
BucketIdFactory factory = new BucketIdFactory();
BucketId bid = factory.getBucketId(did);
@@ -145,7 +145,6 @@ public abstract class Simulator extends ContentPolicyTestEnvironment {
return currentClusterState;
}
}
-
public void runSimulation(String expected, PersistentFailureTestParameters params) {
params.validate();
// Set nodes in slobrok
@@ -158,16 +157,16 @@ public abstract class Simulator extends ContentPolicyTestEnvironment {
replyWrongDistribution(target, "foo", null, params.getInitialClusterState().toString());
}
RandomGen randomizer = new RandomGen(432121);
- int[] correctnode = new int[2],
- wrongnode = new int[2],
- failed = new int[2],
- worked = new int[2],
- downnode = new int[2];
+ int correctnode[] = new int[2],
+ wrongnode[] = new int[2],
+ failed[] = new int[2],
+ worked[] = new int[2],
+ downnode[] = new int[2];
for (int step = 0, steps = (params.getTotalRequests() / params.getParallellRequests()); step < steps; ++step) {
int half = (step < steps / 2 ? 0 : 1);
if (debug) System.err.println("Starting step " + step + " in half " + half);
- String[] docId = new String[params.getParallellRequests()];
- RoutingNode[] targets = new RoutingNode[params.getParallellRequests()];
+ String docId[] = new String[params.getParallellRequests()];
+ RoutingNode targets[] = new RoutingNode[params.getParallellRequests()];
for (int i=0; i<params.getParallellRequests(); ++i) {
docId[i] = "id:ns:testdoc::" + (step * params.getParallellRequests() + i);
frame.setMessage(createMessage(docId[i]));
@@ -207,6 +206,7 @@ public abstract class Simulator extends ContentPolicyTestEnvironment {
}
}
StringBuilder actual = new StringBuilder();
+ String result[][] = new String[2][];
for (int i=0; i<2; ++i) {
actual.append(i == 0 ? "First " : " Last ")
.append("correctnode ").append(correctnode[i])
@@ -215,7 +215,7 @@ public abstract class Simulator extends ContentPolicyTestEnvironment {
.append(", worked ").append(worked[i])
.append(", failed ").append(failed[i]);
}
- if ( ! Pattern.matches(expected, actual.toString())) {
+ if (!Pattern.matches(expected, actual.toString())) {
assertEquals(expected, actual.toString());
}
}