Skip to content

Commit

Permalink
ISPN-16707 Sets EXPOSE_SERVICE_HOST env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
karesti committed Oct 2, 2024
1 parent 692368c commit f2007e4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ and install [cert-manager](https://cert-manager.io) on it:
make deploy-cert-manager
```

## Setup a Kubernetes Cluster using Podman Desktop
[Podman Desktop](https://podman-desktop.io/) a free and open-source tool that helps developers
work with Containers and Kubernetes. It makes it easy to connect local development to Kubernetes clusters
by using tools like Kind, Microshift, Openshift, and more.

## Development
Build the Operator image and deploy to a cluster:

Expand Down Expand Up @@ -131,12 +136,13 @@ The target cluster should be specified by exporting or explicitly providing `KUB
### Env Variables
The following variables can be exported or provided as part of the `make *test` call.

| Variable | Purpose |
|-----------------------|--------------------------------------------------------------------------------------|
| `TEST_NAME` | Specify a single test to run |
| `TESTING_NAMESPACE` | Specify the namespace/project for running test |
| `RUN_LOCAL_OPERATOR` | Specify whether run operator locally or use the predefined installation |
| `EXPOSE_SERVICE_TYPE` | Specify expose service type. `NodePort \| LoadBalancer \| Route`. |
| Variable | Purpose |
|-----------------------|-------------------------------------------------------------------------------------|
| `TEST_NAME` | Specify a single test to run |
| `TESTING_NAMESPACE` | Specify the namespace/project for running test |
| `RUN_LOCAL_OPERATOR` | Specify whether run operator locally or use the predefined installation |
| `EXPOSE_SERVICE_TYPE` | Specify expose service type. `NodePort \| LoadBalancer \| Route`. |
| `EXPOSE_SERVICE_HOST` | Specify the service host. Useful to pass pass `localhost`. |
| `PARALLEL_COUNT` | Specify parallel test running count. Default is one, i.e. no parallel tests enabled. |

### Xsite
Expand Down
4 changes: 4 additions & 0 deletions api/v1/types_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ func (ispn *Infinispan) IsExposed() bool {
return ispn.Spec.Expose != nil && ispn.Spec.Expose.Type != ""
}

func (ispn *Infinispan) GetExposeHost() string {
return ispn.Spec.Expose.Host
}

func (ispn *Infinispan) GetExposeType() ExposeType {
return ispn.Spec.Expose.Type
}
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,17 @@ func WebServerService(name, namespace string) *corev1.Service {
func ExposeServiceSpec(testKube *TestKubernetes) *ispnv1.ExposeSpec {
return &ispnv1.ExposeSpec{
Type: exposeServiceType(testKube),
Host: exposeServiceHost(),
}
}

func exposeServiceHost() string {
if ExposeServiceHost != "" {
return ExposeServiceHost
}
return ""
}

func exposeServiceType(testKube *TestKubernetes) ispnv1.ExposeType {
switch ispnv1.ExposeType(ExposeServiceType) {
case ispnv1.ExposeTypeNodePort, ispnv1.ExposeTypeLoadBalancer:
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ var (
CleanupInfinispan = strings.ToUpper(constants.GetEnvWithDefault("CLEANUP_INFINISPAN_ON_FINISH", "true"))
SuiteMode, _ = strconv.ParseBool(constants.GetEnvWithDefault("SUITE_MODE", "false"))
ExposeServiceType = constants.GetEnvWithDefault("EXPOSE_SERVICE_TYPE", string(ispnv1.ExposeTypeNodePort))

Infrastructure = os.Getenv("TESTING_INFRASTRUCTURE")
Platform = os.Getenv("TESTING_PLATFORM")
ExposeServiceHost = constants.GetEnvWithDefault("EXPOSE_SERVICE_HOST", "")
Infrastructure = os.Getenv("TESTING_INFRASTRUCTURE")
Platform = os.Getenv("TESTING_PLATFORM")

WebServerName = "external-libs-web-server"
WebServerImageName = constants.GetEnvWithDefault("TEST_NGINX_IMAGE", "quay.io/openshift-scale/nginx")
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/utils/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,14 @@ func (k TestKubernetes) WaitForExternalService(ispn *ispnv1.Infinispan, timeout
if len(routeList.Items) > 0 {
switch ispn.GetExposeType() {
case ispnv1.ExposeTypeNodePort:
host, err := k.Kubernetes.GetNodeHost(log, context.TODO())
ExpectNoError(err)
var host string
print(ispn.GetExposeHost())
if ispn.GetExposeHost() != "" {
host = ispn.GetExposeHost()
} else {
host, err = k.Kubernetes.GetNodeHost(log, context.TODO())
ExpectNoError(err)
}
hostAndPort = fmt.Sprintf("%s:%d", host, getNodePort(&routeList.Items[0]))
case ispnv1.ExposeTypeLoadBalancer:
hostAndPort = k.Kubernetes.GetExternalAddress(&routeList.Items[0])
Expand Down

0 comments on commit f2007e4

Please sign in to comment.