Search in sources :

Example 6 with Repeat

use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_200_SubstituteList.

/**
   * Tests different DB substitute list methods.
   */
@Test
@Repeat(times = REPEAT)
public void test_200_SubstituteList() {
    //CHECKED FOR VALIDITY
    String testSubstituteListGuid = "testSubstituteListGUID" + RandomString.randomString(12);
    String field = "people";
    GuidEntry testEntry = null;
    try {
        // Utils.clearTestGuids(client);
        // System.out.println("cleared old GUIDs");
        testEntry = clientCommands.guidCreate(masterGuid, testSubstituteListGuid);
        System.out.print(testEntry + " ");
    } catch (Exception e) {
        failWithStackTrace("Exception during init: ", e);
    }
    try {
        clientCommands.fieldAppendOrCreateList(testEntry.getGuid(), field, new JSONArray(Arrays.asList("Frank", "Joe", "Sally", "Rita")), testEntry);
    } catch (IOException | ClientException e) {
        failWithStackTrace("Exception during create: ", e);
    }
    try {
        HashSet<String> expected = new HashSet<>(Arrays.asList("Frank", "Joe", "Sally", "Rita"));
        HashSet<String> actual = JSONUtils.JSONArrayToHashSet(clientCommands.fieldReadArray(testEntry.getGuid(), field, testEntry));
        Assert.assertEquals(expected, actual);
    } catch (Exception e) {
        failWithStackTrace("Exception when we were not expecting it: ", e);
    }
    try {
        clientCommands.fieldSubstitute(testEntry.getGuid(), field, new JSONArray(Arrays.asList("BillyBob", "Hank")), new JSONArray(Arrays.asList("Frank", "Joe")), testEntry);
    } catch (IOException | ClientException e) {
        failWithStackTrace("Exception during substitute: ", e);
    }
    try {
        HashSet<String> expected = new HashSet<>(Arrays.asList("BillyBob", "Hank", "Sally", "Rita"));
        HashSet<String> actual = JSONUtils.JSONArrayToHashSet(clientCommands.fieldReadArray(testEntry.getGuid(), field, testEntry));
        Assert.assertEquals(expected, actual);
    } catch (Exception e) {
        failWithStackTrace("Exception when we were not expecting it: ", e);
    }
}
Also used : JSONArray(org.json.JSONArray) RandomString(edu.umass.cs.gnscommon.utils.RandomString) IOException(java.io.IOException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) EncryptionException(edu.umass.cs.gnscommon.exceptions.client.EncryptionException) FieldNotFoundException(edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) FileNotFoundException(java.io.FileNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) HashSet(java.util.HashSet) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test) Repeat(edu.umass.cs.utils.Repeat)

Example 7 with Repeat

use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_500_Batch_Tests.

/**
   * The test set for testing batch creates. The test will create batches
   * of size 2, 4, 8,..., 128.
   *
   * @throws Exception
   */
@Test
@Repeat(times = 7)
public void test_500_Batch_Tests() throws Exception {
    GuidEntry accountGuidForBatch = test_510_CreateBatchAccountGuid();
    test_511_CreateBatch(accountGuidForBatch);
    test_512_CheckBatch(accountGuidForBatch);
    numberToCreate *= 2;
}
Also used : BasicGuidEntry(edu.umass.cs.gnsclient.client.util.BasicGuidEntry) GuidEntry(edu.umass.cs.gnsclient.client.util.GuidEntry) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test) Repeat(edu.umass.cs.utils.Repeat)

Example 8 with Repeat

use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_530_Index_Tests.

/**
   * A test set for checking field indices.
   *
   * @throws JSONException
   * @throws IOException
   * @throws ClientException
   */
@Test
@Repeat(times = REPEAT)
public void test_530_Index_Tests() throws ClientException, IOException, JSONException {
    String createIndexTestField = test_540_CreateField();
    test_541_CreateIndex(createIndexTestField);
    test_610_SelectPass(createIndexTestField);
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test) Repeat(edu.umass.cs.utils.Repeat)

Example 9 with Repeat

use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_010_CreateEntity.

/* TODO:
   * Brendan: I've begun checking tests to make sure that logically
   * they should pass every time in a distributed setting.
   * I will be marking the tests I've already checked with //CHECKED FOR VALIDITY
   * in the first line of the test.
   * 
   * For now I'm assuming no loss (if tests are run locally hopefully this won't be a problem)
   * and bounded delays (of less than the timeout).  I am also assuming the tests are executed
   * in order as some do depend on the actions of previous tests.
   * 
   * TODO: Increase the timeout for these test commands so that they almost never fail due to timeout.
   * 
   */
/**
   * Creates a guid.
   *
   * @throws Exception
   */
@Test
@Repeat(times = REPEAT)
public void test_010_CreateEntity() throws Exception {
    // CHECKED FOR VALIDITY
    String alias = "testGUID" + RandomString.randomString(12);
    String createdGUID = client.execute(GNSCommand.guidCreate(masterGuid, alias)).getResultString();
    Assert.assertEquals(alias, GuidUtils.getGUIDKeys(alias).entityName);
    Assert.assertEquals(createdGUID, GuidUtils.getGUIDKeys(alias).guid);
// deprecated client test
// GuidEntry guidEntry = clientCommands.guidCreate(masterGuid, alias);
// Assert.assertNotNull(guidEntry);
// Assert.assertEquals(alias, guidEntry.getEntityName());
}
Also used : RandomString(edu.umass.cs.gnscommon.utils.RandomString) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test) Repeat(edu.umass.cs.utils.Repeat)

Example 10 with Repeat

use of edu.umass.cs.utils.Repeat in project GNS by MobilityFirst.

the class ServerIntegrationTest method test_630_CheckLNSProxy.

/**
   * A basic test to insure that setting LNS Proxy minimally doesn't break.
   */
// This requires that the LOCAL_NAME_SERVER_NODES config option be set.
@Test
@Repeat(times = REPEAT)
public void test_630_CheckLNSProxy() {
    try {
        //PaxosConfig.getActives() works here because the server and client use the same properties file.
        InetAddress lnsAddress = PaxosConfig.getActives().values().iterator().next().getAddress();
        clientCommands.setGNSProxy(new InetSocketAddress(lnsAddress, 24598));
    } catch (Exception e) {
        failWithStackTrace("Exception while setting proxy: ", e);
    }
    String guidString = null;
    try {
        guidString = clientCommands.lookupGuid(accountAlias);
    } catch (IOException | ClientException e) {
        failWithStackTrace("Exception while looking up guid: ", e);
    }
    JSONObject json = null;
    if (guidString != null) {
        try {
            json = clientCommands.lookupAccountRecord(guidString);
        } catch (IOException | ClientException e) {
            failWithStackTrace("Exception while looking up account record: ", e);
        }
    }
    Assert.assertNotNull("Account record is null", json);
    try {
        Assert.assertEquals("Account name doesn't match", accountAlias, json.getString(GNSProtocol.ACCOUNT_RECORD_USERNAME.toString()));
    } catch (JSONException e) {
        failWithStackTrace("Exception while looking up account name: ", e);
    }
    clientCommands.setGNSProxy(null);
}
Also used : JSONObject(org.json.JSONObject) InetSocketAddress(java.net.InetSocketAddress) JSONException(org.json.JSONException) RandomString(edu.umass.cs.gnscommon.utils.RandomString) IOException(java.io.IOException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) InetAddress(java.net.InetAddress) EncryptionException(edu.umass.cs.gnscommon.exceptions.client.EncryptionException) FieldNotFoundException(edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException) JSONException(org.json.JSONException) ClientException(edu.umass.cs.gnscommon.exceptions.client.ClientException) FileNotFoundException(java.io.FileNotFoundException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) DefaultGNSTest(edu.umass.cs.gnsserver.utils.DefaultGNSTest) Test(org.junit.Test) Repeat(edu.umass.cs.utils.Repeat)

Aggregations

DefaultGNSTest (edu.umass.cs.gnsserver.utils.DefaultGNSTest)13 Repeat (edu.umass.cs.utils.Repeat)13 Test (org.junit.Test)13 RandomString (edu.umass.cs.gnscommon.utils.RandomString)11 GuidEntry (edu.umass.cs.gnsclient.client.util.GuidEntry)7 BasicGuidEntry (edu.umass.cs.gnsclient.client.util.BasicGuidEntry)5 JSONObject (org.json.JSONObject)5 ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)4 IOException (java.io.IOException)4 EncryptionException (edu.umass.cs.gnscommon.exceptions.client.EncryptionException)3 FieldNotFoundException (edu.umass.cs.gnscommon.exceptions.client.FieldNotFoundException)3 FileNotFoundException (java.io.FileNotFoundException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 JSONArray (org.json.JSONArray)3 JSONException (org.json.JSONException)3 ContextServiceClient (edu.umass.cs.contextservice.client.ContextServiceClient)2 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 HashSet (java.util.HashSet)1