summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.changes1
-rw-r--r--.github/pull_request_template.md24
-rw-r--r--.github/workflows/build.yml30
-rw-r--r--Dockerfile2
-rwxr-xr-xpkg/pool/static_pool_test.go7
-rw-r--r--pkg/pool/supervisor_test.go2
-rw-r--r--pkg/worker_watcher/stack.go4
-rw-r--r--plugins/http/plugin.go5
-rw-r--r--tests/plugins/http/configs/.rr-no-http.yaml17
-rw-r--r--tests/plugins/http/http_plugin_test.go64
10 files changed, 146 insertions, 10 deletions
diff --git a/.changes b/.changes
deleted file mode 100644
index 345e6aef..00000000
--- a/.changes
+++ /dev/null
@@ -1 +0,0 @@
-Test
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 00000000..c3467850
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,24 @@
+# Reason for This PR
+
+`[Author TODO: add issue # or explain reasoning.]`
+
+## Description of Changes
+
+`[Author TODO: add description of changes.]`
+
+## License Acceptance
+
+By submitting this pull request, I confirm that my contribution is made under
+the terms of the MIT license.
+
+## PR Checklist
+
+`[Author TODO: Meet these criteria.]`
+`[Reviewer TODO: Verify that these criteria are met. Request changes if not]`
+
+- [ ] All commits in this PR are signed (`git commit -s`).
+- [ ] The reason for this PR is clearly provided (issue no. or explanation).
+- [ ] The description of changes is clear and encompassing.
+- [ ] Any required documentation changes (code and docs) are included in this PR.
+- [ ] Any user-facing changes are mentioned in `CHANGELOG.md`.
+- [ ] All added/changed functionality is tested.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0b9240da..7f490208 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -20,7 +20,7 @@ jobs:
matrix:
php: [ "7.4", "8.0" ]
go: [ "1.14", "1.15" ]
- os: [ ubuntu-latest, windows-latest ]
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v2 # action page: <https://github.com/actions/setup-go>
@@ -94,6 +94,34 @@ jobs:
go test -v -race -tags=debug ./tests/plugins/kv/memcached
docker-compose -f ./tests/docker-compose.yaml down
+ - name: Run golang tests on MacOS without codecov
+ if: ${{ matrix.os == 'macos-latest' }}
+ run: |
+ go test -v -race -tags=debug ./utils
+ go test -v -race -tags=debug ./pkg/pipe
+ go test -v -race -tags=debug ./pkg/pool
+ go test -v -race -tags=debug ./pkg/socket
+ go test -v -race -tags=debug ./pkg/worker
+ go test -v -race -tags=debug ./pkg/worker_watcher
+ go test -v -race -tags=debug ./tests/plugins/http
+ go test -v -race -tags=debug ./tests/plugins/informer
+ go test -v -race -tags=debug ./tests/plugins/reload
+ go test -v -race -tags=debug ./tests/plugins/server
+ go test -v -race -tags=debug ./tests/plugins/checker
+ go test -v -race -tags=debug ./tests/plugins/config
+ go test -v -race -tags=debug ./tests/plugins/gzip
+ go test -v -race -tags=debug ./tests/plugins/headers
+ go test -v -race -tags=debug ./tests/plugins/logger
+ go test -v -race -tags=debug ./tests/plugins/metrics
+ go test -v -race -tags=debug ./tests/plugins/redis
+ go test -v -race -tags=debug ./tests/plugins/resetter
+ go test -v -race -tags=debug ./tests/plugins/rpc
+ go test -v -race -tags=debug ./tests/plugins/static
+ go test -v -race -tags=debug ./plugins/kv/boltdb
+ go test -v -race -tags=debug ./plugins/kv/memory
+ go test -v -race -tags=debug ./tests/plugins/kv/boltdb
+ go test -v -race -tags=debug ./tests/plugins/kv/memory
+
- name: Run golang tests on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
diff --git a/Dockerfile b/Dockerfile
index ed143753..5291e86b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -29,7 +29,7 @@ COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags "$LDFLAGS" -o ./rr ./cmd/main.go
# Image page: <https://hub.docker.com/_/alpine>
-FROM alpine:3.12
+FROM alpine:3.13
# use same build arguments for image labels
ARG APP_VERSION
diff --git a/pkg/pool/static_pool_test.go b/pkg/pool/static_pool_test.go
index 53d6b191..f66895dc 100755
--- a/pkg/pool/static_pool_test.go
+++ b/pkg/pool/static_pool_test.go
@@ -459,16 +459,15 @@ func Test_Static_Pool_Handle_Dead(t *testing.T) {
},
)
assert.NoError(t, err)
- defer p.Destroy(ctx)
-
assert.NotNil(t, p)
- for _, w := range p.Workers() {
- w.State().Set(internal.StateErrored)
+ for i := range p.Workers() {
+ p.Workers()[i].State().Set(internal.StateErrored)
}
_, err = p.Exec(payload.Payload{Body: []byte("hello")})
assert.Error(t, err)
+ p.Destroy(ctx)
}
// identical to replace but controlled on worker side
diff --git a/pkg/pool/supervisor_test.go b/pkg/pool/supervisor_test.go
index 72226bee..b3358965 100644
--- a/pkg/pool/supervisor_test.go
+++ b/pkg/pool/supervisor_test.go
@@ -135,7 +135,6 @@ func TestSupervisedPool_Idle(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, p)
- defer p.Destroy(context.Background())
pid := p.Workers()[0].Pid()
@@ -151,6 +150,7 @@ func TestSupervisedPool_Idle(t *testing.T) {
time.Sleep(time.Second * 5)
// should be new worker with new pid
assert.NotEqual(t, pid, p.Workers()[0].Pid())
+ p.Destroy(context.Background())
}
func TestSupervisedPool_ExecTTL_OK(t *testing.T) {
diff --git a/pkg/worker_watcher/stack.go b/pkg/worker_watcher/stack.go
index 788750dc..c87e8b65 100644
--- a/pkg/worker_watcher/stack.go
+++ b/pkg/worker_watcher/stack.go
@@ -109,7 +109,8 @@ func (stack *Stack) Destroy(ctx context.Context) {
stack.destroy = true
stack.mutex.Unlock()
- tt := time.NewTicker(time.Millisecond * 100)
+ tt := time.NewTicker(time.Millisecond * 500)
+ defer tt.Stop()
for {
select {
case <-tt.C:
@@ -131,7 +132,6 @@ func (stack *Stack) Destroy(ctx context.Context) {
_ = stack.workers[i].Kill()
}
stack.mutex.Unlock()
- tt.Stop()
// clear
stack.Reset()
return
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 222bf852..2e00a91a 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -77,6 +77,11 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, server server.Se
return errors.E(op, err)
}
+ // if no HTTP section in config - disable HTTP
+ if s.cfg == nil {
+ return errors.E(op, errors.Disabled)
+ }
+
err = s.cfg.InitDefaults()
if err != nil {
return errors.E(op, err)
diff --git a/tests/plugins/http/configs/.rr-no-http.yaml b/tests/plugins/http/configs/.rr-no-http.yaml
new file mode 100644
index 00000000..6466c950
--- /dev/null
+++ b/tests/plugins/http/configs/.rr-no-http.yaml
@@ -0,0 +1,17 @@
+rpc:
+ listen: tcp://127.0.0.1:6001
+ disabled: false
+
+server:
+ command: "php ../../http/client.php echo pipes"
+ user: ""
+ group: ""
+ env:
+ "RR_HTTP": "true"
+ relay: "pipes"
+ relay_timeout: "20s"
+
+logs:
+ mode: development
+ level: error
+
diff --git a/tests/plugins/http/http_plugin_test.go b/tests/plugins/http/http_plugin_test.go
index 88857df5..3aa0f57a 100644
--- a/tests/plugins/http/http_plugin_test.go
+++ b/tests/plugins/http/http_plugin_test.go
@@ -107,6 +107,70 @@ func TestHTTPInit(t *testing.T) {
wg.Wait()
}
+func TestHTTPNoConfigSection(t *testing.T) {
+ cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.ErrorLevel))
+ assert.NoError(t, err)
+
+ cfg := &config.Viper{
+ Path: "configs/.rr-no-http.yaml",
+ Prefix: "rr",
+ }
+
+ err = cont.RegisterAll(
+ cfg,
+ &logger.ZapLogger{},
+ &server.Plugin{},
+ &httpPlugin.Plugin{},
+ )
+ assert.NoError(t, err)
+
+ err = cont.Init()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ ch, err := cont.Serve()
+ assert.NoError(t, err)
+
+ sig := make(chan os.Signal, 1)
+ signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
+
+ wg := &sync.WaitGroup{}
+ wg.Add(1)
+
+ stopCh := make(chan struct{}, 1)
+ go func() {
+ defer wg.Done()
+ for {
+ select {
+ case e := <-ch:
+ assert.Fail(t, "error", e.Error.Error())
+ err = cont.Stop()
+ if err != nil {
+ assert.FailNow(t, "error", err.Error())
+ }
+ case <-sig:
+ err = cont.Stop()
+ if err != nil {
+ assert.FailNow(t, "error", err.Error())
+ }
+ return
+ case <-stopCh:
+ // timeout
+ err = cont.Stop()
+ if err != nil {
+ assert.FailNow(t, "error", err.Error())
+ }
+ return
+ }
+ }
+ }()
+
+ time.Sleep(time.Second * 2)
+ stopCh <- struct{}{}
+ wg.Wait()
+}
+
func TestHTTPInformerReset(t *testing.T) {
cont, err := endure.NewContainer(nil, endure.SetLogLevel(endure.ErrorLevel))
assert.NoError(t, err)