[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33887 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33887 - gnunet/src/transport |
Date: |
Tue, 1 Jul 2014 05:13:16 +0200 |
Author: amatus
Date: 2014-07-01 05:13:16 +0200 (Tue, 01 Jul 2014)
New Revision: 33887
Added:
gnunet/src/transport/test_transport_api_reliability_http_xhr_peer1.conf
gnunet/src/transport/test_transport_api_reliability_http_xhr_peer2.conf
gnunet/src/transport/test_transport_api_reliability_https_xhr_peer1.conf
gnunet/src/transport/test_transport_api_reliability_https_xhr_peer2.conf
Modified:
gnunet/src/transport/Makefile.am
gnunet/src/transport/plugin_transport_http_client.c
Log:
Add HTTP transport tests with XHR client emulation
These tests don't pass currently but I ran them against a hacked
version of the HTTP server which never calls server_delete_session
and they passed.
Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am 2014-06-30 14:17:28 UTC (rev 33886)
+++ gnunet/src/transport/Makefile.am 2014-07-01 03:13:16 UTC (rev 33887)
@@ -30,13 +30,15 @@
HTTP_API_TEST = test_transport_api_http
HTTP_REVERSE_API_TEST = test_transport_api_http_reverse
HTTP_API_TIMEOUT_TEST = test_transport_api_timeout_http
- HTTP_REL_TEST = test_transport_api_reliability_http
+ HTTP_REL_TEST = test_transport_api_reliability_http \
+ test_transport_api_reliability_http_xhr
HTTP_QUOTA_TEST = test_quota_compliance_http \
test_quota_compliance_http_asymmetric
HTTP_SWITCH = test_transport_address_switch_http
HTTPS_API_TEST = test_transport_api_https
HTTPS_API_TIMEOUT_TEST = test_transport_api_timeout_https
- HTTPS_REL_TEST = test_transport_api_reliability_https
+ HTTPS_REL_TEST = test_transport_api_reliability_https \
+ test_transport_api_reliability_https_xhr
HTTPS_QUOTA_TEST = test_quota_compliance_https \
test_quota_compliance_https_asymmetric
HTTPS_SWITCH = test_transport_address_switch_https
@@ -933,6 +935,14 @@
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
+test_transport_api_reliability_http_xhr_SOURCES = \
+ test_transport_api_reliability.c
+test_transport_api_reliability_http_xhr_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
test_quota_compliance_http_SOURCES = \
test_quota_compliance.c
test_quota_compliance_http_LDADD = \
@@ -991,6 +1001,14 @@
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
+test_transport_api_reliability_https_xhr_SOURCES = \
+ test_transport_api_reliability.c
+test_transport_api_reliability_https_xhr_LDADD = \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/hello/libgnunethello.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/transport/libgnunettransporttesting.la
+
test_transport_api_reliability_unix_SOURCES = \
test_transport_api_reliability.c
test_transport_api_reliability_unix_LDADD = \
Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2014-06-30 14:17:28 UTC
(rev 33886)
+++ gnunet/src/transport/plugin_transport_http_client.c 2014-07-01 03:13:16 UTC
(rev 33887)
@@ -353,6 +353,10 @@
*/
uint16_t use_ipv4;
+ /**
+ * Should we emulate an XHR client for testing?
+ */
+ int emulate_xhr;
};
@@ -649,6 +653,16 @@
/**
+ * Connect GET connection for a session
+ *
+ * @param s the session to connect
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
+ */
+static int
+client_connect_get (struct Session *s);
+
+
+/**
* Connect a HTTP put connection
*
* @param s the session to connect
@@ -983,6 +997,15 @@
if (NULL == msg)
{
+ if (GNUNET_YES == plugin->emulate_xhr)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Session %p/connection %p: PUT request finished\n",
+ s, s->put.easyhandle);
+ s->put_tmp_disconnecting = GNUNET_YES;
+ return 0;
+ }
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Session %p/connection %p: nothing to send, suspending\n",
s, s->put.easyhandle);
@@ -1343,7 +1366,15 @@
/* FIXME: who calls curl_multi_remove on 'easy_h' now!? */
GNUNET_assert (plugin->cur_connections > 0);
plugin->cur_connections--;
- http_client_plugin_session_disconnect (plugin, s);
+ /* If we are emulating an XHR client we need to make another GET
+ * request.
+ */
+ if (GNUNET_YES == plugin->emulate_xhr)
+ {
+ if (GNUNET_SYSERR == client_connect_get (s))
+ http_client_plugin_session_disconnect (plugin, s);
+ } else
+ http_client_plugin_session_disconnect (plugin, s);
}
}
}
@@ -1413,7 +1444,15 @@
s->plugin->proxy_use_httpproxytunnel);
}
- curl_easy_setopt (s->get.easyhandle, CURLOPT_URL, s->url);
+ if (GNUNET_YES == s->plugin->emulate_xhr)
+ {
+ char *url;
+
+ GNUNET_asprintf(&url, "%s,1", s->url);
+ curl_easy_setopt (s->get.easyhandle, CURLOPT_URL, url);
+ GNUNET_free(url);
+ } else
+ curl_easy_setopt (s->get.easyhandle, CURLOPT_URL, s->url);
//curl_easy_setopt (s->get.easyhandle, CURLOPT_HEADERFUNCTION,
&curl_get_header_cb);
//curl_easy_setopt (s->get.easyhandle, CURLOPT_WRITEHEADER, ps);
curl_easy_setopt (s->get.easyhandle, CURLOPT_READFUNCTION, client_send_cb);
@@ -1583,9 +1622,15 @@
"Initiating outbound session peer `%s' using address `%s'\n",
GNUNET_i2s (&s->address->peer), s->url);
- if ((GNUNET_SYSERR == client_connect_get (s)) ||
- (GNUNET_SYSERR == client_connect_put (s)))
+ if (GNUNET_SYSERR == client_connect_get (s))
return GNUNET_SYSERR;
+ /* If we are emulating an XHR client then delay sending a PUT request until
+ * there is something to send.
+ */
+ if (GNUNET_YES == plugin->emulate_xhr)
+ s->put_tmp_disconnected = GNUNET_YES;
+ else if (GNUNET_SYSERR == client_connect_put (s))
+ return GNUNET_SYSERR;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Session %p: connected with connections GET %p and PUT %p\n",
@@ -1970,6 +2015,12 @@
GNUNET_free_non_null (proxy_type);
}
+
+ /* Should we emulate an XHR client for testing? */
+ plugin->emulate_xhr
+ = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
+ plugin->name,
+ "EMULATE_XHR");
return GNUNET_OK;
}
Added: gnunet/src/transport/test_transport_api_reliability_http_xhr_peer1.conf
===================================================================
--- gnunet/src/transport/test_transport_api_reliability_http_xhr_peer1.conf
(rev 0)
+++ gnunet/src/transport/test_transport_api_reliability_http_xhr_peer1.conf
2014-07-01 03:13:16 UTC (rev 33887)
@@ -0,0 +1,34 @@
address@hidden@ template_cfg_peer1.conf
+[PATHS]
+GNUNET_TEST_HOME = /tmp/test-transport/api-http-p1/
+
+[transport-http_client]
+EMULATE_XHR = YES
+
+[transport-tcp]
+TIMEOUT = 5 s
+
+[transport-http]
+PORT = 12180
+
+[arm]
+PORT = 12185
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-arm.sock
+
+[statistics]
+PORT = 12184
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-statistics.sock
+
+[resolver]
+PORT = 12183
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-resolver.sock
+
+[peerinfo]
+PORT = 12182
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock
+
+[transport]
+PORT = 12181
+PLUGINS = http_client
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock
+
Added: gnunet/src/transport/test_transport_api_reliability_http_xhr_peer2.conf
===================================================================
--- gnunet/src/transport/test_transport_api_reliability_http_xhr_peer2.conf
(rev 0)
+++ gnunet/src/transport/test_transport_api_reliability_http_xhr_peer2.conf
2014-07-01 03:13:16 UTC (rev 33887)
@@ -0,0 +1,30 @@
address@hidden@ template_cfg_peer2.conf
+[PATHS]
+GNUNET_TEST_HOME = /tmp/test-transport/api-http-p2/
+
+[transport-http_server]
+PORT = 12090
+USE_IPv6 = NO
+BINDTO = 127.0.0.1
+
+[arm]
+PORT = 12195
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-arm.sock
+
+[statistics]
+PORT = 12194
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-statistics.sock
+
+[resolver]
+PORT = 12193
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-resolver.sock
+
+[peerinfo]
+PORT = 12192
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-peerinfo.sock
+
+[transport]
+PORT = 12191
+PLUGINS = http_server
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock
+
Added: gnunet/src/transport/test_transport_api_reliability_https_xhr_peer1.conf
===================================================================
--- gnunet/src/transport/test_transport_api_reliability_https_xhr_peer1.conf
(rev 0)
+++ gnunet/src/transport/test_transport_api_reliability_https_xhr_peer1.conf
2014-07-01 03:13:16 UTC (rev 33887)
@@ -0,0 +1,28 @@
address@hidden@ template_cfg_peer1.conf
+[PATHS]
+GNUNET_TEST_HOME = /tmp/test-transport/api-https-p1/
+
+[transport-https_client]
+EMULATE_XHR = YES
+
+[arm]
+PORT = 12305
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-arm.sock
+
+[statistics]
+PORT = 12304
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-statistics.sock
+
+[resolver]
+PORT = 12303
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-resolver.sock
+
+[peerinfo]
+PORT = 12302
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-peerinfo.sock
+
+[transport]
+PORT = 12301
+PLUGINS = https_client
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p1-service-transport.sock
+
Added: gnunet/src/transport/test_transport_api_reliability_https_xhr_peer2.conf
===================================================================
--- gnunet/src/transport/test_transport_api_reliability_https_xhr_peer2.conf
(rev 0)
+++ gnunet/src/transport/test_transport_api_reliability_https_xhr_peer2.conf
2014-07-01 03:13:16 UTC (rev 33887)
@@ -0,0 +1,31 @@
address@hidden@ template_cfg_peer2.conf
+[PATHS]
+GNUNET_TEST_HOME = /tmp/test-transport/api-https-p2/
+
+[transport-https_server]
+PORT = 12310
+KEY_FILE = $GNUNET_TEST_HOME/https_key_p2.key
+CERT_FILE = $GNUNET_TEST_HOME/https_cert_p2.crt
+
+[arm]
+PORT = 12315
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-arm.sock
+
+[statistics]
+PORT = 12314
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-statistics.sock
+
+[resolver]
+PORT = 12313
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-resolver.sock
+
+[peerinfo]
+PORT = 12312
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-peerinfo.sock
+
+[transport]
+PORT = 12311
+PLUGINS = https_server
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-p2-service-transport.sock
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33887 - gnunet/src/transport,
gnunet <=