示例#1
0
int tpcmaster_get_slave_for_key(void) {
    setup_slaves();
    // hash is -1848860354761560747
    tpcslave_t *result = tpcmaster_get_primary(&testmaster, "winteriscoming");
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, 2561935789451811312);
    // hash is 4971736480875674229
    result = tpcmaster_get_primary(&testmaster, "inagalaxyfarfaraway");
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, 5397345852215556464);
    // hash is 610258952914415519
    result = tpcmaster_get_primary(&testmaster, "iamyourfather");
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, 2561935789451811312);
    // hash is -2806306382981094914
    result = tpcmaster_get_primary(&testmaster, "thisisourtownscrub");
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, -2561935789451811312);
    // hash is -4289169641250935895
    result = tpcmaster_get_primary(&testmaster, "noooooooo");
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, -2561935789451811312);
    cleanup_slaves();
    return 1;
}
示例#2
0
int tpcmaster_get_successor_for_slave(void) {
    setup_slaves();
    // hash is -1848860354761560747
    tpcslave_t *result = tpcmaster_get_successor(&testmaster,
                         testmaster.slaves_head);
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, -2561935789451811312);
    // hash is 4971736480875674229
    result = tpcmaster_get_successor(&testmaster, result);
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, 2561935789451811312);
    // hash is 610258952914415519
    result = tpcmaster_get_successor(&testmaster, result);
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, 5397345852215556464);
    // hash is -2806306382981094914
    result = tpcmaster_get_successor(&testmaster, result);
    ASSERT_PTR_NOT_NULL(result);
    ASSERT_EQUAL(result->id, -5397345852215556464);
    // hash is -4289169641250935895
    cleanup_slaves();
    return 1;
}
示例#3
0
int kvserver_write_through(void) {
  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY";
  reqmsg.value = "MYVALUE";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  char* retval;
  int ret;

  //check if written to cache
  ret = kvcache_get(&testserver.cache, "MYKEY", &retval);
  ASSERT_EQUAL(ret, 0);
  ASSERT_PTR_NOT_NULL(retval);
  ASSERT_EQUAL(strcmp("MYVALUE", retval), 0);
  free(retval);

  //check if written to store
  ret = find_entry(&testserver.store, "MYKEY", &retval);
  ASSERT_TRUE(ret >= 0);
  ASSERT_PTR_NOT_NULL(retval);
  ASSERT_EQUAL(strcmp("MYVALUE", retval), 0);
  free(retval);

  return 1;
}
void testSuccessAssertPtrNotNull(void)
{
	ASSERT_PTR_NOT_NULL(NULL) ;
	ASSERT_PTR_NOT_NULL(0x0) ;
}
void testSuccessAssertPtrNotNull(void)
{
	ASSERT_PTR_NOT_NULL((void*)0x23) ;
}