Ejemplo n.º 1
0
	virtual void* run()
	{
		bool ret;
		acl::redis_client* conn;
		acl::redis_key redis;

		for (int i = 0; i < n_; i++)
		{
			conn = (acl::redis_client*) pool_.peek();
			
			if (conn == NULL)
			{
				printf("peek redis_client failed\r\n");
				break;
			}

			redis.set_client(conn);

			if (cmd_ == "del")
				ret = test_del(redis, i);
			else if (cmd_ == "expire")
				ret = test_expire(redis, i);
			else if (cmd_ == "ttl")
				ret = test_ttl(redis, i);
			else if (cmd_ == "exists")
				ret = test_exists(redis, i);
			else if (cmd_ == "type")
				ret = test_type(redis, i);
			else if (cmd_ == "all")
			{
				if (test_expire(redis, i) == false
					|| test_ttl(redis, i) == false
					|| test_exists(redis, i) == false
					|| test_type(redis, i) == false
					|| test_del(redis, i) == false)
				{
					ret = false;
				}
				else
					ret = true;
			}
			else
			{
				printf("unknown cmd: %s\r\n", cmd_.c_str());
				break;
			}
			pool_.put(conn, ret);
			if (ret == false)
				break;
		}

		return NULL;
	}
Ejemplo n.º 2
0
	virtual void* run()
	{
		bool ret;
		acl::redis cmd;
		cmd.set_cluster(&cluster_, max_conns_);

		for (int i = 0; i < n_; i++)
		{
			if (cmd_ == "set")
				ret = test_set(cmd, i);
			else if (cmd_ == "get")
				ret = test_get(cmd, i);
			else if (cmd_ == "del")
				ret = test_del(cmd, i);
			else if (cmd_ == "expire")
				ret = test_expire(cmd, i);
			else if (cmd_ == "ttl")
				ret = test_ttl(cmd, i);
			else if (cmd_ == "exists")
				ret = test_exists(cmd, i);
			else if (cmd_ == "type")
				ret = test_type(cmd, i);
			else if (cmd_ == "all")
			{
				if (test_set(cmd, i) == false
					|| test_get(cmd, i) == false
					|| test_exists(cmd, i) == false
					|| test_type(cmd, i) == false
					|| test_expire(cmd, i) == false
					|| test_ttl(cmd, i) == false
					|| test_del(cmd, i) == false)
				{
					ret = false;
				}
				else
					ret = true;
			}
			else
			{
				printf("unknown cmd: %s\r\n", cmd_.c_str());
				break;
			}

			if (ret == false)
			{
				printf("cmd: %s error, tid: %lu\r\n",
					cmd_.c_str(), thread_self());
				break;
			}

			if (i > 0 && i % 1000 == 0)
			{
				char tmp[128];
				acl::safe_snprintf(tmp, sizeof(tmp), "%d", i);
				acl::meter_time(__FILE__, __LINE__, tmp);
			}
		}

		locker_.lock();
		__threads_exit++;
		locker_.unlock();

		return NULL;
	}
Ejemplo n.º 3
0
	virtual void* run()
	{
		bool ret;
		acl::redis_client_pool* pool;
		acl::redis_client* conn;
		acl::redis_key option;

		for (int i = 0; i < n_; i++)
		{
			pool = (acl::redis_client_pool*) manager_.peek();
			if (pool == NULL)
			{
				printf("peek connection pool failed\r\n");
				break;
			}

			conn = (acl::redis_client*) pool->peek();
			
			if (conn == NULL)
			{
				printf("peek redis_client failed\r\n");
				break;
			}

			option.set_client(conn);

			if (cmd_ == "del")
				ret = test_del(option, i);
			else if (cmd_ == "expire")
				ret = test_expire(option, i);
			else if (cmd_ == "ttl")
				ret = test_ttl(option, i);
			else if (cmd_ == "exists")
				ret = test_exists(option, i);
			else if (cmd_ == "type")
				ret = test_type(option, i);
			else if (cmd_ == "all")
			{
				if (test_expire(option, i) == false
					|| test_ttl(option, i) == false
					|| test_exists(option, i) == false
					|| test_type(option, i) == false
					|| test_del(option, i) == false)
				{
					ret = false;
				}
				else
					ret = true;
			}
			else
			{
				printf("unknown cmd: %s\r\n", cmd_.c_str());
				break;
			}

			pool->put(conn, ret);

			if (ret == false)
				break;
		}

		return NULL;
	}
Ejemplo n.º 4
0
int
main(void) {
  test_exists();
  return EXIT_SUCCESS;
}
Ejemplo n.º 5
0
int main(int argc, char* argv[])
{
	int  ch, n = 1, conn_timeout = 10, rw_timeout = 10;
	acl::string addr("127.0.0.1:6379"), cmd;

	while ((ch = getopt(argc, argv, "hs:n:C:T:a:")) > 0)
	{
		switch (ch)
		{
		case 'h':
			usage(argv[0]);
			return 0;
		case 's':
			addr = optarg;
			break;
		case 'n':
			n = atoi(optarg);
			break;
		case 'C':
			conn_timeout = atoi(optarg);
			break;
		case 'T':
			rw_timeout = atoi(optarg);
			break;
		case 'a':
			cmd = optarg;
			break;
		default:
			break;
		}
	}

	acl::acl_cpp_init();
	acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout);
	acl::redis_key redis(&client);

	bool ret;

	if (cmd == "del")
		ret = test_del(redis, n);
	else if (cmd == "expire")
		ret = test_expire(redis, n);
	else if (cmd == "ttl")
		ret = test_ttl(redis, n);
	else if (cmd == "exists")
		ret = test_exists(redis, n);
	else if (cmd == "type")
		ret = test_type(redis, n);
	else if (cmd == "all")
	{
		ret = test_expire(redis, n)
			&& test_ttl(redis, n)
			&& test_exists(redis, n)
			&& test_type(redis, n)
			&& test_del(redis, n);
	}
	else
	{
		ret = false;
		printf("unknown cmd: %s\r\n", cmd.c_str());
	}

	if (ret == true)
		printf("test OK!\r\n");
	else
		printf("test failed!\r\n");

#ifdef WIN32
	printf("enter any key to exit\r\n");
	getchar();
#endif
	return 0;
}
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
	FILE *cgf;
	bool found_zdtmtstroot = false, found_newroot = false;
	char paux[1024];
	int ret = -1;

	test_init(argc, argv);

	if (mount_and_add(cgname, subname))
		goto out;
	if (mount_and_add(cgname2, subname)) {
		sprintf(paux, "%s/%s", dirname, cgname);
		umount(paux);
		rmdir(paux);
		goto out;
	}

	test_daemon();
	test_waitsig();

	cgf = fopen("/proc/self/mountinfo", "r");
	if (cgf == NULL) {
		fail("No mountinfo file");
		goto out_umount;
	}

	while (fgets(paux, sizeof(paux), cgf)) {
		char *s;

		s = strstr(paux, cgname);
		if (s && test_exists(paux, "zdtmtstroot")) {
			found_zdtmtstroot = true;
		}

		s = strstr(paux, cgname2);
		if (s && test_exists(paux, "newroot")) {
			found_newroot = true;
		}
	}

	if (!found_zdtmtstroot) {
		fail("oldroot not rewritten to zdtmtstroot!\n");
		goto out_close;
	}

	if (!found_newroot) {
		fail("oldroot not rewritten to newroot!\n");
		goto out_close;
	}

	pass();
	ret = 0;


out_close:
	fclose(cgf);
out_umount:
	sprintf(paux, "%s/%s", dirname, cgname);
	umount(paux);
	rmdir(paux);

	sprintf(paux, "%s/%s", dirname, cgname2);
	umount(paux);
	rmdir(paux);
out:
	return ret;
}