Skip to content

Commit de0d849

Browse files
sam-heilbronsoloio-bulldozer[bot]jbohanonNadine2016
committed
introduce test coverage reporting, update devel with Gloo Gateway references (#9646)
* devel/ : Gloo Edge -> Gloo Gateway * more changes * update workflows, add go-test-with-coverage * run unit tests on PR * update name * fix coverage file path * consistent step names * disable race to prove out test coverage * add working dir * properly specify outputdir * test coverage update * install test tools * install tools and coverage tools * update thresholds, ignore errors in CI * update test coverage def * add changleog * update commet in gha * re-add race flag * E.T phone home * Apply suggestions from code review Co-authored-by: Jacob Bohanon <jacob.bohanon@solo.io> * Apply suggestions from code review Co-authored-by: Nadine Spies <17709352+Nadine2016@users.noreply.github.com> * more suggestions * skip kube tests --------- Co-authored-by: soloio-bulldozer[bot] <48420018+soloio-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Jacob Bohanon <jacob.bohanon@solo.io> Co-authored-by: Nadine Spies <17709352+Nadine2016@users.noreply.github.com>
1 parent 0672cee commit de0d849

26 files changed

+188
-157
lines changed

.github/workflows/pr-unit-tests.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Unit Tests
2+
3+
# This workflow invokes unit tests for the Gloo Gateway project
4+
# It was introduced during the 1.17 quarter, where we added a new project (projects/gateway2)
5+
# and therefore we only run those new tests here
6+
#
7+
# Our historical unit tests are run via CloudBuild
8+
# Overtime, it would be valuable to consolidate these approaches
9+
10+
on:
11+
pull_request:
12+
types: [opened, synchronize, reopened, ready_for_review]
13+
14+
jobs:
15+
# Runs the unit tests for `projects/gateway2`
16+
kube_gateway_project:
17+
name: projects/gateway2
18+
runs-on: ubuntu-22.04
19+
timeout-minutes: 10
20+
# Other unit tests are run by our CloudBuild runner
21+
# These tests do run on Draft PRs, and so we maintain that consistency and run this job on Draft PRs as well
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Setup Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version-file: go.mod
28+
- name: Build
29+
run: go build -v ./projects/gateway2/... ./projects/gloo/cli/cmd
30+
- name: Install Test Utils
31+
shell: bash
32+
run: make -C ./projects/gateway2/ install-go-tools
33+
- name: Install Test Coverage Tools
34+
shell: bash
35+
run: make install-go-test-coverage
36+
- name: Run Tests
37+
shell: bash
38+
env:
39+
TEST_PKG: ./projects/gateway2/...
40+
run: make go-test-with-coverage
41+
- name: Validate Test Coverage
42+
shell: bash
43+
# The make will error if test coverage drops below a certain threshold
44+
# We intentionally ignore the errors while we build out our test coverage, to establish a good baseline
45+
# However, we should strive to establish a baseline, and then make it required on PRs
46+
run: make --always-make --ignore-errors validate-test-coverage

.github/workflows/pr.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ install-go-tools: mod-download ## Download and install Go dependencies
165165
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(LINTER_VERSION)
166166
go install github.com/quasilyte/go-ruleguard/cmd/ruleguard@v0.3.16
167167

168+
.PHONY: install-go-test-coverage
169+
install-go-test-coverage:
170+
go install github.com/vladopajic/go-test-coverage/v2@v2.8.1
171+
168172
.PHONY: check-format
169173
check-format:
170174
NOT_FORMATTED=$$(gofmt -l ./projects/ ./pkg/ ./test/) && if [ -n "$$NOT_FORMATTED" ]; then echo These files are not formatted: $$NOT_FORMATTED; exit 1; fi
@@ -194,7 +198,7 @@ GINKGO_VERSION ?= $(shell echo $(shell go list -m github.com/onsi/ginkgo/v2) | c
194198
GINKGO_ENV ?= GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore ACK_GINKGO_RC=true ACK_GINKGO_DEPRECATIONS=$(GINKGO_VERSION)
195199
GINKGO_FLAGS ?= -tags=purego --trace -progress -race --fail-fast -fail-on-pending --randomize-all --compilers=5
196200
GINKGO_REPORT_FLAGS ?= --json-report=test-report.json --junit-report=junit.xml -output-dir=$(OUTPUT_DIR)
197-
GINKGO_COVERAGE_FLAGS ?= --cover --covermode=count --coverprofile=coverage.cov
201+
GINKGO_COVERAGE_FLAGS ?= --cover --covermode=atomic --coverprofile=coverage.cov
198202
TEST_PKG ?= ./... # Default to run all tests
199203

200204
# This is a way for a user executing `make test` to be able to provide flags which we do not include by default
@@ -237,6 +241,7 @@ test: ## Run all tests, or only run the test package at {TEST_PKG} if it is spec
237241
$(GINKGO_FLAGS) $(GINKGO_REPORT_FLAGS) $(GINKGO_USER_FLAGS) \
238242
$(TEST_PKG)
239243

244+
# https://go.dev/blog/cover#heat-maps
240245
.PHONY: test-with-coverage
241246
test-with-coverage: GINKGO_FLAGS += $(GINKGO_COVERAGE_FLAGS)
242247
test-with-coverage: test
@@ -277,7 +282,8 @@ GO_TEST_ENV ?= GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore
277282
# Testings flags: https://pkg.go.dev/cmd/go#hdr-Testing_flags
278283
# The default timeout for a suite is 10 minutes, but this can be overridden by setting the -timeout flag. Currently set
279284
# to 25 minutes based on the time it takes to run the longest test setup (k8s_gw_test).
280-
GO_TEST_ARGS ?= -timeout=25m -cpu=4 -race
285+
GO_TEST_ARGS ?= -timeout=25m -cpu=4 -race -outputdir=$(OUTPUT_DIR)
286+
GO_TEST_COVERAGE_ARGS ?= --cover --covermode=atomic --coverprofile=cover.out
281287

282288
# This is a way for a user executing `make go-test` to be able to provide args which we do not include by default
283289
# For example, you may want to run tests multiple times, or with various timeouts
@@ -290,6 +296,19 @@ go-test: clean-bug-report $(BUG_REPORT_DIR) # Ensure the bug_report dir is reset
290296
$(GO_TEST_ARGS) $(GO_TEST_USER_ARGS) \
291297
$(TEST_PKG)
292298

299+
# https://go.dev/blog/cover#heat-maps
300+
.PHONY: go-test-with-coverage
301+
go-test-with-coverage: GO_TEST_ARGS += $(GO_TEST_COVERAGE_ARGS)
302+
go-test-with-coverage: go-test
303+
304+
.PHONY: validate-test-coverage
305+
validate-test-coverage:
306+
${GOBIN}/go-test-coverage --config=./test_coverage.yml
307+
308+
.PHONY: view-test-coverage
309+
view-test-coverage:
310+
go tool cover -html $(OUTPUT_DIR)/cover.out
311+
293312
#----------------------------------------------------------------------------------
294313
# Clean
295314
#----------------------------------------------------------------------------------

README.md

Lines changed: 9 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22

33
<h1 align="center">
4-
<img src="https://github.com/solo-io/gloo/blob/v2.0.x/docs/content/img/logo-gloo-gateway-horizontal.svg" alt="Gloo Gateway v2" width="800">
4+
<img src="https://github.com/solo-io/gloo/blob/main/docs/content/img/logo-gloo-gateway-horizontal.svg" alt="Gloo Gateway" width="800">
55
<br>
66
An Envoy-Powered API Gateway
77
</h1>
@@ -11,89 +11,19 @@
1111
> **Important**
1212
> Gloo Gateway is now a fully conformant Kubernetes Gateway API implementation!
1313
>
14-
> The existing Gloo Edge v1 APIs were not changed and continue to be fully supported.
14+
> The existing Gloo Edge APIs were not changed and continue to be fully supported.
1515
1616
## About Gloo Gateway
1717
Gloo Gateway is a powerful Kubernetes-native ingress controller and API gateway that is based on the Kubernetes Gateway API. It excels in function-level routing, supports legacy apps, microservices and serverless, offers robust discovery capabilities, integrates seamlessly with open-source projects, and is designed to support hybrid applications with various technologies, architectures, protocols, and clouds.
1818

19-
[**Installation**](https://docs.solo.io/gloo-gateway/v2/quickstart) &nbsp; |
20-
&nbsp; [**Documentation**](https://docs.solo.io/gloo-gateway/v2) &nbsp; |
19+
[**Installation**](https://docs.solo.io/gateway/latest/quickstart/) &nbsp; |
20+
&nbsp; [**Documentation**](https://docs.solo.io/gateway/latest/) &nbsp; |
2121
&nbsp; [**Blog**](https://www.solo.io/blog/?category=gloo) &nbsp; |
2222
&nbsp; [**Slack**](https://slack.solo.io) &nbsp; |
2323
&nbsp; [**Twitter**](https://twitter.com/soloio_inc) |
2424
&nbsp; [**Enterprise Trial**](https://www.solo.io/free-trial/)
2525

26-
<BR><center><img src="https://docs.solo.io/gloo-edge/main/img/gloo-architecture-envoys.png" alt="Gloo Gateway v2 Architecture" width="906"></center>
27-
28-
## Quickstart with `glooctl`
29-
Install Gloo Gateway and set up routing to the httpbin sample app.
30-
31-
1. Install `glooctl`, the Gloo Gateway command line tool.
32-
```sh
33-
curl -sL https://run.solo.io/gloo/install | GLOO_VERSION=v2.0.0-beta1 sh
34-
export PATH=$HOME/.gloo/bin:$PATH
35-
```
36-
37-
2. Install the Gloo Gateway v2 control plane, and wait for it to come up.
38-
```sh
39-
glooctl install
40-
```
41-
42-
3. Deploy the httpbin sample app, along with a Gateway and HTTPRoute to access it.
43-
```sh
44-
kubectl -n httpbin apply -f https://raw.githubusercontent.com/solo-io/gloo/v2.0.x/projects/gateway2/examples/httpbin.yaml
45-
```
46-
47-
4. Port-forward the Gateway.
48-
```sh
49-
kubectl port-forward deployment/gloo-proxy-http -n httpbin 8080:8080
50-
```
51-
52-
5. Send a request through our new Gateway.
53-
```sh
54-
curl -I localhost:8080/status/200 -H "host: www.example.com" -v
55-
```
56-
57-
Congratulations! You successfully installed Gloo Gateway and used an HTTP gateway to expose the httpbin sample app.
58-
59-
> **Note**
60-
> To learn more about Gloo Gateway's support for the Kubernetes Gateway API, see the [docs](https://docs.solo.io/gloo-gateway/v2/).
61-
62-
## Quickstart with Helm
63-
64-
1. Install the custom resources of the Kubernetes Gateway API.
65-
```sh
66-
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml
67-
```
68-
69-
2. Install Gloo Gateway v2. This command creates the `gloo-system` namespace and installs the Gloo Gateway v2 control plane into it.
70-
```sh
71-
helm install default -n gloo-system --create-namespace oci://ghcr.io/solo-io/helm-charts/gloo-gateway --version 2.0.0-beta1
72-
```
73-
74-
3. Verify that the Gloo Gateway v2 control plane is up and running and that the `gloo-gateway` GatewayClass is created.
75-
```sh
76-
kubectl get pods -n gloo-system
77-
kubectl get gatewayclass gloo-gateway
78-
```
79-
80-
4. Deploy the httpbin sample app, along with a Gateway and HTTPRoute to access it.
81-
```sh
82-
kubectl -n httpbin apply -f https://raw.githubusercontent.com/solo-io/gloo/v2.0.x/projects/gateway2/examples/httpbin.yaml
83-
```
84-
85-
5. Port-forward the Gateway.
86-
```sh
87-
kubectl port-forward deployment/gloo-proxy-http -n httpbin 8080:8080
88-
```
89-
90-
6. Send a request through our new Gateway.
91-
```sh
92-
curl -I localhost:8080/status/200 -H "host: www.example.com" -v
93-
```
94-
95-
> **Note**
96-
> To learn more about Gloo Gateway's support for the Kubernetes Gateway API, see the [docs](https://docs.solo.io/gloo-gateway/v2/).
26+
<BR><center><img src="https://docs.solo.io/gloo-edge/main/img/gloo-architecture-envoys.png" alt="Gloo Gateway Architecture" width="906"></center>
9727

9828
### Using Gloo Gateway
9929
- **Kubernetes Gateway API**: Gloo Gateway is a feature-rich ingress controller, built on top of the Envoy Proxy and fully conformant with the Kubernetes Gateway API.
@@ -113,14 +43,14 @@ C) Allow different teams in an organization choose different architectures. See
11343
## Next Steps
11444
- Join us on our Slack channel: [https://slack.solo.io/](https://slack.solo.io/)
11545
- Follow us on Twitter: [https://twitter.com/soloio_inc](https://twitter.com/soloio_inc)
116-
- Check out the docs: [https://docs.solo.io/gloo-gateway/v2](https://docs.solo.io/gloo-gateway/v2)
117-
- Check out the code and contribute: [Contribution Guides](/devel/contributing)
46+
- Check out the docs: [https://docs.solo.io/gateway/latest/](https://docs.solo.io/gateway/latest/)
11847

119-
## Thanks
48+
## Contributing to Gloo Gateway
49+
The [devel](devel) folder should be the starting point for understanding the code, and contributing to the product.
12050

51+
## Thanks
12152
**Gloo Gateway** would not be possible without the valuable open-source work of projects in the community. We would like to extend a special thank-you to [Envoy](https://www.envoyproxy.io).
12253

12354

12455
## Security
125-
12656
*Reporting security issues* : We take Gloo Gateway's security very seriously. If you've found a security issue or a potential security issue in Gloo Gateway, please DO NOT file a public Github issue, instead send your report privately to [security@solo.io](mailto:security@solo.io).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
changelog:
2+
- type: NON_USER_FACING
3+
issueLink: https://github.com/solo-io/solo-projects/issues/6026
4+
resolvesIssue: false
5+
description: >-
6+
Introduce code coverage tooling, introduce a basic check on projects/gateway2 tests
7+
so that users have some feedback (that is not yet required).
8+
9+
Update the `devel` folder to remove Gloo Edge references, and replace with Gloo Gateway
10+
11+
skipCI-kube-tests:true

devel/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# Developing Gloo Edge
1+
# Developing Gloo Gateway
22

3-
Find tools and information to help you develop the Gloo Edge project.
3+
Find tools and information to help you develop the Gloo Gateway project.
44

5+
* `architecture`: Descriptions about high-level design and implementation details of various packages and features.
56
* `contributing`: Information to help you contribute to the project, such as how to open issues, review pull requests, generate code, and backport fixes.
67
* `debugging`: Troubleshooting steps for debugging frequent issues.
78
* `testing`: Descriptions on how the tests work and how to use them.
8-
* `tools`: A set of scripts and tools that are intended to help you develop the Gloo Edge project's codebase. Learn more about these tools in the short descriptions later in this readme.
9-
10-
_**Note**: For tools that help maintain an installation of Gloo Edge (the product, not the project codebase), build those tools into the [CLI](/projects/gloo/cli) instead._
9+
* `tools`: A set of scripts and tools that are intended to help you develop the Gloo Gateway project's codebase. Learn more about these tools in the short descriptions later in this readme.
1110

1211
Other resources:
13-
* [Developer guide](https://docs.solo.io/gloo-edge/latest/guides/dev/) to set up your development environment and learn more about extending the functionality of the Gloo Edge project and related plug-ins. While written for external contributors, internal Solo developers might also find this guide helpful when onboarding.
14-
* [Product documentation](https://docs.solo.io/gloo-edge/latest/) with guides for end users to use Gloo Edge as a product
12+
* [Developer guide](https://docs.solo.io/gloo-edge/latest/guides/dev/) to set up your development environment and learn more about extending the functionality of the Gloo Gateway project and related plug-ins. While written for external contributors, internal Solo developers might also find this guide helpful when onboarding.
13+
* [Product documentation](https://docs.solo.io/gloo-edge/latest/) with guides for end users to use Gloo Gateway as a product
1514
* [Guide to contribute to the documentation](https://docs.solo.io/gloo-edge/latest/contributing/documentation/)

devel/architecture/endpoint-discovery.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Endpoint Discovery Service (EDS)
22

33
## Overview
4-
Envoy supports a variety of mechanisms to configure [Service Discovery](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/service_discovery#arch-overview-service-discovery), the mechanism Envoy uses to resolve the members of the cluster. One of the more complex mechanisms is [EDS](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/service_discovery#endpoint-discovery-service-eds), where the xDS management server (Gloo Edge) provides the Endpoints for a given Cluster via an API.
4+
Envoy supports a variety of mechanisms to configure [Service Discovery](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/service_discovery#arch-overview-service-discovery), the mechanism Envoy uses to resolve the members of the cluster. One of the more complex mechanisms is [EDS](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/service_discovery#endpoint-discovery-service-eds), where the xDS management server (Gloo Gateway) provides the Endpoints for a given Cluster via an API.
55

6-
In Gloo Edge, Endpoints can be discovered dynamically via the Endpoint Discovery feature, and then served to the Envoy proxy via the EDS API.
6+
In Gloo Gateway, Endpoints can be discovered dynamically via the Endpoint Discovery feature, and then served to the Envoy proxy via the EDS API.
77

88
## How it works
9-
EDS runs in the [Gloo](/projects/gloo) component of Gloo Edge.
9+
EDS runs in the [Gloo](/projects/gloo) component of Gloo Gateway.
1010

1111
We rely on an [In Memory Endpoint Client](https://github.com/solo-io/gloo/blob/a39fb91c2fb122d5a34353dff891e0b0044bf1dc/projects/gloo/pkg/syncer/setup/setup_syncer.go#L469), meaning that when we “write” an Endpoint, it is just persisted in memory. In Memory clients signal updates to the emitter by two mechanisms:
1212
- [timed update](https://github.com/solo-io/solo-kit/blob/1f34a76bf919fd40a50e4504a837ee4b41b7f215/pkg/api/v1/clients/memory/resource_client.go#L238)

devel/architecture/external-options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# External Options (VirtualHostOption and RouteOption)
22

33
## Overview
4-
Gloo Edge supports decoupling certain resources from the definitions of options related to the resource. Currently there are two objects which support delegating options definition in this way:
4+
Gloo Gateway supports decoupling certain resources from the definitions of options related to the resource. Currently there are two objects which support delegating options definition in this way:
55
- A VirtualHost (exists on a VirtualService) can be configured with the separate resource [VirtualHostOption](./projects/gateway/api/v1/external_options.proto).
66
- A Route (exists on a VirtualHost within a VirtualService or on a RouteTable) can be configured with the separate resource [RouteOption](./projects/gateway/api/v1/external_options.proto).
77

devel/architecture/static_metadata.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The [Gloo Proxy Api](https://docs.solo.io/gloo-edge/latest/reference/api/github.
88

99
This metadata is not required and the `resourceKind`, `resourceRef.name`, and `resourceRef.namespace` fields which compose the metadata are plain strings.
1010

11-
While the objects used to create the Proxy Api resources are and should be generally irrelevant to the functionality of Gloo Edge, they do provide user facing value as sources of names and labels.
11+
While the objects used to create the Proxy Api resources are and should be generally irrelevant to the functionality of Gloo Gateway, they do provide user facing value as sources of names and labels.
1212

1313
## Current uses of this data
1414
### Open Telemetry `service.name`

devel/architecture/upstream-discovery.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
## Overview
44
A [Gloo Upstream](/projects/gloo/api/v1/upstream.proto) represents a destination for routing HTTP requests. An Upstream can be compared to [clusters](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/cluster.proto) in Envoy terminology.
55

6-
Upstreams can either be defined statically in a cluster, or can be discovered dynamically via Gloo Edge's Upstream Discovery feature.
6+
Upstreams can either be defined statically in a cluster, or can be discovered dynamically via Gloo Gateway's Upstream Discovery feature.
77

88
## How it works
9-
UDS runs in the [Discovery](/projects/discovery) component of Gloo Edge.
9+
UDS runs in the [Discovery](/projects/discovery) component of Gloo Gateway.
1010

1111
Create a [discovery emitter](https://github.com/solo-io/gloo/blob/8bbe175ea136178bfe8b4d103ae702d4965c4c75/projects/gloo/pkg/api/v1/discovery_snapshot_emitter.sk.go#L135), which is responsible for the following:
1212
- Emit a snapshot of the resources that are required for UDS to operate (Upstreams, Secrets, Kubernetes Namespaces)

0 commit comments

Comments
 (0)