]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: check http/2 and http/3 server responsiveness
authorStefan Eissing <stefan@eissing.org>
Thu, 26 Sep 2024 12:55:56 +0000 (14:55 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 26 Sep 2024 21:34:16 +0000 (23:34 +0200)
Check responsiveness of http/3 server when running.

Also, a test case with http/2 or http/3 server requirement
now implicitly drags in a 'http' server and we need no longer
mention that in testdata.

Closes #15058

14 files changed:
tests/data/test1700
tests/data/test1701
tests/data/test1702
tests/data/test2401
tests/data/test2402
tests/data/test2403
tests/data/test2404
tests/data/test2405
tests/data/test2406
tests/data/test2500
tests/data/test2501
tests/data/test2502
tests/data/test2503
tests/servers.pm

index 8d1fff5801d318e546586e98a7b277c2a23a9067..be5644db5a6887818e22b487822d8eb1fa10e21f 100644 (file)
@@ -42,7 +42,6 @@ Content-Type: text/html
 h2c
 </features>
 <server>
-http
 http/2
 </server>
 <name>
index c81862aeb5e424a2a95f8b3b5b40c91e90c58258..469026d79d00e287d94758ec019598d43168343d 100644 (file)
@@ -33,7 +33,6 @@ Funny-head: yesyes
 h2c
 </features>
 <server>
-http
 http/2
 </server>
 <name>
index ced2ca06ce5a3a32a384066ba8e51b1e0e27f2e8..ce4a1c04d49b8d4d6779dc7d242925233f120aa2 100644 (file)
@@ -32,7 +32,6 @@ Funny-head: yesyes
 h2c
 </features>
 <server>
-http
 http/2
 </server>
 <name>
index 1db7dbedd9bfa6f6d9b1dc1a5dfb9cdc7ac93c4d..1a51b1741b40dbd92819674f9a5ab5b857f18278 100644 (file)
@@ -30,7 +30,6 @@ h2c
 SSL
 </features>
 <server>
-http
 http/2
 </server>
 <name>
index 44d48f85f2d2d59ba1aa8f3b9fbca9d9af3acaf3..f672759aae3bad4ca0a52bade65d0c52ed94eb0e 100644 (file)
@@ -51,7 +51,6 @@ h2c
 SSL
 </features>
 <server>
-http
 http/2
 </server>
 <tool>
index 7a993d731b8a21e7bc127225cbef401347bf4da3..533d483c5758cf3dd8fbfa101091e1f1e52d61e7 100644 (file)
@@ -34,7 +34,6 @@ SSL
 headers-api
 </features>
 <server>
-http
 http/2
 </server>
 <name>
index bcf1035aaf76d0e40b4fcf24b24886aecdb52266..a9106c50a1aa5bb5df7b56b02c00b9886c8893aa 100644 (file)
@@ -51,7 +51,6 @@ h2c
 SSL
 </features>
 <server>
-http
 http/2
 </server>
 <tool>
index 38bb1cd8c58521834a7bd3db9bf4ef88b1a06f61..8489156e7315eeb238ce33b832410653378f4648 100644 (file)
@@ -29,7 +29,6 @@ Funny-head: yesyes
 # Client-side
 <client>
 <server>
-http
 http/2
 </server>
 <tool>
index 7a1620f2b8adbc823b256465e9e979a92d522f77..541bdeea1a5c8702dbab9d4f943e9e381df0a3f1 100644 (file)
@@ -32,7 +32,6 @@ h2c
 SSL
 </features>
 <server>
-http
 http/2
 </server>
 <name>
index 6ec739d1ac858d8a0db834e33712d9987a45735f..f880672da2a6853961a7310441f8b887a32c2245 100644 (file)
@@ -33,7 +33,6 @@ http/3
 nghttpx-h3
 </features>
 <server>
-http
 http/3
 </server>
 <name>
index 8b49127ffd57ee206ef7d93e1d6f1b17ac14e58a..1f35372f1b09811a88cd4a74c159d3462cc670ba 100644 (file)
@@ -30,7 +30,6 @@ http
 http/3
 </features>
 <server>
-http
 http/3
 </server>
 <name>
index d20771a6f33e347693f0ccfa5646fa096ac3c0f0..2efd04f2d0c66ef821b57f0c84c2ed8c284b2cf0 100644 (file)
@@ -50,7 +50,6 @@ file contents should appear once for each file
 http/3
 </features>
 <server>
-http
 http/3
 </server>
 <tool>
index 9877ee4c1b353fe5a8ce9d55d71ba9729c6683fc..ab86c66be2343dcf7d7f4354f106777b930cdfa3 100644 (file)
@@ -33,7 +33,6 @@ nghttpx-h3
 headers-api
 </features>
 <server>
-http
 http/3
 </server>
 <name>
index 14ffca23bda9693b1b501a61ebb306731497b200..0938aaa93fe5a8c62d0b53a41ceb1c461e5d8b3a 100644 (file)
@@ -550,18 +550,19 @@ sub getexternalproxyflags {
 # assign requested address")
 #
 sub verifyhttp {
-    my ($proto, $ipvnum, $idnum, $ip, $port_or_path) = @_;
+    my ($proto, $ipvnum, $idnum, $ip, $port_or_path, $do_http3) = @_;
     my $server = servername_id($proto, $ipvnum, $idnum);
     my $bonus="";
     # $port_or_path contains a path for Unix sockets, sws ignores the port
     my $port = ($ipvnum eq "unix") ? 80 : $port_or_path;
+    my $infix = ($do_http3) ? "_h3" : "";
 
     my $verifyout = "$LOGDIR/".
-        servername_canon($proto, $ipvnum, $idnum) .'_verify.out';
+        servername_canon($proto, $ipvnum, $idnum) .$infix .'_verify.out';
     unlink($verifyout) if(-f $verifyout);
 
     my $verifylog = "$LOGDIR/".
-        servername_canon($proto, $ipvnum, $idnum) .'_verify.log';
+        servername_canon($proto, $ipvnum, $idnum) .$infix .'_verify.log';
     unlink($verifylog) if(-f $verifylog);
 
     if($proto eq "gopher") {
@@ -579,6 +580,7 @@ sub verifyhttp {
     if($proxy_address) {
         $flags .= getexternalproxyflags();
     }
+    $flags .= "--http3-only " if($do_http3);
     $flags .= "\"$proto://$ip:$port/${bonus}verifiedserver\"";
 
     my $cmd = "$VCURL $flags 2>$verifylog";
@@ -1101,12 +1103,12 @@ sub verifyserver {
 # to verify that a server present in %run hash is still functional
 #
 sub responsiveserver {
-    my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
+    my ($proto, $ipvnum, $idnum, $ip, $port, $do_http3) = @_;
     my $prev_verbose = $verbose;
 
     $verbose = 0;
     my $fun = $protofunc{$proto};
-    my $pid = &$fun($proto, $ipvnum, $idnum, $ip, $port);
+    my $pid = &$fun($proto, $ipvnum, $idnum, $ip, $port, $do_http3);
     $verbose = $prev_verbose;
 
     if($pid > 0) {
@@ -2217,7 +2219,7 @@ sub runnegtelnetserver {
 # be used to verify that a server present in %run hash is still functional
 #
 sub responsive_http_server {
-    my ($proto, $verb, $alt, $port_or_path) = @_;
+    my ($proto, $verb, $alt, $port_or_path, $do_http3) = @_;
     my $ip = $HOSTIP;
     my $ipvnum = 4;
     my $idnum = 1;
@@ -2235,7 +2237,7 @@ sub responsive_http_server {
         $ipvnum = "unix";
     }
 
-    return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port_or_path);
+    return &responsiveserver($proto, $ipvnum, $idnum, $ip, $port_or_path, $do_http3);
 }
 
 #######################################################################
@@ -2424,29 +2426,6 @@ sub startservers {
                 $run{'gopher-ipv6'}="$pid $pid2";
             }
         }
-        elsif($what eq "http/3") {
-            if(!$run{'http/3'}) {
-                ($serr, $pid, $pid2, $PORT{"http3"}) = runhttp3server($verbose);
-                if($pid <= 0) {
-                    return ("failed starting HTTP/3 server", $serr);
-                }
-                logmsg sprintf ("* pid http/3 => %d %d\n", $pid, $pid2)
-                    if($verbose);
-                $run{'http/3'}="$pid $pid2";
-            }
-        }
-        elsif($what eq "http/2") {
-            if(!$run{'http/2'}) {
-                ($serr, $pid, $pid2, $PORT{"http2"}, $PORT{"http2tls"}) =
-                    runhttp2server($verbose);
-                if($pid <= 0) {
-                    return ("failed starting HTTP/2 server", $serr);
-                }
-                logmsg sprintf ("* pid http/2 => %d %d\n", $pid, $pid2)
-                    if($verbose);
-                $run{'http/2'}="$pid $pid2";
-            }
-        }
         elsif($what eq "http") {
             if($run{'http'} &&
                !responsive_http_server("http", $verbose, 0, protoport('http'))) {
@@ -2632,6 +2611,87 @@ sub startservers {
                 $run{'https'}="$pid $pid2";
             }
         }
+        elsif($what eq "http/2") {
+            # http/2 server proxies to a http server
+            if($run{'http/2'} &&
+               !responsive_http_server("https", $verbose, 0, protoport('http2tls'))) {
+                logmsg "* restarting unresponsive HTTP/2 server\n";
+                if(stopserver('http/2')) {
+                    return ("failed stopping unresponsive HTTP/2 server", 3);
+                }
+                # also stop http server, we do not know which state it is in
+                if($run{'http'} && stopserver('http')) {
+                    return ("failed stopping HTTP server", 3);
+                }
+            }
+            # check a running http server if we not already checked http/2
+            if($run{'http'} && !$run{'http/2'} &&
+               !responsive_http_server("http", $verbose, 0,
+                                       protoport('http'))) {
+                if(stopserver('http')) {
+                    return ("failed stopping unresponsive HTTP server", 3);
+                }
+            }
+            if(!$run{'http'}) {
+                ($serr, $pid, $pid2, $PORT{'http'}) =
+                    runhttpserver("http", $verbose, 0);
+                if($pid <= 0) {
+                    return ("failed starting HTTP server", $serr);
+                }
+                logmsg sprintf("* pid http => %d %d\n", $pid, $pid2) if($verbose);
+                $run{'http'}="$pid $pid2";
+            }
+            if(!$run{'http/2'}) {
+                ($serr, $pid, $pid2, $PORT{"http2"}, $PORT{"http2tls"}) =
+                    runhttp2server($verbose);
+                if($pid <= 0) {
+                    return ("failed starting HTTP/2 server", $serr);
+                }
+                logmsg sprintf ("* pid http/2 => %d %d\n", $pid, $pid2)
+                    if($verbose);
+                $run{'http/2'}="$pid $pid2";
+            }
+        }
+        elsif($what eq "http/3") {
+            # http/3 server proxies to a http server
+            if($run{'http/3'} &&
+               !responsive_http_server("https", $verbose, 0, protoport('http3'), 1)) {
+                logmsg "* restarting unresponsive HTTP/3 server\n";
+                if(stopserver('http/3')) {
+                    return ("failed stopping unresponsive HTTP/3 server", 3);
+                }
+                # also stop http server, we do not know which state it is in
+                if($run{'http'} && stopserver('http')) {
+                    return ("failed stopping HTTP server", 3);
+                }
+            }
+            # check a running http server if we not already checked http/3
+            if($run{'http'} && !$run{'http/3'} &&
+               !responsive_http_server("http", $verbose, 0,
+                                       protoport('http'))) {
+                if(stopserver('http')) {
+                    return ("failed stopping unresponsive HTTP server", 3);
+                }
+            }
+            if(!$run{'http'}) {
+                ($serr, $pid, $pid2, $PORT{'http'}) =
+                    runhttpserver("http", $verbose, 0);
+                if($pid <= 0) {
+                    return ("failed starting HTTP server", $serr);
+                }
+                logmsg sprintf("* pid http => %d %d\n", $pid, $pid2) if($verbose);
+                $run{'http'}="$pid $pid2";
+            }
+            if(!$run{'http/3'}) {
+                ($serr, $pid, $pid2, $PORT{"http3"}) = runhttp3server($verbose);
+                if($pid <= 0) {
+                    return ("failed starting HTTP/3 server", $serr);
+                }
+                logmsg sprintf ("* pid http/3 => %d %d\n", $pid, $pid2)
+                    if($verbose);
+                $run{'http/3'}="$pid $pid2";
+            }
+        }
         elsif($what eq "gophers") {
             if(!$stunnel) {
                 # we can't run TLS tests without stunnel