summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-12-15 14:28:30 +0300
committerValery Piashchynski <[email protected]>2020-12-15 14:28:30 +0300
commit21b51367e27f5a1b166459a115e4655d07a5d832 (patch)
treec3257a2ac38f0688e78ca2c9eeb160fb7a84c55d /plugins
parent08f073f3bdc1288db68235c098c3a2109c6e7667 (diff)
parentd39a0735fe21d21c5aae20c4780458433a42250a (diff)
Merge branch '2.0' into plugin/reloader
# Conflicts: # go.mod # sync_worker.go
Diffstat (limited to 'plugins')
-rw-r--r--plugins/checker/tests/plugin_test.go2
-rw-r--r--plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml2
-rw-r--r--plugins/gzip/tests/configs/.rr-http-withGzip.yaml2
-rw-r--r--plugins/gzip/tests/psr-worker.php23
-rw-r--r--plugins/http/plugin.go9
-rw-r--r--plugins/http/tests/configs/.rr-h2c.yaml9
-rw-r--r--plugins/http/tests/configs/.rr-ssl-push.yaml8
-rw-r--r--plugins/http/tests/configs/.rr-ssl-redirect.yaml8
-rw-r--r--plugins/http/tests/configs/.rr-ssl.yaml2
-rw-r--r--plugins/http/tests/http_test.go4
-rw-r--r--plugins/http/tests/uploads_test.go4
-rw-r--r--plugins/http/uploads.go6
-rw-r--r--plugins/informer/tests/informer_test.go2
-rw-r--r--plugins/metrics/config.go11
-rw-r--r--plugins/metrics/tests/metrics_test.go2
-rw-r--r--plugins/resetter/tests/resetter_test.go7
-rwxr-xr-xplugins/rpc/config_test.go7
-rwxr-xr-xplugins/rpc/plugin.go2
-rw-r--r--plugins/rpc/tests/plugin2.go2
-rw-r--r--plugins/server/tests/socket.php6
-rw-r--r--plugins/server/tests/tcp.php8
21 files changed, 46 insertions, 80 deletions
diff --git a/plugins/checker/tests/plugin_test.go b/plugins/checker/tests/plugin_test.go
index c93b68af..a37fc08e 100644
--- a/plugins/checker/tests/plugin_test.go
+++ b/plugins/checker/tests/plugin_test.go
@@ -13,7 +13,7 @@ import (
"time"
"github.com/spiral/endure"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
"github.com/spiral/roadrunner/v2/interfaces/status"
"github.com/spiral/roadrunner/v2/plugins/checker"
"github.com/spiral/roadrunner/v2/plugins/config"
diff --git a/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml b/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml
index df02c043..3dc5f9df 100644
--- a/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml
+++ b/plugins/gzip/tests/configs/.rr-http-middlewareNotExist.yaml
@@ -1,5 +1,5 @@
server:
- command: "php psr-worker.php"
+ command: "php ../../../tests/psr-worker.php"
user: ""
group: ""
env:
diff --git a/plugins/gzip/tests/configs/.rr-http-withGzip.yaml b/plugins/gzip/tests/configs/.rr-http-withGzip.yaml
index b91a9aad..38fdfe47 100644
--- a/plugins/gzip/tests/configs/.rr-http-withGzip.yaml
+++ b/plugins/gzip/tests/configs/.rr-http-withGzip.yaml
@@ -1,5 +1,5 @@
server:
- command: "php psr-worker.php"
+ command: "php ../../../tests/psr-worker.php"
user: ""
group: ""
env:
diff --git a/plugins/gzip/tests/psr-worker.php b/plugins/gzip/tests/psr-worker.php
deleted file mode 100644
index ed936bde..00000000
--- a/plugins/gzip/tests/psr-worker.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-/**
- * @var Goridge\RelayInterface $relay
- */
-use Spiral\Goridge;
-use Spiral\RoadRunner;
-
-ini_set('display_errors', 'stderr');
-require dirname(__DIR__) . "/../../vendor_php/autoload.php";
-
-$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT));
-$psr7 = new RoadRunner\PSR7Client($worker);
-
-while ($req = $psr7->acceptRequest()) {
- try {
- $resp = new \Zend\Diactoros\Response();
- $resp->getBody()->write(str_repeat("hello world", 1000));
-
- $psr7->respond($resp);
- } catch (\Throwable $e) {
- $psr7->getWorker()->error((string)$e);
- }
-} \ No newline at end of file
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 371cdb91..a6399489 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -183,6 +183,11 @@ func (s *Plugin) Serve() chan error {
s.fcgi = &http.Server{Handler: s}
}
+ // apply middlewares before starting the server
+ if len(s.mdwr) > 0 {
+ s.addMiddlewares()
+ }
+
if s.http != nil {
go func() {
httpErr := s.http.ListenAndServe()
@@ -217,10 +222,6 @@ func (s *Plugin) Serve() chan error {
}()
}
- if len(s.mdwr) > 0 {
- s.addMiddlewares()
- }
-
return errCh
}
diff --git a/plugins/http/tests/configs/.rr-h2c.yaml b/plugins/http/tests/configs/.rr-h2c.yaml
index 316daea9..d1b24338 100644
--- a/plugins/http/tests/configs/.rr-h2c.yaml
+++ b/plugins/http/tests/configs/.rr-h2c.yaml
@@ -20,15 +20,6 @@ http:
maxJobs: 0
allocateTimeout: 60s
destroyTimeout: 60s
-
- ssl:
- port: 8891
- redirect: false
- cert: fixtures/server.crt
- key: fixtures/server.key
- # rootCa: root.crt
- fcgi:
- address: tcp://0.0.0.0:6920
http2:
enabled: true
h2c: true
diff --git a/plugins/http/tests/configs/.rr-ssl-push.yaml b/plugins/http/tests/configs/.rr-ssl-push.yaml
index 90a99192..02de906a 100644
--- a/plugins/http/tests/configs/.rr-ssl-push.yaml
+++ b/plugins/http/tests/configs/.rr-ssl-push.yaml
@@ -26,10 +26,4 @@ http:
redirect: true
cert: fixtures/server.crt
key: fixtures/server.key
- # rootCa: root.crt
- fcgi:
- address: tcp://0.0.0.0:6920
- http2:
- enabled: false
- h2c: false
- maxConcurrentStreams: 128 \ No newline at end of file
+ # rootCa: root.crt \ No newline at end of file
diff --git a/plugins/http/tests/configs/.rr-ssl-redirect.yaml b/plugins/http/tests/configs/.rr-ssl-redirect.yaml
index 1878ba53..0ba1753e 100644
--- a/plugins/http/tests/configs/.rr-ssl-redirect.yaml
+++ b/plugins/http/tests/configs/.rr-ssl-redirect.yaml
@@ -26,10 +26,4 @@ http:
redirect: true
cert: fixtures/server.crt
key: fixtures/server.key
- # rootCa: root.crt
- fcgi:
- address: tcp://0.0.0.0:6920
- http2:
- enabled: false
- h2c: false
- maxConcurrentStreams: 128 \ No newline at end of file
+ # rootCa: root.crt \ No newline at end of file
diff --git a/plugins/http/tests/configs/.rr-ssl.yaml b/plugins/http/tests/configs/.rr-ssl.yaml
index 127c1678..fb54d3fa 100644
--- a/plugins/http/tests/configs/.rr-ssl.yaml
+++ b/plugins/http/tests/configs/.rr-ssl.yaml
@@ -28,7 +28,7 @@ http:
key: fixtures/server.key
# rootCa: root.crt
fcgi:
- address: tcp://0.0.0.0:6920
+ address: tcp://0.0.0.0:16920
http2:
enabled: false
h2c: false
diff --git a/plugins/http/tests/http_test.go b/plugins/http/tests/http_test.go
index 06bf3f5d..f68cd42c 100644
--- a/plugins/http/tests/http_test.go
+++ b/plugins/http/tests/http_test.go
@@ -17,7 +17,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/spiral/endure"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
"github.com/spiral/roadrunner/v2"
"github.com/spiral/roadrunner/v2/mocks"
"github.com/spiral/roadrunner/v2/plugins/config"
@@ -334,7 +334,7 @@ func sslEcho(t *testing.T) {
}
func fcgiEcho(t *testing.T) {
- fcgiConnFactory := gofast.SimpleConnFactory("tcp", "0.0.0.0:6920")
+ fcgiConnFactory := gofast.SimpleConnFactory("tcp", "0.0.0.0:16920")
fcgiHandler := gofast.NewHandler(
gofast.BasicParamsMap(gofast.BasicSession),
diff --git a/plugins/http/tests/uploads_test.go b/plugins/http/tests/uploads_test.go
index ee244c06..d36d4793 100644
--- a/plugins/http/tests/uploads_test.go
+++ b/plugins/http/tests/uploads_test.go
@@ -269,7 +269,7 @@ func TestHandler_Upload_File_NoTmpDir(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 200, r.StatusCode)
- fs := fileString(testFile, 5, "application/octet-stream")
+ fs := fileString(testFile, 6, "application/octet-stream")
assert.Equal(t, `{"upload":`+fs+`}`, string(b))
}
@@ -352,7 +352,7 @@ func TestHandler_Upload_File_Forbids(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 200, r.StatusCode)
- fs := fileString(testFile, 7, "application/octet-stream")
+ fs := fileString(testFile, 8, "application/octet-stream")
assert.Equal(t, `{"upload":`+fs+`}`, string(b))
}
diff --git a/plugins/http/uploads.go b/plugins/http/uploads.go
index 5fddb75d..aeb41591 100644
--- a/plugins/http/uploads.go
+++ b/plugins/http/uploads.go
@@ -18,13 +18,13 @@ const (
UploadErrorNoFile = 4
// UploadErrorNoTmpDir - missing a temporary folder.
- UploadErrorNoTmpDir = 5
+ UploadErrorNoTmpDir = 6
// UploadErrorCantWrite - failed to write file to disk.
- UploadErrorCantWrite = 6
+ UploadErrorCantWrite = 7
// UploadErrorExtension - forbidden file extension.
- UploadErrorExtension = 7
+ UploadErrorExtension = 8
)
// Uploads tree manages uploaded files tree and temporary files.
diff --git a/plugins/informer/tests/informer_test.go b/plugins/informer/tests/informer_test.go
index fbe33a7d..9e21e7ea 100644
--- a/plugins/informer/tests/informer_test.go
+++ b/plugins/informer/tests/informer_test.go
@@ -10,7 +10,7 @@ import (
"time"
"github.com/spiral/endure"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
"github.com/spiral/roadrunner/v2"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/informer"
diff --git a/plugins/metrics/config.go b/plugins/metrics/config.go
index 933b7eb8..9459bc9b 100644
--- a/plugins/metrics/config.go
+++ b/plugins/metrics/config.go
@@ -54,6 +54,8 @@ type Collector struct {
Labels []string `json:"labels"`
// Buckets for histogram metric.
Buckets []float64 `json:"buckets"`
+ // Objectives for the summary opts
+ Objectives map[float64]float64 `json:"objectives"`
}
// register application specific metrics.
@@ -109,10 +111,11 @@ func (c *Config) getCollectors() (map[string]prometheus.Collector, error) {
}
case Summary:
opts := prometheus.SummaryOpts{
- Name: name,
- Namespace: m.Namespace,
- Subsystem: m.Subsystem,
- Help: m.Help,
+ Name: name,
+ Namespace: m.Namespace,
+ Subsystem: m.Subsystem,
+ Help: m.Help,
+ Objectives: m.Objectives,
}
if len(m.Labels) != 0 {
diff --git a/plugins/metrics/tests/metrics_test.go b/plugins/metrics/tests/metrics_test.go
index f9014c95..57b10aa4 100644
--- a/plugins/metrics/tests/metrics_test.go
+++ b/plugins/metrics/tests/metrics_test.go
@@ -12,7 +12,7 @@ import (
"time"
"github.com/spiral/endure"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/logger"
"github.com/spiral/roadrunner/v2/plugins/metrics"
diff --git a/plugins/resetter/tests/resetter_test.go b/plugins/resetter/tests/resetter_test.go
index a1873dd4..3bfccf47 100644
--- a/plugins/resetter/tests/resetter_test.go
+++ b/plugins/resetter/tests/resetter_test.go
@@ -10,7 +10,7 @@ import (
"time"
"github.com/spiral/endure"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/logger"
"github.com/spiral/roadrunner/v2/plugins/resetter"
@@ -19,7 +19,7 @@ import (
"github.com/stretchr/testify/assert"
)
-func TestInformerInit(t *testing.T) {
+func TestResetterInit(t *testing.T) {
cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.DebugLevel))
if err != nil {
t.Fatal(err)
@@ -53,7 +53,7 @@ func TestInformerInit(t *testing.T) {
tt := time.NewTimer(time.Second * 15)
- t.Run("InformerRpcTest", resetterRPCTest)
+ t.Run("ResetterRpcTest", resetterRPCTest)
for {
select {
@@ -94,6 +94,7 @@ func resetterRPCTest(t *testing.T) {
var services []string
err = client.Call("resetter.List", nil, &services)
+ assert.NotNil(t, services)
assert.NoError(t, err)
if services[0] != "resetter.plugin1" {
t.Fatal("no enough services")
diff --git a/plugins/rpc/config_test.go b/plugins/rpc/config_test.go
index 8b1d974a..67532bc8 100755
--- a/plugins/rpc/config_test.go
+++ b/plugins/rpc/config_test.go
@@ -1,6 +1,7 @@
package rpc
import (
+ "runtime"
"testing"
j "github.com/json-iterator/go"
@@ -29,7 +30,11 @@ func TestConfig_Listener(t *testing.T) {
}()
assert.Equal(t, "tcp", ln.Addr().Network())
- assert.Equal(t, "0.0.0.0:18001", ln.Addr().String())
+ if runtime.GOOS == "windows" {
+ assert.Equal(t, "[::]:18001", ln.Addr().String())
+ } else {
+ assert.Equal(t, "0.0.0.0:18001", ln.Addr().String())
+ }
}
func TestConfig_ListenerUnix(t *testing.T) {
diff --git a/plugins/rpc/plugin.go b/plugins/rpc/plugin.go
index 24624d91..c8e63496 100755
--- a/plugins/rpc/plugin.go
+++ b/plugins/rpc/plugin.go
@@ -7,7 +7,7 @@ import (
"github.com/spiral/endure"
"github.com/spiral/errors"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
"github.com/spiral/roadrunner/v2/interfaces/log"
rpc_ "github.com/spiral/roadrunner/v2/interfaces/rpc"
"github.com/spiral/roadrunner/v2/plugins/config"
diff --git a/plugins/rpc/tests/plugin2.go b/plugins/rpc/tests/plugin2.go
index 854bf097..347e0330 100644
--- a/plugins/rpc/tests/plugin2.go
+++ b/plugins/rpc/tests/plugin2.go
@@ -6,7 +6,7 @@ import (
"time"
"github.com/spiral/errors"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
)
// plugin2 makes a call to the plugin1 via RPC
diff --git a/plugins/server/tests/socket.php b/plugins/server/tests/socket.php
index 143c3ce4..1b76481a 100644
--- a/plugins/server/tests/socket.php
+++ b/plugins/server/tests/socket.php
@@ -6,7 +6,7 @@
use Spiral\Goridge;
use Spiral\RoadRunner;
-require dirname(__DIR__) . "/../../vendor_php/autoload.php";
+require dirname(__DIR__) . "/../../tests/vendor/autoload.php";
$relay = new Goridge\SocketRelay(
"unix.sock",
@@ -16,9 +16,9 @@ $relay = new Goridge\SocketRelay(
$rr = new RoadRunner\Worker($relay);
-while ($in = $rr->receive($ctx)) {
+while ($in = $rr->waitPayload()) {
try {
- $rr->send((string)$in);
+ $rr->send((string)$in->body);
} catch (\Throwable $e) {
$rr->error((string)$e);
}
diff --git a/plugins/server/tests/tcp.php b/plugins/server/tests/tcp.php
index 2d6fb00a..c567c982 100644
--- a/plugins/server/tests/tcp.php
+++ b/plugins/server/tests/tcp.php
@@ -6,15 +6,15 @@
use Spiral\Goridge;
use Spiral\RoadRunner;
-require dirname(__DIR__) . "/../../vendor_php/autoload.php";
+require dirname(__DIR__) . "/../../tests/vendor/autoload.php";
$relay = new Goridge\SocketRelay("localhost", 9999);
$rr = new RoadRunner\Worker($relay);
-while ($in = $rr->receive($ctx)) {
+while ($in = $rr->waitPayload()) {
try {
- $rr->send((string)$in);
+ $rr->send((string)$in->body);
} catch (\Throwable $e) {
$rr->error((string)$e);
}
-} \ No newline at end of file
+}