Apache Solr open-source search software
Remove duplicate code fragments in StreamingTest (#1489)
Jan Høydahl33ee6f2dad11
diff --git a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.javaindex 337ae7e9af3..295fca76f9f 100644--- a/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java+++ b/solr/solrj-streaming/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java@@ -144,6 +144,20 @@ public class StreamingTest extends SolrCloudTestCase {private static final String id = "id";+ // Update request shared by many of the tests+ private final UpdateRequest helloDocsUpdateRequest =+ new UpdateRequest()+ .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")+ .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")+ .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")+ .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")+ .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")+ .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")+ .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")+ .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")+ .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")+ .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10");+@Beforepublic void clearCollection() throws Exception {new UpdateRequest().deleteByQuery("*:*").commit(cluster.getSolrClient(), COLLECTIONORALIAS);@@ -194,18 +208,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testNonePartitionKeys() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();streamContext.setSolrClientCache(solrClientCache);@@ -412,18 +415,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testTrace() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -449,18 +441,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testReducerStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -527,18 +508,7 @@ public class StreamingTest extends SolrCloudTestCase {public void testZeroReducerStream() throws Exception {// Gracefully handle zero results- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -566,18 +536,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testParallelReducerStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -671,18 +630,7 @@ public class StreamingTest extends SolrCloudTestCase {@Ignorepublic void testExceptionStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -717,18 +665,7 @@ public class StreamingTest extends SolrCloudTestCase {@Ignorepublic void testParallelExceptionStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);SolrParams sParamsA = params("q", "*:*", "fl", "a_s,a_i,a_f,blah", "sort", "blah asc");CloudSolrStream stream = new CloudSolrStream(zkHost, COLLECTIONORALIAS, sParamsA);@@ -805,18 +742,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testStatsStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -874,18 +800,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testFacetStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -1699,18 +1614,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testRollupStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();streamContext.setSolrClientCache(solrClientCache);@@ -1976,18 +1880,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testRollupWithNoParallel() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -2051,18 +1944,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testParallelRollupStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();@@ -2184,18 +2066,7 @@ public class StreamingTest extends SolrCloudTestCase {@Testpublic void testZeroParallelReducerStream() throws Exception {- new UpdateRequest()- .add(id, "0", "a_s", "hello0", "a_i", "0", "a_f", "1")- .add(id, "2", "a_s", "hello0", "a_i", "2", "a_f", "2")- .add(id, "3", "a_s", "hello3", "a_i", "3", "a_f", "3")- .add(id, "4", "a_s", "hello4", "a_i", "4", "a_f", "4")- .add(id, "1", "a_s", "hello0", "a_i", "1", "a_f", "5")- .add(id, "5", "a_s", "hello3", "a_i", "10", "a_f", "6")- .add(id, "6", "a_s", "hello4", "a_i", "11", "a_f", "7")- .add(id, "7", "a_s", "hello3", "a_i", "12", "a_f", "8")- .add(id, "8", "a_s", "hello3", "a_i", "13", "a_f", "9")- .add(id, "9", "a_s", "hello0", "a_i", "14", "a_f", "10")- .commit(cluster.getSolrClient(), COLLECTIONORALIAS);+ helloDocsUpdateRequest.commit(cluster.getSolrClient(), COLLECTIONORALIAS);StreamContext streamContext = new StreamContext();SolrClientCache solrClientCache = new SolrClientCache();