1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci
3f08c3bdfSopenharmony_ci# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
4f08c3bdfSopenharmony_ci# Copyright (c) International Business Machines  Corp., 2005
5f08c3bdfSopenharmony_ci#
6f08c3bdfSopenharmony_ci# This program is free software; you can redistribute it and/or
7f08c3bdfSopenharmony_ci# modify it under the terms of the GNU General Public License as
8f08c3bdfSopenharmony_ci# published by the Free Software Foundation; either version 2 of
9f08c3bdfSopenharmony_ci# the License, or (at your option) any later version.
10f08c3bdfSopenharmony_ci#
11f08c3bdfSopenharmony_ci# This program is distributed in the hope that it would be useful,
12f08c3bdfSopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of
13f08c3bdfSopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14f08c3bdfSopenharmony_ci# GNU General Public License for more details.
15f08c3bdfSopenharmony_ci#
16f08c3bdfSopenharmony_ci# You should have received a copy of the GNU General Public License
17f08c3bdfSopenharmony_ci# along with this program; if not, write the Free Software Foundation,
18f08c3bdfSopenharmony_ci# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19f08c3bdfSopenharmony_ci#
20f08c3bdfSopenharmony_ci# Author: Mitsuru Chinen <mitch@jp.ibm.com>
21f08c3bdfSopenharmony_ci
22f08c3bdfSopenharmony_ciTCID=http-stress
23f08c3bdfSopenharmony_ciTST_TOTAL=2
24f08c3bdfSopenharmony_ciTST_CLEANUP="cleanup"
25f08c3bdfSopenharmony_ci
26f08c3bdfSopenharmony_ciTST_USE_LEGACY_API=1
27f08c3bdfSopenharmony_ci
28f08c3bdfSopenharmony_cicleanup()
29f08c3bdfSopenharmony_ci{
30f08c3bdfSopenharmony_ci	rm -f $HTTP_DOWNLOAD_DIR/http_file
31f08c3bdfSopenharmony_ci}
32f08c3bdfSopenharmony_ci
33f08c3bdfSopenharmony_cisetup()
34f08c3bdfSopenharmony_ci{
35f08c3bdfSopenharmony_ci	tst_require_root
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_ci	tst_resm TINFO "run over IPv$TST_IPVER"
38f08c3bdfSopenharmony_ci
39f08c3bdfSopenharmony_ci	trap "tst_brkm TBROK 'test interrupted'" INT
40f08c3bdfSopenharmony_ci
41f08c3bdfSopenharmony_ci	[ -d "$HTTP_DOWNLOAD_DIR" ] || \
42f08c3bdfSopenharmony_ci		tst_brkm TCONF "Start server manually, set HTTP_DOWNLOAD_DIR"
43f08c3bdfSopenharmony_ci
44f08c3bdfSopenharmony_ci	# As the apache with normal setting cannot handle the file whose size
45f08c3bdfSopenharmony_ci	# is bigger than or equal to 2G byte. Therefore, the file size is
46f08c3bdfSopenharmony_ci	# resetted into 2G - 1 byte."
47f08c3bdfSopenharmony_ci	if [ $DOWNLOAD_BIGFILESIZE -gt 2147483647 ]; then
48f08c3bdfSopenharmony_ci		tst_resm TINFO "Setting file size to 2G - 1 byte"
49f08c3bdfSopenharmony_ci		DOWNLOAD_BIGFILESIZE=2147483647
50f08c3bdfSopenharmony_ci	fi
51f08c3bdfSopenharmony_ci
52f08c3bdfSopenharmony_ci	create_file $HTTP_DOWNLOAD_DIR/http_file $DOWNLOAD_BIGFILESIZE || \
53f08c3bdfSopenharmony_ci		tst_resm TBROK "Failed to create test file"
54f08c3bdfSopenharmony_ci}
55f08c3bdfSopenharmony_ci
56f08c3bdfSopenharmony_citest01()
57f08c3bdfSopenharmony_ci{
58f08c3bdfSopenharmony_ci	tst_resm TINFO "http client download test file"
59f08c3bdfSopenharmony_ci
60f08c3bdfSopenharmony_ci	tst_rhost_run -s -c "http-stress01-rmt.sh $(tst_ipaddr) \
61f08c3bdfSopenharmony_ci		http_file $DOWNLOAD_BIGFILESIZE"
62f08c3bdfSopenharmony_ci
63f08c3bdfSopenharmony_ci	tst_resm TPASS "Test is finished successfully"
64f08c3bdfSopenharmony_ci}
65f08c3bdfSopenharmony_ci
66f08c3bdfSopenharmony_citest02()
67f08c3bdfSopenharmony_ci{
68f08c3bdfSopenharmony_ci	tst_resm TINFO "clients request data asynchronously $NS_DURATION sec"
69f08c3bdfSopenharmony_ci
70f08c3bdfSopenharmony_ci	tst_rhost_run -s -c "http-stress02-rmt.sh $(tst_ipaddr) http_file \
71f08c3bdfSopenharmony_ci		$DOWNLOAD_BIGFILESIZE $NS_DURATION $CONNECTION_TOTAL"
72f08c3bdfSopenharmony_ci
73f08c3bdfSopenharmony_ci	tst_resm TPASS "Test is finished successfully"
74f08c3bdfSopenharmony_ci}
75f08c3bdfSopenharmony_ci
76f08c3bdfSopenharmony_ci. tst_net.sh
77f08c3bdfSopenharmony_cisetup
78f08c3bdfSopenharmony_citest01
79f08c3bdfSopenharmony_citest02
80f08c3bdfSopenharmony_citst_exit
81