From: <tho...@us...> - 2014-04-08 12:22:14
|
Revision: 8083 http://sourceforge.net/p/bigdata/code/8083 Author: thompsonbry Date: 2014-04-08 12:22:11 +0000 (Tue, 08 Apr 2014) Log Message: ----------- Modified test case to demonstrate failure for #883 (CANCEL Query fails on non-default kb namespace on HA follower). Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA3CancelQuery.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA3CancelQuery.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA3CancelQuery.java 2014-04-07 23:57:41 UTC (rev 8082) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-jini/src/test/com/bigdata/journal/jini/ha/TestHA3CancelQuery.java 2014-04-08 12:22:11 UTC (rev 8083) @@ -26,39 +26,24 @@ */ package com.bigdata.journal.jini.ha; +import java.io.IOException; import java.util.UUID; import net.jini.config.Configuration; +import org.apache.http.client.HttpClient; +import org.apache.http.impl.client.DefaultHttpClient; + import com.bigdata.ha.HAGlue; import com.bigdata.ha.HAStatusEnum; -import com.bigdata.journal.AbstractJournal; -import com.bigdata.quorum.Quorum; import com.bigdata.rdf.sail.webapp.client.RemoteRepository; +import com.bigdata.rdf.sail.webapp.client.RemoteRepositoryManager; /** - * Test suites for an {@link HAJournalServer} quorum with a replication factor - * of THREE (3) and a fully met {@link Quorum}. + * Test suite for the SPARQL query and SPARQL update request cancellation + * protocol for an {@link HAJournalServer} quorum with a replication factor of + * THREE (3). * - * TODO Do we have any guards against rolling back a service in RESYNC if the - * other services are more than 2 commit points before it? We probably should - * not automatically roll it back to the other services in this case, but that - * could also reduce the ergonomics of the HA3 configuration. - * - * TODO All of these live load remains met tests could also be done with BOUNCE - * rather than SHUTDOWN/RESTART. BOUNCE exercises different code paths and - * corresponds to a zookeeper timeout, e.g., as might occur during a full GC - * pause. - * - * TODO Update the existing tests to verify that the quorum token is properly - * set on C when C resyncs with A+B and that - * {@link AbstractJournal#getHAReady()} reports the correct token. This tests - * for a problem where we did not call setQuorumToken() again when we resync and - * transition into the met quorum. This meant that the HAReady token is not set - * for a service unless it is part of the initial quorum meet. One of the HA3 - * backup tests covers this, but we should be checking the HAReadyToken in this - * test suite as well. - * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> */ public class TestHA3CancelQuery extends AbstractHA3JournalServerTestCase { @@ -95,6 +80,9 @@ * order will be A, B, C. Issues cancel request to each of the services and * verifies that all services are willing to accept a POST of the CANCEL * request. + * + * @see <a href="http://trac.bigdata.com/ticket/883">CANCEL Query fails on + * non-default kb namespace on HA follower</a> */ public void test_ABC_CancelQuery() throws Exception { @@ -108,22 +96,90 @@ // await the KB create commit point to become visible on each service. awaitCommitCounter(1L, new HAGlue[] { serverA, serverB, serverC }); - // get RemoteRepository for each service. - final RemoteRepository[] repo = new RemoteRepository[3]; - - repo[0] = getRemoteRepository(serverA); - repo[1] = getRemoteRepository(serverB); - repo[2] = getRemoteRepository(serverC); - // Verify leader vs followers. assertEquals(HAStatusEnum.Leader, serverA.getHAStatus()); assertEquals(HAStatusEnum.Follower, serverB.getHAStatus()); assertEquals(HAStatusEnum.Follower, serverC.getHAStatus()); - repo[0].cancel(UUID.randomUUID()); - repo[1].cancel(UUID.randomUUID()); - repo[2].cancel(UUID.randomUUID()); + /* + * Do CANCEL for each service using the default namespace. + */ + { + // Get RemoteRepository for each service. + final RemoteRepository[] repo = new RemoteRepository[3]; + + repo[0] = getRemoteRepository(serverA); + repo[1] = getRemoteRepository(serverB); + repo[2] = getRemoteRepository(serverC); + + repo[0].cancel(UUID.randomUUID()); + repo[1].cancel(UUID.randomUUID()); + repo[2].cancel(UUID.randomUUID()); + + } + /* + * Do CANCEL for each service using the SPARQL end point associated with + * a non-default namespace: + * + * /sparql/namespace/NAMESPACE + */ + { + final String namespace = "kb"; + + // Get RemoteRepository for each service. + final RemoteRepository[] repo = new RemoteRepository[3]; + + repo[0] = getRemoteRepositoryForNamespace(serverA, namespace); + repo[1] = getRemoteRepositoryForNamespace(serverB, namespace); + repo[2] = getRemoteRepositoryForNamespace(serverC, namespace); + + repo[0].cancel(UUID.randomUUID()); + repo[1].cancel(UUID.randomUUID()); + repo[2].cancel(UUID.randomUUID()); + } + } + /** + * Return a {@link RemoteRepository} that will communicate with the KB + * instance associated with the given <i>namespace</i>. The + * {@link RemoteRepository} will use a URL for the SPARQL end point that is + * associated with the specified namespace and formed as + * <code>/sparql/namespace/<i>namespace</i></code> rather than the default + * KB SPARQL end point (<code>/sparql</code>). + * + * @param haGlue + * The service. + * @param namespace + * The namespace. + * @return The {@link RemoteRepository} for that namespace. + * + * @throws IOException + * + * TODO Push down into the abstract base class when reconciling + * with the RDR branch which has changes to the abstract base + * class to support the LBS. + */ + protected RemoteRepository getRemoteRepositoryForNamespace( + final HAGlue haGlue, final String namespace) throws IOException { + + final String sparqlEndpointURL = getNanoSparqlServerURL(haGlue); + + // Client for talking to the NSS. + final HttpClient httpClient = new DefaultHttpClient(ccm); + + final RemoteRepositoryManager repositoryManager = new RemoteRepositoryManager( + sparqlEndpointURL, httpClient, executorService); + + final RemoteRepository repo = repositoryManager + .getRepositoryForNamespace(namespace); + + // Note: This is not required in order to demonstrate the problem. +// repo.setMaxRequestURLLength(65536); +// repo.setQueryMethod("GET"); + + return repo; + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |