-
Notifications
You must be signed in to change notification settings - Fork 539
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: prior tests to ensure name fixes
Signed-off-by: Marc Nuri <[email protected]>
- Loading branch information
Showing
17 changed files
with
412 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 | ||
*/ | ||
plugins { | ||
id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" | ||
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" | ||
id 'java' | ||
} | ||
|
||
group = 'org.eclipse.jkube.integration.tests.gradle' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '11' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
def extensionConfig = { | ||
offline = true | ||
images { | ||
image { | ||
name = 'repository/service-name:latest' | ||
build { | ||
from = 'quay.io/jkube/jkube-java' | ||
ports = ['8080'] | ||
} | ||
} | ||
} | ||
enricher { | ||
config { | ||
'jkube-service' { | ||
name = 'customized-name' | ||
} | ||
} | ||
} | ||
} | ||
|
||
kubernetes(extensionConfig) | ||
openshift(extensionConfig) |
76 changes: 76 additions & 0 deletions
76
gradle-plugin/it/src/it/service-name/expected/kubernetes.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
jkube.eclipse.org/git-commit: "@ignore@" | ||
jkube.eclipse.org/git-url: "@ignore@" | ||
jkube.eclipse.org/git-branch: "@ignore@" | ||
labels: | ||
app: service-name | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: customized-name | ||
spec: | ||
ports: | ||
- name: http | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 8080 | ||
selector: | ||
app: service-name | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
- apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
annotations: | ||
jkube.eclipse.org/git-commit: "@ignore@" | ||
jkube.eclipse.org/git-url: "@ignore@" | ||
jkube.eclipse.org/git-branch: "@ignore@" | ||
labels: | ||
app: service-name | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: service-name | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 2 | ||
selector: | ||
matchLabels: | ||
app: service-name | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
template: | ||
metadata: | ||
annotations: | ||
jkube.eclipse.org/git-commit: "@ignore@" | ||
jkube.eclipse.org/git-url: "@ignore@" | ||
jkube.eclipse.org/git-branch: "@ignore@" | ||
labels: | ||
app: service-name | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: service-name | ||
spec: | ||
containers: | ||
- env: | ||
- name: KUBERNETES_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: HOSTNAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
image: repository/service-name:latest | ||
imagePullPolicy: IfNotPresent | ||
name: repository-service-name | ||
securityContext: | ||
privileged: false |
112 changes: 112 additions & 0 deletions
112
gradle-plugin/it/src/it/service-name/expected/openshift.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
jkube.eclipse.org/git-commit: "@ignore@" | ||
app.openshift.io/vcs-ref: "@ignore@" | ||
jkube.eclipse.org/git-url: "@ignore@" | ||
app.openshift.io/vcs-uri: "@ignore@" | ||
jkube.eclipse.org/git-branch: "@ignore@" | ||
labels: | ||
app: service-name | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: customized-name | ||
spec: | ||
ports: | ||
- name: http | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 8080 | ||
selector: | ||
app: service-name | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
- apiVersion: apps.openshift.io/v1 | ||
kind: DeploymentConfig | ||
metadata: | ||
annotations: | ||
jkube.eclipse.org/git-commit: "@ignore@" | ||
jkube.eclipse.org/git-url: "@ignore@" | ||
app.openshift.io/vcs-ref: "@ignore@" | ||
app.openshift.io/vcs-uri: "@ignore@" | ||
jkube.eclipse.org/git-branch: "@ignore@" | ||
labels: | ||
app: service-name | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: service-name | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 2 | ||
selector: | ||
app: service-name | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
strategy: | ||
rollingParams: | ||
timeoutSeconds: 3600 | ||
type: Rolling | ||
template: | ||
metadata: | ||
annotations: | ||
jkube.eclipse.org/git-commit: "@ignore@" | ||
jkube.eclipse.org/git-url: "@ignore@" | ||
app.openshift.io/vcs-ref: "@ignore@" | ||
app.openshift.io/vcs-uri: "@ignore@" | ||
jkube.eclipse.org/git-branch: "@ignore@" | ||
labels: | ||
app: service-name | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: service-name | ||
spec: | ||
containers: | ||
- env: | ||
- name: KUBERNETES_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
image: repository/service-name:latest | ||
imagePullPolicy: IfNotPresent | ||
name: repository-service-name | ||
securityContext: | ||
privileged: false | ||
triggers: | ||
- type: ConfigChange | ||
- imageChangeParams: | ||
automatic: true | ||
containerNames: | ||
- repository-service-name | ||
from: | ||
kind: ImageStreamTag | ||
name: service-name:latest | ||
type: ImageChange | ||
- apiVersion: route.openshift.io/v1 | ||
kind: Route | ||
metadata: | ||
annotations: | ||
jkube.eclipse.org/git-commit: "@ignore@" | ||
jkube.eclipse.org/git-url: "@ignore@" | ||
app.openshift.io/vcs-ref: "@ignore@" | ||
app.openshift.io/vcs-uri: "@ignore@" | ||
jkube.eclipse.org/git-branch: "@ignore@" | ||
labels: | ||
app: service-name | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: customized-name | ||
spec: | ||
port: | ||
targetPort: 8080 | ||
to: | ||
kind: Service | ||
name: customized-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/ServiceNameIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* 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.gradle.plugin.tests; | ||
|
||
import net.minidev.json.parser.ParseException; | ||
import org.eclipse.jkube.kit.common.ResourceVerify; | ||
import org.gradle.testkit.runner.BuildResult; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
@DisplayName("Service can have name overridden by configuration") | ||
class ServiceNameIT { | ||
|
||
private static final String TEST_PROJECT = "service-name"; | ||
|
||
@RegisterExtension | ||
protected final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); | ||
|
||
@Test | ||
void k8sResourceTask() throws IOException, ParseException { | ||
// When | ||
final BuildResult result = gradleRunner.withITProject(TEST_PROJECT) | ||
.withArguments("k8sResource", "--stacktrace") | ||
.build(); | ||
// Then | ||
ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultKubernetesResourceFile(), | ||
gradleRunner.resolveFile("expected", "kubernetes.yml")); | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Using resource templates from") | ||
.contains("Adding a default Deployment") | ||
.contains("Adding revision history limit to 2") | ||
.contains("validating"); | ||
} | ||
|
||
@Test | ||
void ocResourceTask() throws IOException, ParseException { | ||
// When | ||
final BuildResult result = gradleRunner.withITProject(TEST_PROJECT) | ||
.withArguments("ocResource", "--stacktrace") | ||
.build(); | ||
// Then | ||
ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultOpenShiftResourceFile(), | ||
gradleRunner.resolveFile("expected", "openshift.yml")); | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Using resource templates from") | ||
.contains("Adding a default Deployment") | ||
.contains("Adding revision history limit to 2") | ||
.contains("validating"); | ||
} | ||
} |
Oops, something went wrong.