Skip to content

Commit

Permalink
test(controller-enricher): Add Maven integration test for nodeSelecto…
Browse files Browse the repository at this point in the history
…r via Maven XML and Groovy DSL

Signed-off-by: Sun Seng David TAN <[email protected]>
  • Loading branch information
sunix authored and manusa committed Mar 28, 2024
1 parent ef857f8 commit 37498f7
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#
# Copyright (c) 2019 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at:
#
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
prometheus.io/scrape: "true"
jkube.eclipse.org/git-branch: "@ignore@"
prometheus.io/port: "9779"
labels:
provider: jkube
app: jkube-maven-sample-node-selector
version: "@ignore@"
group: org.eclipse.jkube
name: jkube-maven-sample-node-selector
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: jkube-maven-sample-node-selector
provider: jkube
group: org.eclipse.jkube
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
provider: jkube
app: jkube-maven-sample-node-selector
version: "@ignore@"
group: org.eclipse.jkube
name: jkube-maven-sample-node-selector
spec:
replicas: 1
selector:
matchLabels:
app: jkube-maven-sample-node-selector
provider: jkube
group: org.eclipse.jkube
template:
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
provider: jkube
app: jkube-maven-sample-node-selector
version: "@ignore@"
group: org.eclipse.jkube
spec:
nodeSelector:
region: east
type: user-node
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: "@matches('jkube/jkube-maven-sample-node-selector:.*$')@"
imagePullPolicy: IfNotPresent
name: quarkus
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9779
name: prometheus
protocol: TCP
- containerPort: 8778
name: jolokia
protocol: TCP
securityContext:
privileged: false
17 changes: 17 additions & 0 deletions kubernetes-maven-plugin/it/src/it/nodeSelector/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2019 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at:
#
# https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

invoker.goals.1=clean k8s:resource
invoker.mavenOpts=-Djkube.verbose -Djkube.offline=true
invoker.debug=false
83 changes: 83 additions & 0 deletions kubernetes-maven-plugin/it/src/it/nodeSelector/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2019 Red Hat, Inc.
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at:
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Red Hat, Inc. - initial API and implementation
-->
<project>

<modelVersion>4.0.0</modelVersion>

<artifactId>jkube-maven-sample-node-selector</artifactId>
<groupId>org.eclipse.jkube</groupId>
<version>0.1-SNAPSHOT</version>

<properties>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.8.3</quarkus.platform.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive</artifactId>
</dependency>
</dependencies>

<build>

<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
</plugin>

<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>@jkube.version@</version>
<configuration>
<resources>
<controller>
<nodeSelector>
<region>east</region>
<type>user-node</type>
</nodeSelector>
</controller>
</resources>
</configuration>
</plugin>

</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello")
public class GreetingResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello JKube";
}
}
22 changes: 22 additions & 0 deletions kubernetes-maven-plugin/it/src/it/nodeSelector/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
import org.eclipse.jkube.maven.it.Verify

[ "kubernetes" ].each {
Verify.verifyResourceDescriptors(
new File(basedir, sprintf("/target/classes/META-INF/jkube/%s.yml",it)),
new File(basedir, sprintf("/expected/%s.yml",it)))
}

true

0 comments on commit 37498f7

Please sign in to comment.