Skip to content
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
71fdbd8
experiment
n0tl3ss Feb 9, 2023
8f12e76
Merge branch 'master' into feature/workflow1
n0tl3ss Mar 8, 2023
1003b2c
experiment
n0tl3ss Mar 8, 2023
e92dd4f
experiment
n0tl3ss Mar 8, 2023
a60ede8
experiment
n0tl3ss Mar 8, 2023
81a34a0
experiment
n0tl3ss Mar 9, 2023
1c06da7
experiment
n0tl3ss Mar 9, 2023
0df5612
experiment
n0tl3ss Mar 9, 2023
4498df8
experiment
n0tl3ss Mar 10, 2023
097308c
experiment
n0tl3ss Mar 10, 2023
2a3320a
experiment
n0tl3ss Mar 10, 2023
7a5f32a
experiment
n0tl3ss Mar 10, 2023
0eb7769
experiment
n0tl3ss Mar 10, 2023
0f359c8
experiment
n0tl3ss Mar 10, 2023
3fdf25b
small fixes
n0tl3ss Mar 13, 2023
c35909e
small fixes
n0tl3ss Mar 13, 2023
66663c3
empty to trigger build
n0tl3ss Mar 15, 2023
c311960
empty to trigger build
n0tl3ss Mar 15, 2023
1faa493
empty to trigger build
n0tl3ss Mar 15, 2023
3eea457
empty to trigger build
n0tl3ss Mar 15, 2023
167de58
empty to trigger build
n0tl3ss Mar 15, 2023
54b1229
empty to trigger build
n0tl3ss Mar 20, 2023
d77e9cc
add text to CONTRIBUTING.md
n0tl3ss Mar 20, 2023
09529db
empty to trigger build
n0tl3ss Mar 20, 2023
4f89e74
switch discovery-client test to debug level from info
n0tl3ss Mar 20, 2023
bee3fd9
empty to trigger build
n0tl3ss Mar 20, 2023
b788688
experiment
n0tl3ss Mar 20, 2023
6c47904
experiment
n0tl3ss Mar 21, 2023
47f3d04
empty to trigger build
n0tl3ss Mar 21, 2023
2b28d63
empty to trigger build
n0tl3ss Mar 21, 2023
2d143c1
experiment
n0tl3ss Mar 21, 2023
7fd7abd
experiment
n0tl3ss Mar 21, 2023
6285eb4
empty to trigger build
n0tl3ss Mar 21, 2023
f13f4c0
experiment
n0tl3ss Mar 21, 2023
41386ea
experiment
n0tl3ss Mar 21, 2023
70ddf1f
experiment
n0tl3ss Mar 21, 2023
a3ebb82
experiment
n0tl3ss Mar 21, 2023
f7e6488
experiment
n0tl3ss Mar 21, 2023
50dadec
experiment
n0tl3ss Mar 21, 2023
ee41220
experiment
n0tl3ss Mar 21, 2023
a58b67f
experiment
n0tl3ss Mar 21, 2023
6776236
empty to trigger build
n0tl3ss Mar 21, 2023
30ea16c
empty to trigger build
n0tl3ss Mar 21, 2023
937e45e
empty to trigger build
n0tl3ss Mar 21, 2023
132be39
experiment
n0tl3ss Mar 21, 2023
7a1f1ce
experiment
n0tl3ss Mar 22, 2023
1c72c6d
experiment
n0tl3ss Mar 22, 2023
a4c4b4c
experiment
n0tl3ss Mar 22, 2023
14cea8b
experiment
n0tl3ss Mar 22, 2023
9fa04be
empty to trigger build
n0tl3ss Mar 22, 2023
d1a8525
empty to trigger build
n0tl3ss Mar 22, 2023
f2d75f2
empty to trigger build
n0tl3ss Mar 22, 2023
2af1d1f
empty to trigger build
n0tl3ss Mar 22, 2023
2b85279
experiment
n0tl3ss Mar 22, 2023
7e75a83
experiment
n0tl3ss Mar 22, 2023
6a17b44
experiment
n0tl3ss Mar 22, 2023
012ea24
empty to trigger build
n0tl3ss Mar 22, 2023
7b824f2
empty to trigger build
n0tl3ss Mar 23, 2023
b37d6ce
empty to trigger build
n0tl3ss Mar 23, 2023
fead6f1
experiment
n0tl3ss Mar 23, 2023
935d320
experiment
n0tl3ss Mar 23, 2023
d1a570d
experiment
n0tl3ss Mar 23, 2023
d6ed7f9
experiment
n0tl3ss Mar 23, 2023
993aa7e
experiment
n0tl3ss Mar 23, 2023
1ad1521
experiment
n0tl3ss Mar 23, 2023
5b79bbb
empty to trigger build
n0tl3ss Mar 23, 2023
076e720
experiment
n0tl3ss Mar 23, 2023
d22a149
empty to trigger build
n0tl3ss Mar 23, 2023
dc9086b
empty to trigger build
n0tl3ss Mar 23, 2023
3ae5682
empty to trigger build
n0tl3ss Mar 24, 2023
d007bc0
empty to trigger build
n0tl3ss Mar 24, 2023
26bd73d
empty to trigger build
n0tl3ss Mar 24, 2023
e4db018
experiment
n0tl3ss Mar 24, 2023
1ce9dde
empty to trigger build
n0tl3ss Mar 24, 2023
0898712
empty to trigger build
n0tl3ss Mar 24, 2023
c6ba6a1
experiment
n0tl3ss Mar 24, 2023
e597432
experiment
n0tl3ss Mar 24, 2023
66b8c70
experiment
n0tl3ss Mar 24, 2023
0527124
experiment
n0tl3ss Mar 24, 2023
ba6355b
experiment
n0tl3ss Mar 24, 2023
a9ac47f
empty to trigger build
n0tl3ss Mar 27, 2023
0664874
empty to trigger build
n0tl3ss Mar 27, 2023
5ad1cb3
experiment
n0tl3ss Mar 27, 2023
5475d0b
experiment
n0tl3ss Mar 27, 2023
92a7d36
experiment
n0tl3ss Mar 27, 2023
c93a538
empty to trigger build
n0tl3ss Mar 27, 2023
8911f84
empty to trigger build
n0tl3ss Mar 27, 2023
a4d5040
empty to trigger build
n0tl3ss Mar 27, 2023
11c1938
empty to trigger build
n0tl3ss Mar 27, 2023
0f6381a
empty to trigger build
n0tl3ss Mar 27, 2023
18262ad
empty to trigger build
n0tl3ss Mar 27, 2023
db6a9ef
empty to trigger build
n0tl3ss Mar 27, 2023
455e4ad
empty to trigger build
n0tl3ss Mar 27, 2023
b3106bc
experiment
n0tl3ss Mar 28, 2023
e0cfdd6
experiment
n0tl3ss Mar 28, 2023
85a2935
experiment
n0tl3ss Mar 28, 2023
497c05a
empty to trigger build
n0tl3ss Mar 28, 2023
a34182b
experiment
n0tl3ss Mar 28, 2023
ed437b2
experiment
n0tl3ss Mar 28, 2023
b49976e
experiment
n0tl3ss Mar 28, 2023
bdcecba
experiment
n0tl3ss Mar 28, 2023
4429ca5
experiment
n0tl3ss Mar 28, 2023
60e062d
empty to trigger build
n0tl3ss Mar 29, 2023
90a04f8
empty to trigger build
n0tl3ss Mar 29, 2023
a665496
empty to trigger build
n0tl3ss Mar 29, 2023
3ef1e95
empty to trigger build
n0tl3ss Mar 29, 2023
8570bc9
Merge branch 'master' into feature/workflow1
n0tl3ss Mar 31, 2023
ef7bf77
fix SecretInformerControllerSpec test
n0tl3ss Mar 31, 2023
97e8605
empty to trigger build
n0tl3ss Apr 1, 2023
e464019
empty to trigger build
n0tl3ss Apr 3, 2023
bb47f68
empty to trigger build
n0tl3ss Apr 3, 2023
25a7f3c
Merge branch 'master' into feature/workflow1
n0tl3ss Apr 3, 2023
052c3cf
empty to trigger build
n0tl3ss Apr 3, 2023
3259495
empty to trigger build
n0tl3ss Apr 3, 2023
a67bc50
empty to trigger build
n0tl3ss Apr 3, 2023
fa33222
remove shared
n0tl3ss Apr 3, 2023
d2844be
remove shared
n0tl3ss Apr 3, 2023
d9dd6c0
empty to trigger build
n0tl3ss Apr 4, 2023
d8eee57
empty to trigger build
n0tl3ss Apr 4, 2023
0b35ef6
empty to trigger build
n0tl3ss Apr 4, 2023
e0a78ff
empty to trigger build
n0tl3ss Apr 4, 2023
81c8ef4
empty to trigger build
n0tl3ss Apr 4, 2023
8a2ec95
empty to trigger build
n0tl3ss Apr 4, 2023
e78e2b0
empty to trigger build
n0tl3ss Apr 4, 2023
17d661e
empty to trigger build
n0tl3ss Apr 4, 2023
6cfa8e7
Merge branch 'master' into feature/workflow1
n0tl3ss Apr 11, 2023
fecfc62
update KubernetesSpecification
n0tl3ss Apr 11, 2023
059e8c1
empty to trigger build
n0tl3ss Apr 11, 2023
06326e6
empty to trigger build
n0tl3ss Apr 12, 2023
67e24a5
empty to trigger build
n0tl3ss Apr 12, 2023
75d2240
empty to trigger build
n0tl3ss Apr 12, 2023
ade3eb1
empty to trigger build
n0tl3ss Apr 12, 2023
04bc347
empty to trigger build
n0tl3ss Apr 12, 2023
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
4 changes: 0 additions & 4 deletions .github/actions/graalvm-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#TODO move this action to https://github.com/micronaut-projects/github-actions
name: Build steps for GitHub gradle workflow
description: Perform build steps for gradle workflow
inputs:
java:
description: java version
required: true
runs:
using: "composite"
steps:
Expand Down
32 changes: 26 additions & 6 deletions .github/workflows/graalvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,59 @@ jobs:
build:
if: github.repository != 'micronaut-projects/micronaut-project-template'
runs-on: ubuntu-latest
env:
OCI_CLI_USER: ${{ secrets.OCI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_KEY_FILE }}
OCI_CLI_REGION: ${{ secrets.OCI_REGION }}
strategy:
matrix:
java: [ '17' ]
graalvm: ['latest']
k8s: [ '1.21' ]
steps:
- uses: actions/checkout@v3
- name: Configure Kubectl
uses: oracle-actions/[email protected]
id: test-configure-kubectl-oke-action
with:
cluster: ${{ secrets.OKE_CLUSTER_OCID }}
- name: Run Kubectl
run: kubectl get nodes -A
- name: Pre-build
uses: ./.github/actions/gradle-pre-build
uses: ./.github/actions/graalvm-pre-build
id: pre-build
env:
K8S_VERSION: ${{ matrix.k8s }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
GIT_COMMIT_HASH: ${{ github.sha }}
OCI_REGION: ${{ secrets.OCI_REGION }}
Copy link
Member

Choose a reason for hiding this comment

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

Can we change the action to use OCI_CLI_REGION instead?

JOB_ID: ${{ format('{0}-graalvm-java-{1}', github.run_id, matrix.java) }}
OCI_TENANCY_NAME: ${{ secrets.OCI_TENANCY_NAME }}
JAVA_VERSION: ${{ matrix.java }}
AUTH_TOKEN: ${{ secrets.OCI_AUTH_TOKEN }}
OCIR_USERNAME: ${{ secrets.OCIR_USERNAME }}
with:
java: ${{ matrix.java }}
graalvm: ${{ matrix.graalvm }}
- name: Build
uses: ./.github/actions/graalvm-build
id: build
with:
java: ${{ matrix.java }}
env:
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
IMAGE_TAG: 'java-${{ matrix.java }}-${{ github.sha }}'
IMAGE_PREFIX: '${{ secrets.OCI_REGION }}.ocir.io/${{ secrets.OCI_TENANCY_NAME }}/'
KUBERNETES_TRUST_CERTIFICATES: 'true'
- name: Post-build
uses: ./.github/actions/graalvm-post-build
if: always()
id: post-build
env:
K8S_VERSION: ${{ matrix.k8s }}
JOB_ID: ${{ format('{0}-graalvm-java-{1}', github.run_id, matrix.java) }}
with:
java: ${{ matrix.java }}
31 changes: 25 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,55 @@ jobs:
build:
if: github.repository != 'micronaut-projects/micronaut-project-template'
runs-on: ubuntu-latest
env:
OCI_CLI_USER: ${{ secrets.OCI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_KEY_FILE }}
OCI_CLI_REGION: ${{ secrets.OCI_REGION }}
strategy:
matrix:
java: ['8', '11', '17']
k8s: ['1.21']
steps:
- uses: actions/checkout@v3
- name: Configure Kubectl
uses: oracle-actions/[email protected]
id: test-configure-kubectl-oke-action
with:
cluster: ${{ secrets.OKE_CLUSTER_OCID }}
- name: Run Kubectl
run: kubectl get nodes -A
- name: Pre-build
uses: ./.github/actions/gradle-pre-build
id: pre-build
env:
K8S_VERSION: ${{ matrix.k8s }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
OCI_REGION: ${{ secrets.OCI_REGION }}
OCI_TENANCY_NAME: ${{ secrets.OCI_TENANCY_NAME }}
AUTH_TOKEN: ${{ secrets.OCI_AUTH_TOKEN }}
OCIR_USERNAME: ${{ secrets.OCIR_USERNAME }}
GIT_COMMIT_HASH: ${{ github.sha }}
JOB_ID: ${{ format('{0}-java-{1}', github.run_id, matrix.java) }}
JAVA_VERSION: ${{ matrix.java }}
with:
java: ${{ matrix.java }}
- name: Build
uses: ./.github/actions/gradle-build
id: build
with:
java: ${{ matrix.java }}
env:
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
IMAGE_TAG: 'java-${{ matrix.java }}-${{ github.sha }}'
IMAGE_PREFIX: '${{ secrets.OCI_REGION }}.ocir.io/${{ secrets.OCI_TENANCY_NAME }}/'
KUBERNETES_TRUST_CERTIFICATES: 'true'
- name: Post-build
uses: ./.github/actions/gradle-post-build
id: post-build
if: always()
env:
GH_TOKEN_PUBLIC_REPOS_READONLY: ${{ secrets.GH_TOKEN_PUBLIC_REPOS_READONLY }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
Expand All @@ -56,7 +75,7 @@ jobs:
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
K8S_VERSION: ${{ matrix.k8s }}
JOB_ID: ${{ format('{0}-java-{1}', github.run_id, matrix.java) }}
with:
java: ${{ matrix.java }}
- name: Publish-Github-Pages
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ on:
jobs:
build:
if: github.repository != 'micronaut-projects/micronaut-project-template'
env:
Copy link
Member

Choose a reason for hiding this comment

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

FYI this workflow is being removed since we are running coverage in the main Gradle workflow. See micronaut-projects/micronaut-project-template#342

OCI_CLI_USER: ${{ secrets.OCI_USER }}
OCI_CLI_TENANCY: ${{ secrets.OCI_TENANCY }}
OCI_CLI_FINGERPRINT: ${{ secrets.OCI_FINGERPRINT }}
OCI_CLI_KEY_CONTENT: ${{ secrets.OCI_KEY_FILE }}
OCI_CLI_REGION: ${{ secrets.OCI_REGION }}
runs-on: ubuntu-latest
steps:
# https://github.com/actions/virtual-environments/issues/709
Expand All @@ -39,11 +45,25 @@ jobs:
with:
distribution: 'adopt'
java-version: 11
- name: Configure Kubectl
uses: oracle-actions/[email protected]
id: test-configure-kubectl-oke-action
with:
cluster: ${{ secrets.OKE_CLUSTER_OCID }}
- name: Run Kubectl
run: kubectl get nodes -A
- name: Optional setup step
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
GIT_COMMIT_HASH: ${{ github.sha }}
JOB_ID: ${{ format('{0}-sonar', github.run_id) }}
OCI_REGION: ${{ secrets.OCI_REGION }}
OCI_TENANCY_NAME: ${{ secrets.OCI_TENANCY_NAME }}
JAVA_VERSION: '11'
AUTH_TOKEN: ${{ secrets.OCI_AUTH_TOKEN }}
OCIR_USERNAME: ${{ secrets.OCIR_USERNAME }}
run: |
[ -f ./setup.sh ] && ./setup.sh || true
- name: Analyse with Gradle
Expand All @@ -54,5 +74,17 @@ jobs:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
IMAGE_TAG: 'java-11-${{ github.sha }}'
IMAGE_PREFIX: '${{ secrets.OCI_REGION }}.ocir.io/${{ secrets.OCI_TENANCY_NAME }}/'
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KUBERNETES_TRUST_CERTIFICATES: 'true'
- name: Optional teardown step
if: always()
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
JOB_ID: ${{ format('{0}-sonar', github.run_id) }}
run: |
[ -f ./teardown.sh ] && ./teardown.sh || true
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package micronaut.client

import groovy.util.logging.Slf4j
import io.micronaut.context.annotation.Property
import io.micronaut.context.env.Environment
import io.micronaut.core.util.StringUtils
import io.micronaut.http.annotation.Get
import io.micronaut.http.client.annotation.Client
import io.micronaut.kubernetes.test.KubernetesSpecification
Expand All @@ -17,13 +19,18 @@ import io.micronaut.context.annotation.Requires as MicronautRequires
@MicronautTest(environments = Environment.KUBERNETES)
@Property(name = "spec.name", value = "KubernetesHealthIndicatorSpec")
@Property(name = "spec.reuseNamespace", value = "false")
@Property(name = "kubernetes.client.namespace", value = "kubernetes-health-indicator")
@Requires({ TestUtils.kubernetesApiAvailable() })
@Slf4j
class KubernetesHealthIndicatorSpec extends KubernetesSpecification {

@Inject
@Shared
ServiceClient client

@Property(name = "image.tag")
String imageTag

def setupSpec() {
operations.portForwardService("example-service", namespace, 8081, 9999)
}
Expand All @@ -32,6 +39,11 @@ class KubernetesHealthIndicatorSpec extends KubernetesSpecification {
when:
Map details = client.health().details

String tagName = "latest"
if (StringUtils.isNotEmpty(imageTag)) {
tagName = imageTag
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
String tagName = "latest"
if (StringUtils.isNotEmpty(imageTag)) {
tagName = imageTag
}
String tagName = imageTag ?: "latest"


then:
details.kubernetes.name == "micronaut-service"
details.kubernetes.status == "UP"
Expand All @@ -41,7 +53,7 @@ class KubernetesHealthIndicatorSpec extends KubernetesSpecification {
details.kubernetes.details.podIP
details.kubernetes.details.hostIP
details.kubernetes.details.containerStatuses.first().name == "example-service"
details.kubernetes.details.containerStatuses.first().image.endsWith "example-service:latest"
details.kubernetes.details.containerStatuses.first().image.endsWith "example-service:" + tagName
details.kubernetes.details.containerStatuses.first().ready == true
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package micronaut.informer

import groovy.util.logging.Slf4j
import io.fabric8.kubernetes.api.model.ContainerBuilder
import io.fabric8.kubernetes.api.model.ContainerPortBuilder
import io.fabric8.kubernetes.api.model.HTTPGetActionBuilder
Expand All @@ -17,12 +18,15 @@ import io.kubernetes.client.openapi.models.V1Secret
import io.micronaut.context.annotation.Property
import io.micronaut.context.annotation.Requires as MicronautRequires
import io.micronaut.context.env.Environment
import io.micronaut.core.util.StringUtils
import io.micronaut.http.MediaType
import io.micronaut.http.annotation.Get
import io.micronaut.http.client.annotation.Client
import io.micronaut.http.client.exceptions.HttpClientException
import io.micronaut.kubernetes.test.KubernetesSpecification
import io.micronaut.kubernetes.test.TestUtils
import io.micronaut.test.extensions.spock.annotation.MicronautTest
import jakarta.annotation.Nullable
import jakarta.inject.Inject
import spock.lang.Requires
import spock.lang.Shared
Expand All @@ -35,16 +39,40 @@ import java.util.concurrent.TimeUnit
@Property(name = "spec.reuseNamespace", value = "false")
@Property(name = "kubernetes.client.namespace", value = "micronaut-example-informer")
@Requires({ TestUtils.kubernetesApiAvailable() })
@Slf4j
class SecretInformerControllerSpec extends KubernetesSpecification {

@Inject
@Shared
TestClient testClient

@Nullable
@Property(name = "image.tag")
Optional<String> imageTag

@Nullable
@Property(name = "image.prefix")
Optional<String> imagePrefix

@Override
def setupFixture(String namespace) {
createNamespaceSafe(namespace)
createBaseResources(namespace)
def imageName = "micronaut-kubernetes-informer-example"
def tagName = "latest"

if (StringUtils.isNotEmpty(imagePrefix.orElse(null))) {
imageName = imagePrefix.get() + imageName
}

if (StringUtils.isNotEmpty(imageTag.orElse(null))) {
tagName = imageTag.get()
}

imageName = imageName + ":" + tagName

log.info("Image name: ${imageName}")

def client = operations.getClient(namespace)
def informerDeployment = client.apps().deployments().createOrReplace(
new DeploymentBuilder()
Expand All @@ -63,8 +91,8 @@ class SecretInformerControllerSpec extends KubernetesSpecification {
.withSpec(new PodSpecBuilder()
.withContainers(new ContainerBuilder()
.withName("informer")
.withImage("micronaut-kubernetes-informer-example")
.withImagePullPolicy("Never")
.withImage(imageName)
.withImagePullPolicy("IfNotPresent")
.withPorts(new ContainerPortBuilder()
.withName("http")
.withContainerPort(8080)
Expand Down Expand Up @@ -113,7 +141,10 @@ class SecretInformerControllerSpec extends KubernetesSpecification {

void "test all"() {
expect:
testClient.all().size() == 4
// kind adds "default-token" secret to every namespace. That's why we check with >= to make sure it works both with OKE and kind
testClient.all().size() >= 3
testClient.secret("mounted-secret")
testClient.secret("another-secret")
testClient.secret("test-secret")
testClient.secret("test-secret").data.containsKey("username")
}
Expand All @@ -134,7 +165,10 @@ class SecretInformerControllerSpec extends KubernetesSpecification {

then:
conditions.eventually {
testClient.all().size() == 5
testClient.all().size() >= 4
testClient.secret("mounted-secret")
testClient.secret("another-secret")
testClient.secret("test-secret")
testClient.secret(secretName)
}

Expand All @@ -143,7 +177,11 @@ class SecretInformerControllerSpec extends KubernetesSpecification {

then:
conditions.eventually {
testClient.all().size() == 4
testClient.all().size() >= 3
testClient.secret("mounted-secret")
testClient.secret("another-secret")
testClient.secret("test-secret")
!testClient.secret(secretName)
}
}

Expand Down
Loading