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

[RESTEASY-3386] Add cloud tests for Kubernetes. #3894

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cloud-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ on:
- 'resteasy-dependencies-bom/**'
- 'resteasy-feature-pack/**'
- 'resteasy-security/**'
- 'resteasy-testsuite/cloud-tests/**'
- 'testsuite/cloud-tests/**'
schedule:
- cron: '0 0 * * *' # Every day at 00:00 UTC

Expand Down
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@
</plugins>
</build>
</profile>
<profile>
<id>debug-logs</id>
<activation>
<property>
<name>debug.logs</name>
</property>
</activation>
<properties>
<maven.test.redirectTestOutputToFile>false</maven.test.redirectTestOutputToFile>
</properties>
</profile>
</profiles>

<contributors>
Expand Down
Empty file.
87 changes: 87 additions & 0 deletions testsuite/cloud-tests/client-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~
~ Copyright 2023 Red Hat, Inc., and individual contributors
~ as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.resteasy.cloud.tests</groupId>
<artifactId>cloud-tests</artifactId>
<version>6.2.6.Final-SNAPSHOT</version>
</parent>

<artifactId>client-tests</artifactId>
<name>RESTEasy Cloud Testsuite: Client Tests</name>
<packaging>war</packaging>

<properties>
<skip.image>false</skip.image>
<wildfly.cloud.test.base.image.name>resteasy-cloud-test-image/cloud-server:latest</wildfly.cloud.test.base.image.name>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.resteasy.test</groupId>
<artifactId>test-utils</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<scope>provided</scope>
</dependency>

<!-- Test dependencies -->
<!-- TODO (jrp) fix this -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<!-- Use ROOT so we are registered as the root context -->
<finalName>ROOT</finalName>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* JBoss, Home of Professional Open Source.
*
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.resteasy.cloud.tests.client;

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

/**
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
*/
@Path("echo")
public class EchoResource {

@GET
@Path("/get/{msg}")
@Produces(MediaType.TEXT_PLAIN)
public String get(@PathParam("msg") final String msg) {
return msg;
}

@POST
@Path("/post")
@Produces(MediaType.TEXT_PLAIN)
public String post(final String msg) {
return msg;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source.
*
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.resteasy.cloud.tests.client;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

import io.dekorate.kubernetes.annotation.ImagePullPolicy;
import io.dekorate.kubernetes.annotation.KubernetesApplication;

/**
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
*/
@KubernetesApplication(imagePullPolicy = ImagePullPolicy.Always)
@ApplicationPath("/user")
public class RestActivator extends Application {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* JBoss, Home of Professional Open Source.
*
* Copyright 2023 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.resteasy.cloud.tests.client;

import static org.wildfly.test.cloud.common.WildflyTags.KUBERNETES;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import jakarta.inject.Inject;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Response;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.wildfly.test.cloud.common.TestHelper;
import org.wildfly.test.cloud.common.WildFlyCloudTestCase;
import org.wildfly.test.cloud.common.WildFlyKubernetesIntegrationTest;

/**
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
*/

@Tag(KUBERNETES)
@WildFlyKubernetesIntegrationTest
public class EchoIT extends WildFlyCloudTestCase {

@Inject
private Client client;

@Test
public void chineseGet() throws Exception {
get("你好");
}

@Test
public void chinesePost() throws Exception {
post("你好");
}

@Test
public void englishGet() throws Exception {
get("Hello!");
}

@Test
public void englishPost() throws Exception {
post("Hello!");
}

@Test
public void spanishGet() throws Exception {
get("¡Hola!");
}

@Test
public void spanishPost() throws Exception {
post("¡Hola!");
}

private void get(final String msg) throws Exception {
final TestHelper testHelper = getHelper();
testHelper.doWithWebPortForward("/user/echo/get/" + URLEncoder.encode(msg, StandardCharsets.UTF_8),
(url) -> {
try (Response response = client.target(url.toURI()).request().get()) {
final String content = response.readEntity(String.class);
Assertions.assertEquals(Response.Status.OK, response.getStatusInfo(), content);
Assertions.assertEquals(msg, content);
return null;
}
});
}

private void post(final String msg) throws Exception {
final TestHelper testHelper = getHelper();
testHelper.doWithWebPortForward("/user/echo/post/",
(url) -> {
try (Response response = client.target(url.toURI()).request().post(Entity.text(msg))) {
final String content = response.readEntity(String.class);
Assertions.assertEquals(Response.Status.OK, response.getStatusInfo(), content);
Assertions.assertEquals(msg, content);
return null;
}
});
}
}
66 changes: 66 additions & 0 deletions testsuite/cloud-tests/images/cloud-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~
~ Copyright 2023 Red Hat, Inc., and individual contributors
~ as indicated by the @author tags.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.resteasy.cloud.tests</groupId>
<artifactId>images</artifactId>
<version>6.2.6.Final-SNAPSHOT</version>
</parent>

<artifactId>cloud-server</artifactId>
<name>RESTEasy Cloud Testsuite: Cloud Container Image</name>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<executions>
<execution>
<id>provision-base-cloud-server</id>
<phase>process-test-resources</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>build-server</id>
<phase>process-test-classes</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>