Beispiel #1
0
TEST(tfw_sched_hash, max_srv_in_sg_and_zero_conn)
{
	int i, j;

	TfwSrvGroup *sg = test_create_sg("test", "hash");

	for (i = 0; i < TFW_SG_MAX_SRV; ++i) {
		test_create_srv("127.0.0.1", sg);
	}

	for (i = 0; i < req_strs_size; ++i) {
		for (j = 0; j < 2 * TFW_SG_MAX_SRV; ++j) {
			TfwConnection *conn;
			TfwHttpReq *req = test_req_alloc(strlen(req_strs[i]));

			tfw_http_parse_req(req, req_strs[i], strlen(req_strs[i]));

			conn = sg->sched->sched_srv((TfwMsg *)req, sg);
			EXPECT_TRUE(conn == NULL);

			test_req_free(req);
		}
	}

	test_sg_release_all();
}
Beispiel #2
0
static void
http_match_suite_setup(void)
{
	test_req = test_req_alloc();
	test_mlst = tfw_http_match_list_alloc();
	BUG_ON(!test_mlst);

}
Beispiel #3
0
TEST(tfw_sched_hash, sg_empty)
{
	int i, j;

	TfwSrvGroup *sg = test_create_sg("test", "hash");

	for (i = 0; i < req_strs_size; ++i) {
		for (j = 0; j < 3; ++j) {
			TfwConnection *conn;
			TfwHttpReq *req = test_req_alloc(strlen(req_strs[i]));

			tfw_http_parse_req_ptr(req, req_strs[i], strlen(req_strs[i]));

			conn = sg->sched->sched_srv((TfwMsg *)req, sg);
			EXPECT_TRUE(conn == NULL);

			test_req_free(req);
		}
	}

	test_sg_release_all();
}
Beispiel #4
0
TEST(tfw_sched_hash, max_srv_in_sg_and_max_conn)
{
	int i, j;

	TfwSrvGroup *sg = test_create_sg("test", "hash");

	for (i = 0; i < TFW_SG_MAX_SRV; ++i) {
		TfwServer *srv = test_create_srv("127.0.0.1", sg);

		for (j = 0; j < TFW_SRV_MAX_CONN; ++j) {
			test_create_conn((TfwPeer *)srv);
		}
	}
	sg->sched->update_grp(sg);

	for (i = 0; i < req_strs_size; ++i) {
		TfwConnection *s = NULL;

		for (j = 0; j < 3 * TFW_SG_MAX_SRV * TFW_SRV_MAX_CONN; ++j) {
			TfwConnection *conn;
			TfwHttpReq *req = test_req_alloc(strlen(req_strs[i]));

			tfw_http_parse_req(req, req_strs[i], strlen(req_strs[i]));

			conn = sg->sched->sched_srv((TfwMsg *)req, sg);
			if (!s) {
				s = conn;
			} else {
				EXPECT_TRUE(conn == s);
			}

			test_req_free(req);
			tfw_connection_put(conn);
		}
	}

	test_conn_release_all(sg);
	test_sg_release_all();
}