summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-05-23 19:59:27 +0300
committerValery Piashchynski <[email protected]>2020-05-23 19:59:27 +0300
commitc4a47cc74421808a1f20788dbca2fbf1334e8054 (patch)
treef3f03df5e4bbe8bbd229b6e519b420feecc14fd2
parent6a111d01d9ec2f43b2fd0173532a0db101137648 (diff)
update h2c_test, add backoff
-rw-r--r--CHANGELOG.md5
-rw-r--r--service/http/h2c_test.go85
2 files changed, 54 insertions, 36 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index de88fbe9..713da3b3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,14 +1,15 @@
CHANGELOG
=========
-v1.8.1 (20.05.2020)
+v1.8.1 (23.05.2020)
-------------------
-- Update goridge version to 2.4.2
+- Update goridge version to 2.4.3
- Fix code warnings from phpstan
- Improve RPC
- Create templates for the Bug reporting and Feature requests
- Move docker images from golang-alpine to regular golang images
- Add support for the CloudFlare CF-Connecting-IP and True-Client-IP headers (thanks @vsychov)
+- Add support for the RootCA via the
- See the full milestone here: [link](https://github.com/spiral/roadrunner/milestone/11?closed=1)
v1.8.0 (05.05.2020)
diff --git a/service/http/h2c_test.go b/service/http/h2c_test.go
index a2465a0a..88c9ee5b 100644
--- a/service/http/h2c_test.go
+++ b/service/http/h2c_test.go
@@ -1,23 +1,29 @@
package http
import (
+ "net/http"
+ "testing"
+ "time"
+
+ "github.com/cenkalti/backoff/v4"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/test"
"github.com/spiral/roadrunner/service"
"github.com/stretchr/testify/assert"
- "net/http"
- "testing"
- "time"
)
func Test_Service_H2C(t *testing.T) {
- logger, _ := test.NewNullLogger()
- logger.SetLevel(logrus.DebugLevel)
+ bkoff := backoff.NewExponentialBackOff()
+ bkoff.MaxElapsedTime = time.Second * 15
+
+ err := backoff.Retry(func() error {
+ logger, _ := test.NewNullLogger()
+ logger.SetLevel(logrus.DebugLevel)
- c := service.NewContainer(logger)
- c.Register(ID, &Service{})
+ c := service.NewContainer(logger)
+ c.Register(ID, &Service{})
- assert.NoError(t, c.Init(&testCfg{httpCfg: `{
+ err := c.Init(&testCfg{httpCfg: `{
"address": ":6029",
"http2": {"h2c":true},
"workers":{
@@ -27,40 +33,51 @@ func Test_Service_H2C(t *testing.T) {
"numWorkers": 1
}
}
- }`}))
+ }`})
+ if err != nil {
+ return err
+ }
- s, st := c.Get(ID)
- assert.NotNil(t, s)
- assert.Equal(t, service.StatusOK, st)
+ s, st := c.Get(ID)
+ assert.NotNil(t, s)
+ assert.Equal(t, service.StatusOK, st)
- // should do nothing
- s.(*Service).Stop()
+ // should do nothing
+ s.(*Service).Stop()
+
+ go func() {
+ err := c.Serve()
+ if err != nil {
+ t.Errorf("error serving: %v", err)
+ }
+ }()
+ time.Sleep(time.Millisecond * 100)
+ defer c.Stop()
- go func() {
- err := c.Serve()
+ req, err := http.NewRequest("PRI", "http://localhost:6029?hello=world", nil)
if err != nil {
- t.Errorf("error serving: %v", err)
+ return err
}
- }()
- time.Sleep(time.Millisecond * 100)
- defer c.Stop()
- req, err := http.NewRequest("PRI", "http://localhost:6029?hello=world", nil)
- assert.NoError(t, err)
+ req.Header.Add("Upgrade", "h2c")
+ req.Header.Add("Connection", "HTTP2-Settings")
+ req.Header.Add("HTTP2-Settings", "")
- req.Header.Add("Upgrade", "h2c")
- req.Header.Add("Connection", "HTTP2-Settings")
- req.Header.Add("HTTP2-Settings", "")
-
- r, err2 := http.DefaultClient.Do(req)
- if err2 != nil {
- t.Fatal(err2)
- }
+ r, err2 := http.DefaultClient.Do(req)
+ if err2 != nil {
+ return err2
+ }
- assert.Equal(t, "101 Switching Protocols", r.Status)
+ assert.Equal(t, "101 Switching Protocols", r.Status)
- err3 := r.Body.Close()
- if err3 != nil {
- t.Errorf("fail to close the Body: error %v", err3)
+ err3 := r.Body.Close()
+ if err3 != nil {
+ return err3
+ }
+ return nil
+ }, bkoff)
+
+ if err != nil {
+ t.Fatal(err)
}
}