Skip to content

Commit

Permalink
Merge pull request #539 from megaease/pipeline
Browse files Browse the repository at this point in the history
Pipeline
  • Loading branch information
localvar committed Jun 29, 2022
2 parents 1053f3c + cb2674b commit d3732f5
Show file tree
Hide file tree
Showing 247 changed files with 16,002 additions and 18,330 deletions.
1 change: 1 addition & 0 deletions .github/workflows/code.analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- main
- pipeline
paths:
- "**/*.go"
- "go.mod"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/license-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- main
- pipeline
pull_request:
branches:
- main
- pipeline

jobs:
check-license:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: |
go mod verify
go mod download
go test -v ./...
go test -v ./pkg/...
integration-test-ubuntu:
needs: [test, test-win]
runs-on: ubuntu-latest
Expand All @@ -65,7 +65,7 @@ jobs:

- name: Test
run: |
make httpserver_test
make integration_test
goreleaser:
runs-on: ubuntu-latest
needs: integration-test-ubuntu
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- pipeline
paths:
- "**/*.go"
- "**/*.yaml"
Expand All @@ -15,6 +16,7 @@ on:
types: [opened, synchronize, reopened]
branches:
- main
- pipeline
paths:
- "**/*.go"
- "go.mod"
Expand Down Expand Up @@ -66,9 +68,8 @@ jobs:
run: |
go mod verify
go mod download
go test -v ./...
go test -v ./pkg/...
integration-test-ubuntu:
needs: [test, test-win]
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -83,5 +84,4 @@ jobs:

- name: Test
run: |
make httpserver_test
make integration_test
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
RELEASE_DIR := ${MKFILE_DIR}bin
GO_PATH := $(shell go env | grep GOPATH | awk -F '"' '{print $$2}')
HTTPSERVER_TEST_PATH := build/test
INTEGRATION_TEST_PATH := build/test

# Image Name
IMAGE_NAME?=megaease/easegress
Expand Down Expand Up @@ -98,16 +98,17 @@ build_docker:

test:
cd ${MKFILE_DIR}
go mod tidy
go mod tidy -compat=1.17
git diff --exit-code go.mod go.sum
go mod verify
go test -v ./... ${TEST_FLAGS}
go test -v ${MKFILE_DIR}pkg/... ${TEST_FLAGS}

httpserver_test: build
integration_test: build
{ \
set -e ;\
cd ${HTTPSERVER_TEST_PATH} ;\
./httpserver_test.sh ;\
cd ${INTEGRATION_TEST_PATH} ;\
./test.sh ;\
./clean.sh ;\
}

clean:
Expand Down
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Easegress

[![Go Report Card](https://goreportcard.com/badge/github.com/megaease/easegress)](https://goreportcard.com/report/github.com/megaease/easegress) [![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/megaease/easegress/Test/main)](https://github.com/megaease/easegress/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/megaease/easegress/branch/main/graph/badge.svg?token=5Q80B98LPI)](https://codecov.io/gh/megaease/easegress) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/megaease/easegress)](https://github.com/megaease/easegress/blob/main/go.mod) [![Join MegaEase Slack](https://img.shields.io/badge/slack-megaease-brightgreen?logo=slack)](https://join.slack.com/t/openmegaease/shared_invite/zt-upo7v306-lYPHvVwKnvwlqR0Zl2vveA)
[![Go Report Card](https://goreportcard.com/badge/github.com/megaease/easegress)](https://goreportcard.com/report/github.com/megaease/easegress)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/megaease/easegress/Test/main)](https://github.com/megaease/easegress/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/megaease/easegress/branch/main/graph/badge.svg?token=5Q80B98LPI)](https://codecov.io/gh/megaease/easegress)
[![Docker pulls](https://img.shields.io/docker/pulls/megaease/easegress.svg)](https://hub.docker.com/r/megaease/easegress)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/megaease/easegress)](https://github.com/megaease/easegress/blob/main/go.mod)
[![Join MegaEase Slack](https://img.shields.io/badge/slack-megaease-brightgreen?logo=slack)](https://join.slack.com/t/openmegaease/shared_invite/zt-upo7v306-lYPHvVwKnvwlqR0Zl2vveA)

<a href="https://megaease.com/easegress">
<img src="./doc/imgs/easegress.svg"
Expand Down Expand Up @@ -47,10 +53,10 @@ The architecture of Easegress:
- MQTT
- **Rich Routing Rules:** exact path, path prefix, regular expression of the path, method, headers.
- **Resilience&Fault Tolerance**
- **Circuit breaker:** temporarily blocks possible failures.
- **Rate limiter:** limits the rate of incoming requests.
- **Retryer:** repeats failed executions.
- **Time limiter:** limits the duration of execution.
- **Circuit break:** temporarily blocks possible failures.
- **Rate limit:** limits the rate of incoming requests.
- **Retry:** repeats failed executions.
- **Time limit:** limits the duration of execution.
- **Deployment Management**
- **Blue-green Strategy:** switches traffic at one time.
- **Canary Strategy:** schedules traffic slightly.
Expand Down Expand Up @@ -103,7 +109,7 @@ The architecture of Easegress:

The following examples show how to use Easegress for different scenarios.

- [API Aggregator](./doc/cookbook/api-aggregator.md) - Aggregating many APIs into a single API.
- [API Aggregation](./doc/cookbook/api-aggregation.md) - Aggregating many APIs into a single API.
- [Cluster Deployment](./doc/cookbook/multi-node-cluster.md) - How to deploy multiple Easegress cluster nodes.
- [Distributed Tracing](./doc/cookbook/distributed-tracing.md) - How to do APM tracing - Zipkin.
- [FaaS](./doc/cookbook/faas.md) - Supporting Knative FaaS integration
Expand All @@ -113,7 +119,7 @@ The following examples show how to use Easegress for different scenarios.
- [MQTTProxy](./doc/cookbook/mqtt-proxy.md) - An Example to MQTT proxy with Kafka backend.
- [Performance](./doc/cookbook/performance.md) - Performance optimization - compression, caching etc.
- [Pipeline](./doc/cookbook/pipeline.md) - How to orchestrate HTTP filters for requests/responses handling
- [Resilience and Fault Tolerance](./doc/cookbook/resilience.md) - Circuit Breaker, Rate Limiter, Retryer, Time limiter, etc. (Porting from [Java resilience4j](https://github.com/resilience4j/resilience4j))
- [Resilience and Fault Tolerance](./doc/cookbook/resilience.md) - Circuit Break, Rate Limit, Retry, Time Limit, etc. (Porting from [Java resilience4j](https://github.com/resilience4j/resilience4j))
- [Security](./doc/cookbook/security.md) - How to do authentication by Header, JWT, HMAC, OAuth2, etc.
- [Service Proxy](./doc/cookbook/service-proxy.md) - Supporting the Microservice registries - Zookeeper, Eureka, Consul, Nacos, etc.
- [WebAssembly](./doc/cookbook/wasm.md) - Using AssemblyScript to extend the Easegress
Expand Down Expand Up @@ -213,14 +219,14 @@ The rules of routers above mean that it will lead the traffic with the prefix `/
```bash
$ echo '
name: pipeline-demo
kind: HTTPPipeline
kind: Pipeline
flow:
- filter: proxy
filters:
- name: proxy
kind: Proxy
mainPool:
servers:
pools:
- servers:
- url: http:https://127.0.0.1:9095
- url: http:https://127.0.0.1:9096
- url: http:https://127.0.0.1:9097
Expand Down Expand Up @@ -262,7 +268,7 @@ Now we want to add more features to the pipeline, then we could add kinds of fil
```bash
$ cat pipeline-demo.yaml
name: pipeline-demo
kind: HTTPPipeline
kind: Pipeline
flow:
- filter: validator
jumpIf: { invalid: END }
Expand All @@ -282,8 +288,8 @@ filters:
X-Adapt-Key: goodplan
- name: proxy
kind: Proxy
mainPool:
servers:
pools:
- servers:
- url: http:https://127.0.0.1:9095
- url: http:https://127.0.0.1:9096
- url: http:https://127.0.0.1:9097
Expand Down
22 changes: 14 additions & 8 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Easegress

[![Go Report Card](https://goreportcard.com/badge/github.com/megaease/easegress)](https://goreportcard.com/report/github.com/megaease/easegress) [![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/megaease/easegress/Test/main)](https://github.com/haoel/easegress/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/megaease/easegress/branch/main/graph/badge.svg?token=5Q80B98LPI)](https://codecov.io/gh/megaease/easegress) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/megaease/easegress)](https://github.com/haoel/easegress/blob/main/go.mod) [![Join MegaEase Slack](https://img.shields.io/badge/slack-megaease-brightgreen?logo=slack)](https://join.slack.com/t/openmegaease/shared_invite/zt-upo7v306-lYPHvVwKnvwlqR0Zl2vveA)
[![Go Report Card](https://goreportcard.com/badge/github.com/megaease/easegress)](https://goreportcard.com/report/github.com/megaease/easegress)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/megaease/easegress/Test/main)](https://github.com/megaease/easegress/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/megaease/easegress/branch/main/graph/badge.svg?token=5Q80B98LPI)](https://codecov.io/gh/megaease/easegress)
[![Docker pulls](https://img.shields.io/docker/pulls/megaease/easegress.svg)](https://hub.docker.com/r/megaease/easegress)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/megaease/easegress)](https://github.com/megaease/easegress/blob/main/go.mod)
[![Join MegaEase Slack](https://img.shields.io/badge/slack-megaease-brightgreen?logo=slack)](https://join.slack.com/t/openmegaease/shared_invite/zt-upo7v306-lYPHvVwKnvwlqR0Zl2vveA)

<a href="https://megaease.com/easegress">
<img src="./doc/imgs/easegress.svg"
Expand Down Expand Up @@ -102,7 +108,7 @@

下面的例子展示了如何在不同场景下使用 Easegress。

- [API 聚合](./doc/cookbook/api-aggregator.md) - 将多个 API 聚合为一个。
- [API 聚合](./doc/cookbook/api-aggregation.md) - 将多个 API 聚合为一个。
- [Easegress 集群化部署](./doc/cookbook/multi-node-cluster.md) - Easegress 如何进行集群化多点部署。
- [分布式调用链](./doc/cookbook/distributed-tracing.md) - 如何使用 Zipkin 进行 APM 追踪。
- [函数即服务 FaaS](./doc/cookbook/faas.md) - 支持 Knative FaaS 集成。
Expand Down Expand Up @@ -212,14 +218,14 @@ rules:
```bash
$ echo '
name: pipeline-demo
kind: HTTPPipeline
kind: Pipeline
flow:
- filter: proxy
filters:
- name: proxy
kind: Proxy
mainPool:
servers:
pools:
- servers:
- url: http:https://127.0.0.1:9095
- url: http:https://127.0.0.1:9096
- url: http:https://127.0.0.1:9097
Expand Down Expand Up @@ -261,7 +267,7 @@ Body : Hello, Easegress
```bash
$ cat pipeline-demo.yaml
name: pipeline-demo
kind: HTTPPipeline
kind: Pipeline
flow:
- filter: validator
jumpIf: { invalid: END }
Expand All @@ -281,8 +287,8 @@ filters:
X-Adapt-Key: goodplan
- name: proxy
kind: Proxy
mainPool:
servers:
pools:
- servers:
- url: http:https://127.0.0.1:9095
- url: http:https://127.0.0.1:9096
- url: http:https://127.0.0.1:9097
Expand Down
39 changes: 39 additions & 0 deletions build/test/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Copyright (c) 2017, MegaEase
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Test the Easegress' basic functionality which is generating
# an HTTPServer and Pipeline for testing HTTP Requests.
set -e

# path related define.
# Note: use $(dirname $(realpath ${BASH_SOURCE[0]})) to value SCRIPTPATH is OK in linux platform,
# but not in MacOS.(cause there is not `realpath` in it)
# reference: https://stackoverflow.com/questions/4774054/reliable-way-for-a-bash-script-to-get-the-full-path-to-itself
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
pushd $SCRIPTPATH"/../../example" > /dev/null
EXAMPLEDIR="$SCRIPTPATH"/../../example

# clean cleans primary-single's data and cluster data and the `go run` process.
function clean()
{
# basic cleaning routine
bash $EXAMPLEDIR/stop_cluster.sh
bash $EXAMPLEDIR/clean_cluster.sh
}

# clean the cluster resource.
clean
101 changes: 101 additions & 0 deletions build/test/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2017, MegaEase
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package test

import (
"fmt"
"io"
"net/http"
"strings"
"testing"

"github.com/stretchr/testify/require"
)

func makeURL(template string, a ...interface{}) string {
return "http:https://127.0.0.1:12381/apis/v1" + fmt.Sprintf(template, a...)
}

func successfulStatusCode(code int) bool {
return code >= 200 && code < 300
}

func intentString(str string) string {
return "\n\t\t" + strings.ReplaceAll(str, "\n", "\n\t\t")
}

func handleRequest(t *testing.T, method string, url string, reader io.Reader) *http.Response {
req, err := http.NewRequest(method, url, reader)
require.Nil(t, err)
resp, err := http.DefaultClient.Do(req)
require.Nil(t, err)
return resp
}

const (
objectsURL = "/objects"
objectURL = "/objects/%s"
)

func createObject(t *testing.T, yamlFile string) (ok bool, msg string) {
resp := handleRequest(t, http.MethodPost, makeURL(objectsURL), strings.NewReader(yamlFile))
defer resp.Body.Close()

ok = successfulStatusCode(resp.StatusCode)
if !ok {
data, err := io.ReadAll(resp.Body)
require.Nil(t, err)
msg = fmt.Sprintf("create object\n %v\nfailed, %v", intentString(yamlFile), intentString(string(data)))
}
return
}

func updateObject(t *testing.T, name string, yamlFile string) (ok bool, msg string) {
resp := handleRequest(t, http.MethodPut, makeURL(objectURL, name), strings.NewReader(yamlFile))
defer resp.Body.Close()

ok = successfulStatusCode(resp.StatusCode)
if !ok {
data, err := io.ReadAll(resp.Body)
require.Nil(t, err)
msg = fmt.Sprintf("update object %v\n %v\nfailed, %v", name, intentString(yamlFile), intentString(string(data)))
}
return
}

func deleteObject(t *testing.T, name string) (ok bool, msg string) {
resp := handleRequest(t, http.MethodDelete, makeURL(objectURL, name), nil)
defer resp.Body.Close()

ok = successfulStatusCode(resp.StatusCode)
if !ok {
data, err := io.ReadAll(resp.Body)
require.Nil(t, err)
msg = fmt.Sprintf("delete object %v failed, %v", name, intentString(string(data)))
}
return ok, msg
}

func listObject(t *testing.T) (ok bool, msg string) {
resp := handleRequest(t, http.MethodGet, makeURL(objectsURL), nil)
defer resp.Body.Close()

data, err := io.ReadAll(resp.Body)
require.Nil(t, err)
return successfulStatusCode(resp.StatusCode), string(data)
}
Loading

0 comments on commit d3732f5

Please sign in to comment.