Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NET-11187] Nightly openshift basic test #4424

Merged
merged 24 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3d7288b
basic test cases
sarahalsmiller Nov 12, 2024
d354c99
test fixtures
sarahalsmiller Nov 12, 2024
fd6d08c
working openshift test
sarahalsmiller Nov 12, 2024
406c679
openshift test packages
sarahalsmiller Nov 12, 2024
fedcbde
update Makefile
sarahalsmiller Nov 12, 2024
b400a67
Correct name of added Make target
nathancoleman Nov 13, 2024
df79cf0
Correct import blocking
nathancoleman Nov 13, 2024
d0c0ba7
Make assertions more robust, clean up code/comments
nathancoleman Nov 13, 2024
7da5014
Add a PR trigger for acceptance tests
nathancoleman Nov 13, 2024
9366c64
Use different source for branch name provided to workflow
nathancoleman Nov 13, 2024
ba5c14e
Rename PR-triggered workflow
nathancoleman Nov 13, 2024
7840a05
Use local checkout of Helm chart for installation
nathancoleman Nov 13, 2024
b4fb68c
Use workspace from environment
nathancoleman Nov 13, 2024
f991992
Add the hashicorp helm repo as part of test setup
nathancoleman Nov 14, 2024
44d9361
new chart path
sarahalsmiller Nov 14, 2024
9daa878
Remove unused code, retry gateway connection, improve logging
nathancoleman Nov 14, 2024
7a0f066
Remove PR trigger for nightly acceptance tests
nathancoleman Nov 14, 2024
4c91a8f
move cleanup calls before the error so they'll clean up even if it er…
sarahalsmiller Nov 14, 2024
4ff0d07
Update acceptance/tests/openshift/main_test.go
sarahalsmiller Nov 14, 2024
44096fd
update flags to use config
sarahalsmiller Nov 14, 2024
2963997
readd pr trigger test to validate change
sarahalsmiller Nov 14, 2024
bac0643
add license mounting config
sarahalsmiller Nov 14, 2024
a37774c
fix cert reference
sarahalsmiller Nov 14, 2024
fb8a09c
Merge branch 'main' into nightly-openshift-run
sarahalsmiller Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ eks-test-packages: ## eks test packages
aks-test-packages: ## aks test packages
@./control-plane/build-support/scripts/set_test_package_matrix.sh "acceptance/ci-inputs/aks_acceptance_test_packages.yaml"


.PHONY: openshift-test-packages
openshift-test-packages: ## openshift test packages
@./control-plane/build-support/scripts/set_test_package_matrix.sh "acceptance/ci-inputs/openshift_acceptance_test_packages.yaml"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only for CI or could I run make openshift-test-packages locally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could run this locally if you were connected to an openshift cluster and passed in the --use-openshift flag

.PHONY: go-mod-tidy
go-mod-tidy: ## Recursively run go mod tidy on all subdirectories
@./control-plane/build-support/scripts/mod_tidy.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

# Cloud package is not included in test suite as it is triggered from a non consul-k8s repo and requires HCP credentials
- {runner: 0, test-packages: "openshift"}
1 change: 1 addition & 0 deletions acceptance/framework/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type TestConfig struct {
UseGKE bool
UseGKEAutopilot bool
UseKind bool
UseOpenshift bool

helmChartPath string
}
Expand Down
8 changes: 7 additions & 1 deletion acceptance/framework/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
"strings"
"sync"

"github.com/hashicorp/consul-k8s/acceptance/framework/config"
"github.com/hashicorp/go-version"

"github.com/hashicorp/consul-k8s/acceptance/framework/config"
)

type TestFlags struct {
Expand Down Expand Up @@ -57,6 +58,7 @@ type TestFlags struct {
flagUseGKE bool
flagUseGKEAutopilot bool
flagUseKind bool
flagUseOpenshift bool

flagDisablePeering bool

Expand Down Expand Up @@ -154,6 +156,9 @@ func (t *TestFlags) init() {
flag.BoolVar(&t.flagUseKind, "use-kind", false,
"If true, the tests will assume they are running against a local kind cluster(s).")

flag.BoolVar(&t.flagUseOpenshift, "use-openshift", false,
"If true, the tests will assume they are running against an openshift cluster(s).")

flag.BoolVar(&t.flagDisablePeering, "disable-peering", false,
"If true, the peering tests will not run.")

Expand Down Expand Up @@ -246,6 +251,7 @@ func (t *TestFlags) TestConfigFromFlags() *config.TestConfig {
UseGKE: t.flagUseGKE,
UseGKEAutopilot: t.flagUseGKEAutopilot,
UseKind: t.flagUseKind,
UseOpenshift: t.flagUseOpenshift,
}

return c
Expand Down
59 changes: 59 additions & 0 deletions acceptance/tests/fixtures/cases/openshift/basic/backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: v1
kind: Namespace
metadata:
name: backend
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: backend
namespace: backend
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
namespace: backend
spec:
selector:
matchLabels:
app: backend
replicas: 1
template:
metadata:
labels:
app: backend
annotations:
consul.hashicorp.com/connect-inject: "true"
spec:
serviceAccountName: backend
containers:
- name: backend
image: nicholasjackson/fake-service:v0.26.0
ports:
- containerPort: 8080
env:
- name: LISTEN_ADDR
value: "0.0.0.0:8080"
- name: NAME
value: backend
---
apiVersion: v1
kind: Service
metadata:
name: backend
namespace: backend
spec:
type: ClusterIP
selector:
app: backend
ports:
- port: 8080
---
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceDefaults
metadata:
name: backend
namespace: backend
spec:
protocol: http
62 changes: 62 additions & 0 deletions acceptance/tests/fixtures/cases/openshift/basic/frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: v1
kind: Namespace
metadata:
name: frontend
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: frontend
namespace: frontend
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
namespace: frontend
spec:
selector:
matchLabels:
app: frontend
replicas: 1
template:
metadata:
labels:
app: frontend
annotations:
consul.hashicorp.com/connect-inject: "true"
spec:
serviceAccountName: frontend
containers:
- name: frontend
image: nicholasjackson/fake-service:v0.26.0
ports:
- containerPort: 8080
env:
- name: LISTEN_ADDR
value: "0.0.0.0:8080"
- name: NAME
value: frontend
- name: UPSTREAM_URIS
value: 'http://backend.backend:8080'

---
apiVersion: v1
kind: Service
metadata:
name: frontend
namespace: frontend
spec:
type: ClusterIP
selector:
app: frontend
ports:
- port: 8080
---
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceDefaults
metadata:
name: frontend
namespace: frontend
spec:
protocol: http
15 changes: 15 additions & 0 deletions acceptance/tests/fixtures/cases/openshift/basic/gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: api-gateway
namespace: consul
spec:
gatewayClassName: consul
listeners:
- name: https
protocol: HTTPS
port: 443
tls:
certificateRefs:
- name: consul-server-cert
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this refer to a secret that gets created by our helm templates?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

namespace: consul
23 changes: 23 additions & 0 deletions acceptance/tests/fixtures/cases/openshift/basic/intentions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceIntentions
metadata:
name: to-backend-default
namespace: default
spec:
destination:
name: backend
sources:
- name: frontend
action: allow
---
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceIntentions
metadata:
name: to-frontend-default
namespace: default
spec:
destination:
name: frontend
sources:
- name: api-gateway
action: allow
30 changes: 30 additions & 0 deletions acceptance/tests/fixtures/cases/openshift/basic/route.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
name: frontend-route-default
namespace: consul
spec:
parentRefs:
- name: api-gateway
rules:
- backendRefs:
- kind: Service
name: frontend
namespace: frontend
port: 8080

---
apiVersion: gateway.networking.k8s.io/v1beta1
kind: ReferenceGrant
metadata:
name: service-grant
namespace: frontend
spec:
from:
- group: gateway.networking.k8s.io
kind: HTTPRoute
namespace: consul
to:
- group: ""
kind: Service
name: frontend
Loading
Loading