Пример #1
0
int
main(int argc, char *argv[])
{
	TEST_OPTS *opts, _opts;
	TEST_PER_THREAD_OPTS thread_args[N_THREADS];
	pthread_t ckpt_thread, mon_thread, threads[N_THREADS];
	int i;

	/*
	 * This test should not run unless long tests flag is set. The test
	 * runs for 15 minutes.
	 */
	if (!testutil_is_flag_set("TESTUTIL_ENABLE_TIMING_TESTS"))
		return (EXIT_SUCCESS);

	opts = &_opts;
	opts->unique_id = 0;
	memset(opts, 0, sizeof(*opts));

	testutil_check(testutil_parse_opts(argc, argv, opts));
	testutil_make_work_dir(opts->home);

	testutil_check(wiredtiger_open(opts->home, &event_handler,
	    "create,cache_size=1G,timing_stress_for_test=[checkpoint_slow]",
	    &opts->conn));

	testutil_check(pthread_create(
	    &ckpt_thread, NULL, do_checkpoints, opts));

	for (i = 0; i < N_THREADS; ++i) {
		thread_args[i].testopts = opts;
		thread_args[i].thread_counter = 0;
		thread_args[i].threadnum = i;
		testutil_check(pthread_create(
		    &threads[i], NULL, do_ops, &thread_args[i]));
	}

	/*
	 * Pass the whole array of thread arguments to the monitoring thread.
	 * This thread will need to monitor each threads counter to track if it
	 * is stuck.
	 */
	testutil_check(pthread_create(&mon_thread, NULL, monitor, thread_args));

	for (i = 0; i < N_THREADS; ++i)
		testutil_check(pthread_join(threads[i], NULL));

	testutil_check(pthread_join(mon_thread, NULL));

	testutil_check(pthread_join(ckpt_thread, NULL));

	printf("Success\n");

	testutil_cleanup(opts);
	return (EXIT_SUCCESS);
}
Пример #2
0
/*
 * main --
 *	The main program for the test. When invoked with "subtest"
 *	argument, run the subtest. Otherwise, run a separate process
 *	for each needed subtest, and check the results.
 */
int
main(int argc, char *argv[])
{
	TEST_OPTS *opts, _opts;
	uint64_t nresults;
	const char *debugger;

	/* Ignore unless requested */
	if (!testutil_is_flag_set("TESTUTIL_ENABLE_LONG_TESTS"))
		return (EXIT_SUCCESS);

	opts = &_opts;
	memset(opts, 0, sizeof(*opts));
	debugger = NULL;

	testutil_check(testutil_parse_opts(argc, argv, opts));
	argc -= __wt_optind;
	argv += __wt_optind;
	if (opts->nrecords == 0)
		opts->nrecords = 50000;

	while (argc > 0) {
		if (strcmp(argv[0], "subtest") == 0) {
			subtest_main(argc, argv, false);
			return (0);
		} else if (strcmp(argv[0], "subtest_close") == 0) {
			subtest_main(argc, argv, true);
			return (0);
		} else if (strcmp(argv[0], "gdb") == 0)
			debugger = "/usr/bin/gdb";
		else
			testutil_assert(false);
		argc--;
		argv++;
	}
	if (opts->verbose) {
		printf("Number of operations until failure: %" PRIu64
		    "  (change with -o N)\n", opts->nops);
		printf("Number of records: %" PRIu64
		    "  (change with -n N)\n", opts->nrecords);
	}
	if (opts->nops == 0) {
		run_check_subtest_range(opts, debugger, false);
		run_check_subtest_range(opts, debugger, true);
	} else
		run_check_subtest(opts, debugger, opts->nops,
		    opts->nrecords, &nresults);

	testutil_clean_work_dir(opts->home);
	testutil_cleanup(opts);

	return (0);
}
Пример #3
0
int
main(int argc, char *argv[])
{
	WT_SESSION *session;
	clock_t ce, cs;
	pthread_t idlist[100];
	uint64_t i, id;
	char buf[100];

	/* Bypass this test for valgrind */
	if (testutil_is_flag_set("TESTUTIL_BYPASS_VALGRIND"))
		return (EXIT_SUCCESS);

	opts = &_opts;
	memset(opts, 0, sizeof(*opts));
	opts->table_type = TABLE_ROW;
	opts->n_append_threads = N_APPEND_THREADS;
	opts->nrecords = N_RECORDS;
	testutil_check(testutil_parse_opts(argc, argv, opts));
	testutil_make_work_dir(opts->home);

	testutil_check(__wt_snprintf(buf, sizeof(buf),
	    "create,"
	    "cache_size=%s,"
	    "eviction=(threads_max=5),"
	    "statistics=(fast)",
	    opts->table_type == TABLE_FIX ? "500MB" : "2GB"));
	testutil_check(wiredtiger_open(opts->home, NULL, buf, &opts->conn));
	testutil_check(
	    opts->conn->open_session(opts->conn, NULL, NULL, &session));
	testutil_check(__wt_snprintf(buf, sizeof(buf),
	    "key_format=r,value_format=%s,"
	    "allocation_size=4K,leaf_page_max=64K",
	    opts->table_type == TABLE_FIX ? "8t" : "S"));
	testutil_check(session->create(session, opts->uri, buf));
	testutil_check(session->close(session, NULL));

	page_init(5000);

	/* Force to disk and re-open. */
	testutil_check(opts->conn->close(opts->conn, NULL));
	testutil_check(wiredtiger_open(opts->home, NULL, NULL, &opts->conn));

	(void)signal(SIGINT, onsig);

	cs = clock();
	id = 0;
	for (i = 0; i < opts->n_append_threads; ++i, ++id) {
		printf("append: %" PRIu64 "\n", id);
		testutil_check(
		    pthread_create(&idlist[id], NULL, thread_append, opts));
	}

	for (i = 0; i < id; ++i)
		testutil_check(pthread_join(idlist[i], NULL));

	ce = clock();
	printf("%" PRIu64 "M records: %.2lf processor seconds\n",
	    opts->max_inserted_id / MILLION,
	    (ce - cs) / (double)CLOCKS_PER_SEC);

	testutil_cleanup(opts);
	return (EXIT_SUCCESS);
}
Пример #4
0
int
main(int argc, char *argv[])
{
	static const struct {
		u_int workers;
		u_int uris;
		bool  cache_cursors;
	} runs[] = {
		{  1,   1, false},
		{  1,   1, true},
		{  8,   1, false},
		{  8,   1, true},
		{ 16,   1, false},
		{ 16,   1, true},
		{ 16,   WT_ELEMENTS(uri_list), false},
		{ 16,   WT_ELEMENTS(uri_list), true},
		{200, 100, false},
		{200, 100, true},
		{200, WT_ELEMENTS(uri_list), false},
		{200, WT_ELEMENTS(uri_list), true},
		{300, 100, false},
		{300, 100, true},
		{600, WT_ELEMENTS(uri_list), false},
		{600, WT_ELEMENTS(uri_list), true},
	};
	WT_RAND_STATE rnd;
	u_int i, n;
	int ch;

	/*
	 * Bypass this test for valgrind. It has a fairly low thread limit.
	 */
	if (testutil_is_flag_set("TESTUTIL_BYPASS_VALGRIND"))
		return (EXIT_SUCCESS);

	(void)testutil_set_progname(argv);
	__wt_random_init_seed(NULL, &rnd);

	while ((ch = __wt_getopt(argv[0], argc, argv, "v")) != EOF) {
		switch (ch) {
		case 'v':
			verbose = true;
			break;
		default:
			fprintf(stderr, "usage: %s [-v]\n", argv[0]);
			return (EXIT_FAILURE);
		}
	}

	(void)signal(SIGALRM, on_alarm);

	/* Each test in the table runs for a minute, run 5 tests at random. */
	for (i = 0; i < 5; ++i) {
		n = __wt_random(&rnd) % WT_ELEMENTS(runs);
		workers = runs[n].workers;
		uris = runs[n].uris;
		run(runs[n].cache_cursors);
	}

	uri_teardown();

	return (EXIT_SUCCESS);
}