Search in sources :

Example 6 with CoordinatorConfig

use of voldemort.rest.coordinator.config.CoordinatorConfig in project voldemort by voldemort.

the class CoordinatorRestAPITest method testLargeValueSizeVersionedPut.

@Test
public void testLargeValueSizeVersionedPut() {
    String key = "amigo";
    String payload = generateRandomString(new CoordinatorConfig().getHttpMessageDecoderMaxChunkSize() * 10, ValueType.ALPHA);
    String newPayload = generateRandomString(new CoordinatorConfig().getHttpMessageDecoderMaxChunkSize() * 10, ValueType.ALPHA);
    // 1. Do a put
    doPut(key, payload, null);
    // 2. Do a get on the same key
    TestVersionedValue response = doGet(key, null);
    if (response == null) {
        fail("key does not exist after a put. ");
    }
    System.out.println("Received value: " + response.getValue());
    // 3. Do a versioned put based on the version received previously
    doPut(key, newPayload, response.getVc());
    // 4. Do a get again on the same key
    TestVersionedValue newResponse = doGet(key);
    if (newResponse == null) {
        fail("key does not exist after the versioned put. ");
    }
    assertEquals("Returned response does not have a higer version", Occurred.AFTER, newResponse.getVc().compare(response.getVc()));
    assertEquals("Returned response does not have a higer version", Occurred.BEFORE, response.getVc().compare(newResponse.getVc()));
    System.out.println("Received value after the Versioned put: " + newResponse.getValue());
    if (!newResponse.getValue().equals(newPayload)) {
        fail("Received value is incorrect ! Expected : " + newPayload + " but got : " + newResponse.getValue());
    }
}
Also used : CoordinatorConfig(voldemort.rest.coordinator.config.CoordinatorConfig) Test(org.junit.Test)

Aggregations

CoordinatorConfig (voldemort.rest.coordinator.config.CoordinatorConfig)6 File (java.io.File)5 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)4 Before (org.junit.Before)4 IOException (java.io.IOException)3 CoordinatorProxyService (voldemort.rest.coordinator.CoordinatorProxyService)2 CoordinatorServer (voldemort.rest.coordinator.CoordinatorServer)2 FileBasedStoreClientConfigService (voldemort.rest.coordinator.config.FileBasedStoreClientConfigService)2 StoreClientConfigService (voldemort.rest.coordinator.config.StoreClientConfigService)2 RESTClientConfig (voldemort.restclient.RESTClientConfig)2 CoordinatorAdminClient (voldemort.restclient.admin.CoordinatorAdminClient)2 Test (org.junit.Test)1 VoldemortException (voldemort.VoldemortException)1 RESTClientFactory (voldemort.restclient.RESTClientFactory)1 RESTClientFactoryConfig (voldemort.restclient.RESTClientFactoryConfig)1 ObsoleteVersionException (voldemort.versioning.ObsoleteVersionException)1