Skip to content

Commit

Permalink
Failed to start Kamelet #493
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Sep 22, 2020
1 parent ce00982 commit 5254ebb
Show file tree
Hide file tree
Showing 18 changed files with 445 additions and 56 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ jobs:
native-image-project:
- :camel-k-quarkus-itests-core
- :camel-k-quarkus-itests-runtime
- :camel-k-quarkus-itests-runtime-kamelet
- :camel-k-quarkus-itests-cron
- :camel-k-quarkus-itests-master
- :camel-k-quarkus-itests-kamelet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import org.apache.camel.k.Constants;
import org.apache.camel.k.ContextCustomizer;
import org.apache.camel.k.SourceDefinition;
import org.apache.camel.k.SourceLoader;
import org.apache.camel.k.core.quarkus.RuntimeRecorder;
import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination;
import org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem;
import org.apache.camel.spi.StreamCachingStrategy;
Expand Down Expand Up @@ -99,10 +95,4 @@ void registerStreamCachingClasses(
StreamCachingStrategy.SpoolRule.class)
);
}

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
void customizeContext(RuntimeRecorder recorder, BuildProducer<CamelContextCustomizerBuildItem> customizers) {
customizers.produce(new CamelContextCustomizerBuildItem(recorder.registerCompositeClassLoader()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,4 @@ public JsonObject getServices() {
.add("services", builder)
.build();
}

@GET
@Path("/application-classloader")
@Produces(MediaType.TEXT_PLAIN)
public String getApplicationClassloader() {
return camelContext.getApplicationContextClassLoader().getClass().getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,4 @@ public void testServices() {
SourcesConfigurer.class.getName()
);
}

@DisabledOnNativeImage
@Test
public void testClassLoader() {
RestAssured.given()
.accept(MediaType.TEXT_PLAIN)
.get("/test/application-classloader")
.then()
.statusCode(200)
.body(is(CompositeClassloader.class.getName()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.json.JsonObject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
Expand All @@ -42,4 +43,11 @@ public class Application {
public JsonObject loadRoutes(@PathParam("name") String name, String code) throws Exception {
return LoaderSupport.inspectSource(context, name, "java", code);
}

@GET
@Path("/application-classloader")
@Produces(MediaType.TEXT_PLAIN)
public String getApplicationClassloader() {
return context.getApplicationContextClassLoader().getClass().getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.path.json.JsonPath;
import org.apache.camel.k.CompositeClassloader;
import org.apache.camel.util.IOHelper;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.is;

@DisabledOnNativeImage
@QuarkusTest
Expand Down Expand Up @@ -56,4 +58,15 @@ public void testLoadRoutes() throws IOException {
assertThat(p.getList("routes", String.class)).contains("java");
assertThat(p.getList("endpoints", String.class)).contains("direct://java", "log://java");
}

@DisabledOnNativeImage
@Test
public void testClassLoader() {
RestAssured.given()
.accept(MediaType.TEXT_PLAIN)
.get("/test/application-classloader")
.then()
.statusCode(200)
.body(is(CompositeClassloader.class.getName()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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">
<parent>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-itests</artifactId>
<version>1.5.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-k-quarkus-itests-runtime-kamelet</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-runtime-quarkus</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-kamelet</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.k</groupId>
<artifactId>camel-k-quarkus-loader-yaml</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin-version}</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>test.http.port.jvm</portName>
<portName>test.http.port.native</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<environmentVariables>
<ROUTES_DIR>${project.basedir}/src/test/resources/routes</ROUTES_DIR>
<CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF>
</environmentVariables>
<systemProperties>
<quarkus.http.test-port>${test.http.port.jvm}</quarkus.http.test-port>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<environmentVariables>
<ROUTES_DIR>${project.basedir}/src/test/resources/routes</ROUTES_DIR>
<CAMEL_K_CONF>${project.basedir}/src/test/resources/routes.properties</CAMEL_K_CONF>
</environmentVariables>
<systemProperties>
<quarkus.http.test-port>${test.http.port.native}</quarkus.http.test-port>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.camel.k.quarkus.it;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.apache.camel.FluentProducerTemplate;

@Path("/test")
@ApplicationScoped
public class Application {
@Inject
FluentProducerTemplate template;

@GET
@Path("/execute")
@Produces(MediaType.TEXT_PLAIN)
public String execute() {
return template.to("direct:process").request(String.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements. See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You 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.
## ---------------------------------------------------------------------------

#
# Quarkus
#
quarkus.log.console.enable = true
quarkus.banner.enabled = false

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.camel.k.quarkus.it;

import io.quarkus.test.junit.NativeImageTest;

@NativeImageTest
public class RuntimeIT extends RuntimeTest {
}
Loading

0 comments on commit 5254ebb

Please sign in to comment.