コード例 #1
0
ファイル: kerb.c プロジェクト: pombredanne/hadoofus
int
main(int argc, char **argv)
{
	int r;
	int64_t res;
	struct hdfs_object *exception = NULL, *dl;

	r = sasl_client_init(NULL);
	if (r != SASL_OK) {
		fprintf(stderr, "Error initializing sasl: %d\n", r);
		return -1;
	}

	if (argc > 1) {
		if (strcmp(argv[1], "-h") == 0) {
			printf("Usage: ./kerb [host [port [kerb_principal]]]\n");
			exit(0);
		}
		host = argv[1];
		if (argc > 2) {
			port = argv[2];
			if (argc > 3) {
				user = argv[3];
			}
		}
	}

	h = hdfs_namenode_new(host, port, user, HDFS_REQUIRE_KERB, &err);
	if (!h)
		goto out;

	res = hdfs_getProtocolVersion(h, HADOOFUS_CLIENT_PROTOCOL_STR, 61L,
	    &exception);
	if (exception) {
		err = exception->ob_val._exception._msg;
		goto out;
	}

	if (res != 61)
		fprintf(stderr, "protocol version != 61: %zd\n", (intmax_t)res);
	else
		fprintf(stderr, "success\n");

	dl = hdfs_getListing(h, "/", NULL, &exception);
	if (exception) {
		err = exception->ob_val._exception._msg;
		goto out;
	}

	hdfs_object_free(dl);
	fprintf(stderr, "dl: success\n");

out:
	if (err)
		fprintf(stderr, "hadoofus error: %s\n", err);
	if (h)
		hdfs_namenode_delete(h);
	sasl_done();
	return 0;
}
コード例 #2
0
ファイル: hl-hello.c プロジェクト: 13141516/hadoofus
int
main(int argc, char **argv)
{
	int64_t res;
	struct hdfs_object *exception = NULL;

	if (argc > 1) {
		if (strcmp(argv[1], "-h") == 0) {
			printf("Usage: ./hl-hello [host [port [user]]]\n");
			exit(0);
		}
		host = argv[1];
		if (argc > 2) {
			port = argv[2];
			if (argc > 3) {
				user = argv[3];
			}
		}
	}

	h = hdfs_namenode_new(host, port, user, HDFS_NO_KERB, &error);
	if (!h)
		goto out;

	res = hdfs_getProtocolVersion(h, HADOOFUS_CLIENT_PROTOCOL_STR, 61L,
	    &exception);
	if (exception) {
		error = exception->ob_val._exception._msg;
		goto out;
	}

	if (res != 61)
		fprintf(stderr, "protocol version != 61: %zd\n", (intmax_t)res);
	else
		fprintf(stderr, "success\n");

out:
	if (error)
		fprintf(stderr, "hadoofus error: %s\n", error);
	if (h)
		hdfs_namenode_delete(h);
	return 0;
}
コード例 #3
0
ファイル: t_main.c プロジェクト: cemeyer/hadoofus
int
main(int argc, char **argv)
{
	int64_t proto_ver;
	struct hdfs_error error;
	struct hdfs_namenode *nn;
	struct hdfs_object *exception = NULL;
	bool success = true;
	Suite *(*suites[])(void) = {
		t_hl_rpc_basics_suite,
		t_hl_rpc2_basics_suite,
		t_datanode_basics_suite,
		t_datanode2_basics_suite,
		t_unit,
	};
	int rc;

	if (!getenv(HDFS_T_ENV))
		errx(EXIT_FAILURE,
		    "Please set %s to an HDFS host before running tests!",
		    HDFS_T_ENV);

	rc = sasl_client_init(NULL);
	assert(rc == SASL_OK);

	H_ADDR = strdup(getenv(HDFS_T_ENV));
	assert(H_ADDR);

	if (getenv(HDFS_T_USER)) {
		H_USER = strdup(getenv(HDFS_T_USER));
		assert(H_USER);
	}

	// Test basic connectivity
	nn = hdfs_namenode_new_version(H_ADDR, "8020", "root", HDFS_NO_KERB,
	    HDFS_NN_v1, &error);
	if (!nn)
		errx(EXIT_FAILURE,
		    "Could not connect to namenode %s: %s",
		    H_ADDR, format_error(error));

	// And verify liveness at a protocol level
	proto_ver = hdfs_getProtocolVersion(nn, HADOOFUS_CLIENT_PROTOCOL_STR,
	    61L, &exception);
	if (exception)
		errx(EXIT_FAILURE,
		    "getProtocolVersion failed: %s",
		    hdfs_exception_get_message(exception));
	if (proto_ver != 61L)
		errx(EXIT_FAILURE,
		    "Got unexpected protocol version: %ld", proto_ver);

	hdfs_namenode_delete(nn);

	// Find and run all tests
	for (size_t i = 0; i < nelem(suites); i++) {
		Suite *s = suites[i]();
		SRunner *sr = srunner_create(s);

		srunner_run_all(sr, CK_NORMAL);

		if (srunner_ntests_failed(sr) > 0)
			success = false;

		srunner_free(sr);
	}

	if (success)
		return EXIT_SUCCESS;
	return EXIT_FAILURE;
}