Skip to content

Commit

Permalink
Merge branch 'apache:master' into fix-rpc-type
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLYC committed Sep 23, 2022
2 parents eabbd05 + bd5d11f commit 71906e7
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 28 deletions.
33 changes: 17 additions & 16 deletions ci/apisix/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@
# limitations under the License.
#

apisix:
allow_admin:
- 0.0.0.0/0
enable_control: true
control:
ip: "0.0.0.0"
port: 9092
admin_key:
- name: admin
key: edd1c9f034335f136f87ad84b625c8f1
role: admin
etcd:
host:
- http://etcd:2379
prefix: "/apisix"
timeout: 30
deployment:
admin:
allow_admin:
- 0.0.0.0/0
enable_control: true
control:
ip: "0.0.0.0"
port: 9092
admin_key:
- name: admin
key: edd1c9f034335f136f87ad84b625c8f1
role: admin
etcd:
host:
- "http://etcd:2379"
prefix: /apisix
timeout: 30
ext-plugin:
path_for_test: /tmp/runner.sock
nginx_config:
Expand Down
1 change: 1 addition & 0 deletions ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
depends_on:
- etcd
ports:
- "9180:9180/tcp"
- "9080:9080/tcp"
- "9091:9091/tcp"
- "9443:9443/tcp"
Expand Down
26 changes: 26 additions & 0 deletions docs/en/latest/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ We can see that the interface returns hello and does not access anything upstrea

### Setting up APISIX (running)

#### Setting up directly

Here's an example of go-runner, you just need to configure the command line to run it inside ext-plugin:

```
Expand All @@ -270,3 +272,27 @@ ext-plugin:
APISIX will treat the plugin runner as a child process of its own, managing its entire lifecycle.

APISIX will automatically assign a unix socket address for the runner to listen to when it starts. environment variables do not need to be set manually.

#### Setting up in container

First you need to prepare the go-runner binary. Use this command:

```shell
make build
```

:::note
When you use a Linux distribution such as Alpine Linux that is not based on standard glibc, you must turn off Golang's CGO support via the `CGO_ENABLED=0` environment variable to avoid libc ABI incompatibilities.

If you want to use CGO, then you must build the binaries using the Go compiler and the C compiler in the same Linux distribution.
:::

Then you need to rebuild the container image to include the go-runner binary. You can use the following Dockerfile:

```
FROM apache/apisix:2.15.0-debian
COPY ./go-runner /usr/local/apisix-go-plugin-runner/go-runner
```

Finally, you can push and run your custom image, just configure the binary path and commands in the configuration file via `ext-plugin.cmd` to start APISIX with go plugin runner.
4 changes: 2 additions & 2 deletions tests/e2e/plugins/plugins_fault_injection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var _ = ginkgo.Describe("Fault-injection plugin", func() {
tools.RunTestCase(tc)
},
table.Entry("Config APISIX.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6CPExpect(),
Method: http.MethodPut,
Path: "/apisix/admin/routes/1",
Body: `{
Expand All @@ -58,7 +58,7 @@ var _ = ginkgo.Describe("Fault-injection plugin", func() {
ExpectStatusRange: httpexpect.Status2xx,
}),
table.Entry("Test if fault-injection plugin work.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6DPExpect(),
Method: http.MethodGet,
Path: "/test/go/runner/faultinjection",
ExpectBody: []string{"hello"},
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/plugins/plugins_limit_req_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var _ = ginkgo.Describe("Limit-req Plugin", func() {
tools.RunTestCase(tc)
},
table.Entry("Config APISIX.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6CPExpect(),
Method: http.MethodPut,
Path: "/apisix/admin/routes/1",
Body: `{
Expand All @@ -58,7 +58,7 @@ var _ = ginkgo.Describe("Limit-req Plugin", func() {
ExpectStatusRange: httpexpect.Status2xx,
}),
table.Entry("Test if limit-req plugin work.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6DPExpect(),
Method: http.MethodGet,
Path: "/test/go/runner/limitreq",
ExpectStatus: http.StatusOK,
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/plugins/plugins_response_rewrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var _ = ginkgo.Describe("ResponseRewrite Plugin", func() {
tools.RunTestCase(tc)
},
table.Entry("Config APISIX.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6CPExpect(),
Method: http.MethodPut,
Path: "/apisix/admin/routes/1",
Body: `{
Expand All @@ -58,7 +58,7 @@ var _ = ginkgo.Describe("ResponseRewrite Plugin", func() {
ExpectStatusRange: httpexpect.Status2xx,
}),
table.Entry("Should rewrite response.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6DPExpect(),
Method: http.MethodGet,
Path: "/test/go/runner/say",
ExpectBody: []string{"response rewrite"},
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/plugins/plugins_say_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var _ = ginkgo.Describe("Say Plugin", func() {
tools.RunTestCase(tc)
},
table.Entry("Config APISIX.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6CPExpect(),
Method: http.MethodPut,
Path: "/apisix/admin/routes/1",
Body: `{
Expand All @@ -58,7 +58,7 @@ var _ = ginkgo.Describe("Say Plugin", func() {
ExpectStatusRange: httpexpect.Status2xx,
}),
table.Entry("Should return hello.", tools.HttpTestCase{
Object: tools.GetA6Expect(),
Object: tools.GetA6DPExpect(),
Method: http.MethodGet,
Path: "/test/go/runner/say",
ExpectBody: []string{"hello"},
Expand Down
14 changes: 10 additions & 4 deletions tests/e2e/tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,23 @@ import (
)

var (
token = "edd1c9f034335f136f87ad84b625c8f1"
A6Host = "http://127.0.0.1:9080"
token = "edd1c9f034335f136f87ad84b625c8f1"
A6DPHost = "http://127.0.0.1:9080"
A6CPHost = "http://127.0.0.1:9180"
)

func GetAdminToken() string {
return token
}

func GetA6Expect() *httpexpect.Expect {
func GetA6DPExpect() *httpexpect.Expect {
t := ginkgo.GinkgoT()
return httpexpect.New(t, A6Host)
return httpexpect.New(t, A6DPHost)
}

func GetA6CPExpect() *httpexpect.Expect {
t := ginkgo.GinkgoT()
return httpexpect.New(t, A6CPHost)
}

type HttpTestCase struct {
Expand Down

0 comments on commit 71906e7

Please sign in to comment.