Exemplo n.º 1
0
static void test_geos_linemerge(void)
{
	char *ewkt;
	char *out_ewkt;
	LWGEOM *geom1;
	LWGEOM *geom2;

	ewkt = "MULTILINESTRING((0 0, 0 100),(0 -5, 0 0))";
	geom1 = lwgeom_from_wkt(ewkt, LW_PARSER_CHECK_NONE);
	geom2 = lwgeom_linemerge(geom1);
	out_ewkt = lwgeom_to_ewkt((LWGEOM*)geom2);
	ASSERT_STRING_EQUAL(out_ewkt, "LINESTRING(0 -5,0 0,0 100)");
	lwfree(out_ewkt);
	lwgeom_free(geom1);
	lwgeom_free(geom2);

	ewkt = "MULTILINESTRING EMPTY";
	geom1 = lwgeom_from_wkt(ewkt, LW_PARSER_CHECK_NONE);
	geom2 = lwgeom_linemerge(geom1);
	out_ewkt = lwgeom_to_ewkt((LWGEOM*)geom2);
	ASSERT_STRING_EQUAL(out_ewkt, "GEOMETRYCOLLECTION EMPTY");
	lwfree(out_ewkt);
	lwgeom_free(geom1);
	lwgeom_free(geom2);
}
Exemplo n.º 2
0
int tpcmaster_register_single(void) {
    reqmsg.type = REGISTER;
    reqmsg.key = "123.45.67.89";
    reqmsg.value = "987";
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);
    tpcslave_t *slave = testmaster.slaves_head;
    ASSERT_STRING_EQUAL(slave->host, "123.45.67.89");
    ASSERT_EQUAL(slave->port, 987);
    ASSERT_EQUAL(slave->id, 5331380280059431172);
    return 1;
}
Exemplo n.º 3
0
int tpcmaster_get_cached(void) {
    int ret;
    pthread_rwlock_t *cachelock = kvcache_getlock(&testmaster.cache, "KEY");
    pthread_rwlock_wrlock(cachelock);
    ret = kvcache_put(&testmaster.cache, "KEY", "VAL");
    pthread_rwlock_unlock(cachelock);
    ASSERT_EQUAL(ret, 0);
    reqmsg.key = "KEY";
    tpcmaster_handle_get(&testmaster, &reqmsg, &respmsg);
    ASSERT_EQUAL(respmsg.type, GETRESP);
    ASSERT_STRING_EQUAL(respmsg.key, "KEY");
    ASSERT_STRING_EQUAL(respmsg.value, "VAL");
    return 1;
}
Exemplo n.º 4
0
int kvserver_single_put_get(void) {
  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY";
  reqmsg.value = "MYVALUE";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, GETRESP);
  ASSERT_STRING_EQUAL(respmsg.key, "MYKEY");
  ASSERT_STRING_EQUAL(respmsg.value, "MYVALUE");
  return 1;
}
Exemplo n.º 5
0
int kvserver_get_no_key(void) {
  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY";
  reqmsg.value = "MYVALUE";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  reqmsg.type = GETREQ;
  reqmsg.key = "NOT MYKEY";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_NO_KEY);
  return 1;
}
Exemplo n.º 6
0
int tpcmaster_get_simple(void) {
    current_test = GET_SIMPLE;
    tpcmaster_run_test();
    ASSERT_EQUAL(respmsg.type, GETRESP);
    ASSERT_STRING_EQUAL(respmsg.value, "VAL");
    return 1;
}
Exemplo n.º 7
0
int tpcmaster_get_replica(void) {
    current_test = GET_REPLICA;
    tpcmaster_run_test();
    ASSERT_EQUAL(respmsg.type, GETRESP);
    ASSERT_STRING_EQUAL(respmsg.value, "VAL");
    return 1;
}
void testSuccessAssertStringEqual(void)
{
	char str1[] = "test" ;
	char str2[] = "test" ;

	ASSERT_STRING_EQUAL(str1, str2) ;
}
Exemplo n.º 9
0
int tpcmaster_put_updates_cache(void) {
    char* value;
    current_test = PUT_CACHE;
    tpcmaster_run_test();
    kvcache_get(&testmaster.cache, "KEY", &value);
    ASSERT_STRING_EQUAL(value, "VAL2");
    return 1;
}
Exemplo n.º 10
0
int tpcmaster_register_slave_twice(void) {
    reqmsg.type = REGISTER;
    reqmsg.key = "123.45.67.89";
    reqmsg.value = "2112";
    unsigned int init_slave_count = testmaster.slave_count;
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);
    ASSERT_EQUAL(testmaster.slave_count, init_slave_count+1);
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);
    ASSERT_EQUAL(testmaster.slave_count, init_slave_count+1);
    int count = 0;
    tpcslave_t* elem;
    CDL_COUNT(testmaster.slaves_head, elem, count);
    ASSERT_EQUAL(count, 1);
    return 1;
}
Exemplo n.º 11
0
int kvstore_multiple_put_get(void) {
  char *retval;
  int ret;
  ret = kvstore_put(&teststore, "KEY1", "VALUE1");
  ret += kvstore_put(&teststore, "KEY2", "VALUE2");
  ret += kvstore_put(&teststore, "KEY3", "VALUE3");
  ret += kvstore_get(&teststore, "KEY1", &retval);
  ASSERT_STRING_EQUAL(retval, "VALUE1");
  free(retval);
  ret += kvstore_get(&teststore, "KEY2", &retval);
  ASSERT_STRING_EQUAL(retval, "VALUE2");
  free(retval);
  ret += kvstore_get(&teststore, "KEY3", &retval);
  ASSERT_STRING_EQUAL(retval, "VALUE3");
  free(retval);
  ASSERT_EQUAL(ret, 0);
  return 1;
}
Exemplo n.º 12
0
int kvstore_put_get_blank_value(void) {
  char *retval;
  int ret;
  ret = kvstore_put(&teststore, "valid key", "");
  ret += kvstore_get(&teststore, "valid key", &retval);
  ASSERT_STRING_EQUAL(retval, "");
  ASSERT_EQUAL(ret, 0);
  free(retval);
  return 1;
}
Exemplo n.º 13
0
int kvstore_put_overwrite(void) {
  char *retval;
  int ret;
  ret = kvstore_put(&teststore, "mykey", "initial value");
  ret += kvstore_put(&teststore, "mykey", "updated value");
  ret += kvstore_get(&teststore, "mykey", &retval);
  ASSERT_STRING_EQUAL(retval, "updated value");
  free(retval);
  ASSERT_EQUAL(ret, 0);
  return 1;
}
Exemplo n.º 14
0
int kvstore_single_put_get(void) {
  char *retval;
  int ret;
  ret = kvstore_put(&teststore, "MYKEY", "MYVALUE");
  ASSERT_EQUAL(ret, 0);
  ret = kvstore_get(&teststore, "MYKEY", &retval);
  ASSERT_EQUAL(ret, 0);
  ASSERT_STRING_EQUAL(retval, "MYVALUE");
  free(retval);
  return 1;
}
Exemplo n.º 15
0
int kvserver_use_cache(void) {
  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY";
  reqmsg.value = "MYVALUE";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  kvserver_clean(&testserver);
  /* Doing a request after deleting the KVStore directory should normally
   * result in an error, but since the key should be in the cache, the store
   * should never be touched. */
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, GETRESP);
  ASSERT_STRING_EQUAL(respmsg.key, "MYKEY");
  ASSERT_STRING_EQUAL(respmsg.value, "MYVALUE");
  return 1;
}
Exemplo n.º 16
0
int kvstore_del_hash_conflicts(void) {
  /* hash("abD") == hash("aae") == hash("ac#") */
  char *retval = NULL, *key1 = "abD", *key2 = "aae", *key3 = "ac#";
  int ret;
  ret = kvstore_put(&teststore, key1, "value1");
  ret += kvstore_put(&teststore, key2, "value2");
  ret += kvstore_put(&teststore, key3, "value3");
  ret += kvstore_del(&teststore, key2);
  ASSERT_EQUAL(ret, 0);
  ret = kvstore_get(&teststore, key2, &retval);
  ASSERT_PTR_NULL(retval);
  ASSERT_EQUAL(ret, ERRNOKEY);
  ret = kvstore_get(&teststore, key1, &retval);
  ASSERT_STRING_EQUAL(retval, "value1");
  free(retval);
  ret += kvstore_get(&teststore, key3, &retval);
  ASSERT_STRING_EQUAL(retval, "value3");
  free(retval);
  ASSERT_EQUAL(ret, 0);
  /* Clean store and do operations again with a different insertion order to
   * help ensure that success wasn't due to a lucky ordering. */
  kvstore_clean(&teststore);
  kvstore_init(&teststore, KVSTORE_DIRNAME);
  ret = kvstore_put(&teststore, key2, "value2");
  ret += kvstore_put(&teststore, key1, "value1");
  ret += kvstore_put(&teststore, key3, "value3");
  ret += kvstore_del(&teststore, key2);
  ASSERT_EQUAL(ret, 0);
  retval = NULL;
  ret = kvstore_get(&teststore, key2, &retval);
  ASSERT_PTR_NULL(retval);
  ASSERT_EQUAL(ret, ERRNOKEY);
  ret = kvstore_get(&teststore, key1, &retval);
  ASSERT_STRING_EQUAL(retval, "value1");
  free(retval);
  ret += kvstore_get(&teststore, key3, &retval);
  ASSERT_STRING_EQUAL(retval, "value3");
  free(retval);
  ASSERT_EQUAL(ret, 0);
  return 1;
}
Exemplo n.º 17
0
int kvstore_get_put_with_hash_conflicts(void) {
  /* hash("abD") == hash("aae") == hash("ac#") */
  char *retval, *key1 = "abD", *key2 = "aae", *key3 = "ac#";
  int ret;
  ret = kvstore_put(&teststore, key1, "value1");
  ret += kvstore_put(&teststore, key2, "value2");
  ret += kvstore_put(&teststore, key3, "value3");
  ret += kvstore_get(&teststore, key1, &retval);
  ASSERT_STRING_EQUAL(retval, "value1");
  free(retval);
  ret += kvstore_get(&teststore, key2, &retval);
  ASSERT_STRING_EQUAL(retval, "value2");
  free(retval);
  ret += kvstore_get(&teststore, key3, &retval);
  ASSERT_STRING_EQUAL(retval, "value3");
  free(retval);
  /* Clean the store and do it again in a different order to ensure that
     the above success wasn't just because of a lucky ordering. */
  kvstore_clean(&teststore);
  kvstore_init(&teststore, KVSTORE_DIRNAME);
  ret = kvstore_put(&teststore, key2, "value2");
  ret += kvstore_put(&teststore, key3, "value3");
  ret += kvstore_put(&teststore, key1, "value1");
  ret += kvstore_get(&teststore, key1, &retval);
  ASSERT_STRING_EQUAL(retval, "value1");
  free(retval);
  ret += kvstore_get(&teststore, key2, &retval);
  ASSERT_STRING_EQUAL(retval, "value2");
  free(retval);
  ret += kvstore_get(&teststore, key3, &retval);
  ASSERT_STRING_EQUAL(retval, "value3");
  free(retval);
  ASSERT_EQUAL(ret, 0);
  return 1;
}
Exemplo n.º 18
0
int kvserver_get_oversized_key(void) {
  char oversized_key[MAX_KEYLEN + 10];
  int i;
  reqmsg.type = GETREQ;
  for (i = 0; i < MAX_KEYLEN + 8; i++)
    oversized_key[i] = 'a';
  oversized_key[i] = '\0';
  reqmsg.key = oversized_key;
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_KEY_LEN);
  return 1;
}
Exemplo n.º 19
0
int kvserver_cache_concurrent_get_cache_writes(void) {
  pthread_rwlock_t *cachelock;
  pthread_t thread;
  kvserver_init(&testserver, KVSERVER_DIRNAME, 1, 2, 1, KVSERVER_HOSTNAME, KVSERVER_PORT, false);
  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY1";
  reqmsg.value = "MYVALUE1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

/* Clear MYKEY1 from the cache */
  reqmsg.key = "MYKEY2";
  reqmsg.value = "MYVALUE2";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg); 
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);
  reqmsg.key = "MYKEY3";
  reqmsg.value = "MYVALUE3";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg); 
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  synch = 0;
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY1";

  cachelock = kvcache_getlock(&testserver.cache, "MYKEY1");
  pthread_rwlock_rdlock(cachelock);
  pthread_create(&thread, NULL, kvserver_concurrent_helper, NULL);
  usleep(1000 * SLEEP_TIME); /* Give the get request a chance to run. */
  ASSERT_EQUAL(synch, 0); /* Ensure the get request didn't complete yet. */
  pthread_rwlock_unlock(cachelock);
  pthread_join(thread, NULL);
  ASSERT_EQUAL(synch, 1); /* Ensure that the get request was able to run after the lock was released. */
  return 1;
}
Exemplo n.º 20
0
int kvstore_del_simple(void) {
  char *retval;
  int ret;
  ret = kvstore_put(&teststore, "key", "val");
  ret += kvstore_get(&teststore, "key", &retval);
  ASSERT_STRING_EQUAL(retval, "val");
  free(retval);
  ret += kvstore_del(&teststore, "key");
  ASSERT_EQUAL(ret, 0);
  retval = NULL;
  ret = kvstore_get(&teststore, "key", &retval);
  ASSERT_EQUAL(ret, ERRNOKEY);
  ASSERT_PTR_NULL(retval);
  return 1;
}
Exemplo n.º 21
0
int kvserver_put_oversized_fields(void) {
  char oversized_key[MAX_KEYLEN + 10], oversized_value[MAX_VALLEN + 10];
  int i;
  for (i = 0; i < MAX_KEYLEN + 8; i++)
    oversized_key[i] = 'a';
  oversized_key[i] = '\0';
  for (i = 0; i < MAX_VALLEN + 8; i++)
    oversized_value[i] = 'a';
  oversized_value[i] = '\0';

  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY";
  reqmsg.value = oversized_value;
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_VAL_LEN);

  reqmsg.key = oversized_key;
  reqmsg.value = "MYVALUE";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_KEY_LEN);
  return 1;
}
Exemplo n.º 22
0
int tpcmaster_register_fail(void) {
    reqmsg.type = REGISTER;
    reqmsg.key = "123.45.67.89";
    reqmsg.value = "1234";
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    reqmsg.value = "2345";
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    reqmsg.value = "3456";
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    reqmsg.value = "4567";
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    reqmsg.value = "5678";
    tpcmaster_register(&testmaster, &reqmsg, &respmsg);
    ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_GENERIC_ERROR);
    return 1;
}
Exemplo n.º 23
0
int tpcmaster_info_check(void) {
    current_test = INFO_SIMPLE;
    tpcmaster_run_test();
    char buf[100], pbuf[10], expected[100];
    strcpy(buf, respmsg.message + strcspn(respmsg.message, "\n") + 1);
    sprintf(pbuf, "%d", SLAVE_PORT);
    strcpy(expected, "Slaves:\n{localhost, ");
    strcat(expected, pbuf);
    strcat(expected, "}\n{localhost, ");
    strcat(expected, pbuf);
    strcat(expected, "}\n{localhost, ");
    strcat(expected, pbuf);
    strcat(expected, "}\n{localhost, ");
    strcat(expected, pbuf);
    strcat(expected, "}");
    ASSERT_STRING_EQUAL(buf, expected);
    return 1;
}
Exemplo n.º 24
0
int kvserver_get_fills_cache(void) {
  kvserver_init(&testserver, KVSERVER_DIRNAME, 1, 2, 1, KVSERVER_HOSTNAME,
      KVSERVER_PORT, false);
  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY1";
  reqmsg.value = "MYVALUE1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  /* Overwrite MYKEY1 in the cache */
  reqmsg.key = "MYKEY2";
  reqmsg.value = "MYVALUE2";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);
  reqmsg.key = "MYKEY3";
  reqmsg.value = "MYVALUE3";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  /* Should bring MYKEY1 back into the cache */
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, GETRESP);
  ASSERT_STRING_EQUAL(respmsg.key, "MYKEY1");
  ASSERT_STRING_EQUAL(respmsg.value, "MYVALUE1");

  kvserver_clean(&testserver);
  /* Doing a request after deleting the KVStore directory should normally
   * result in an error, but since the key should be in the cache, the store
   * should never be touched. */
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, GETRESP);
  ASSERT_STRING_EQUAL(respmsg.key, "MYKEY1");
  ASSERT_STRING_EQUAL(respmsg.value, "MYVALUE1");
  return 1;
}
Exemplo n.º 25
0
int kvserver_cache_concurrent_gets_rdlock(void) {
  pthread_rwlock_t *cachelock;
  pthread_t thread;

  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY";
  reqmsg.value = "MYVALUE";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  synch = 0;
  reqmsg.type = GETREQ;

  cachelock = kvcache_getlock(&testserver.cache, "MYKEY");
  pthread_rwlock_rdlock(cachelock);
  pthread_create(&thread, NULL, kvserver_concurrent_helper, NULL);
  usleep(1000 * SLEEP_TIME); /* Give the get request a chance to run. */
  ASSERT_EQUAL(synch, 1); /* Ensure the get request was able to complete already. */
  pthread_rwlock_unlock(cachelock);
  pthread_join(thread, NULL);
  return 1;
}
Exemplo n.º 26
0
int tpcmaster_del_simple(void) {
    current_test = DEL_SIMPLE;
    tpcmaster_run_test();
    ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);
    return 1;
}
Exemplo n.º 27
0
kvserver_get_from_store(void) {
  kvserver_init(&testserver, KVSERVER_DIRNAME, 1, 2, 1, KVSERVER_HOSTNAME,
      KVSERVER_PORT, false);

  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY1";
  reqmsg.value = "MYVALUE1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  /* Get is successful since MYKEY1 is in the cache and in store */
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, GETRESP);
  ASSERT_STRING_EQUAL(respmsg.key, "MYKEY1");
  ASSERT_STRING_EQUAL(respmsg.value, "MYVALUE1");

  /* Overwrite MYKEY1 in the cache */
  reqmsg.type = PUTREQ;
  reqmsg.key = "MYKEY2";
  reqmsg.value = "MYVALUE2";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  /* Remove MYKEY2 in the cache and the store. */
  reqmsg.type = DELREQ;
  reqmsg.key = "MYKEY2";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, MSG_SUCCESS);

  /* The cache should be empty, and the store should have MYKEY1.  Get MYKEY1 should successfully return the value from store */
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, GETRESP);
  ASSERT_STRING_EQUAL(respmsg.key, "MYKEY1");
  ASSERT_STRING_EQUAL(respmsg.value, "MYVALUE1");

  /* Clear the store.  MYKEY1 should not be in the store, but should be in the cache since the GET above should put it in the cache. */
  kvserver_clean(&testserver);
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, GETRESP);
  ASSERT_STRING_EQUAL(respmsg.key, "MYKEY1");
  ASSERT_STRING_EQUAL(respmsg.value, "MYVALUE1");

  /* Clear the cache.  Now the cache is empty, and the store contains only MYKEY1.  Clear the store and make sure get MYKEY1 fails.  Should be an ERRFILACCESS since kvserver_clean deletes the store.  This gets convereted to an ERRMSG_GENERIC_ERROR. */
  kvcache_clear(&testserver.cache);
  kvserver_clean(&testserver);
  
  reqmsg.type = GETREQ;
  reqmsg.key = "MYKEY1";
  kvserver_handle_no_tpc(&testserver, &reqmsg, &respmsg);
  ASSERT_EQUAL(respmsg.type, RESP);
  ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_GENERIC_ERROR);
  return 1;
}
Exemplo n.º 28
0
int tpcmaster_get_fail(void) {
    current_test = GET_FAIL;
    tpcmaster_run_test();
    ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_NO_KEY);
    return 1;
}
Exemplo n.º 29
0
int tpcmaster_put_fail(void) {
    current_test = PUT_FAIL;
    tpcmaster_run_test();
    ASSERT_STRING_EQUAL(respmsg.message, ERRMSG_GENERIC_ERROR);
    return 1;
}