Exemple #1
0
static void run(const int id, const char *server, const int value_length,
			const int requests, const int command)
{
	char key[20];
	char *value;
	int i;
	struct st_client *stc;
	bool ret;

	value = xmalloc(value_length);
	memset(value, '*', value_length);

	stc = stc_new2(server);
	if (!stc)
		die("stc_new failed");

	ret = stc_table_openz(stc, "testtable",
			command == 'w' ? CHF_TBL_CREAT : 0);
	if (!ret)
		die("stc_table_openz failed");

	for (i =  0; i < requests; i++) {
		sprintf(key, "%04d-%011d", id, i);

		if (command == 'w')
			do_chunkd_set(stc, key, 16, value, value_length);
		else
			do_chunkd_get(stc, key, 16);
	}
	stc_free(stc);
	free(value);
}
Exemple #2
0
static void test(bool do_encrypt)
{
	struct st_object *obj;
	struct st_keylist *klist;
	struct st_client *stc;
	int port;
	bool rcb;
	char val[] = "my first value";
	char key[64] = "deadbeef";
	size_t len = 0;
	void *mem;

	port = hail_readport(TEST_PORTFILE);
	OK(port > 0);

	stc = stc_new(TEST_HOST, port, TEST_USER, TEST_USER_KEY, do_encrypt);
	OK(stc);

	rcb = stc_table_openz(stc, TEST_TABLE, 0);
	OK(rcb);

	/* store object */
	rcb = stc_put_inlinez(stc, key, val, strlen(val), 0);
	OK(rcb);

	/* make sure object appears in list of volume keys */
	klist = stc_keys(stc);
	OK(klist);
	OK(klist->contents);
	OK(klist->contents->next == NULL);

	obj = klist->contents->data;
	OK(obj);
	OK(obj->name);
	OK(!strcmp(obj->name, key));
	OK(obj->time_mod);
	OK(obj->etag);
	OK(obj->size == strlen(val));
	OK(obj->owner);

	stc_free_keylist(klist);

	/* get object */
	mem = stc_get_inlinez(stc, key, &len);
	OK(mem);
	OK(len == strlen(val));
	OK(!memcmp(val, mem, strlen(val)));

	free(mem);

	/* delete object */
	rcb = stc_delz(stc, key);
	OK(rcb);

	stc_free(stc);
}