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);
}
}
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;
}
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);
}
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());
}
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);
}
Aggregations