-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #692 from xlight05/enable-native-tests
Add graalvm build args and enable native tests
- Loading branch information
Showing
17 changed files
with
153 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
[package] | ||
org = "ballerina" | ||
name = "cloud" | ||
version = "2.7.1" | ||
version = "2.8.0" | ||
repository = "https://github.com/ballerina-platform/module-ballerina-c2c" | ||
license = ["Apache-2.0"] | ||
keywords = ["cloud", "kubernetes", "docker", "k8s", "c2c"] | ||
distribution = "2201.6.0" | ||
distribution = "2201.7.0" |
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
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
compiler-plugin-tests/src/test/java/io/ballerina/c2c/test/samples/NativeArgsTest.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) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* WSO2 Inc. 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 io.ballerina.c2c.test.samples; | ||
|
||
import io.ballerina.c2c.exceptions.KubernetesPluginException; | ||
import io.ballerina.c2c.test.utils.KubernetesTestUtils; | ||
import io.ballerina.c2c.utils.KubernetesUtils; | ||
import org.apache.commons.io.FilenameUtils; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import static io.ballerina.c2c.KubernetesConstants.DOCKER; | ||
|
||
/** | ||
* Test cases for docker cloud option as a project. | ||
*/ | ||
public class NativeArgsTest { | ||
|
||
protected static final Path SAMPLE_DIR = Paths.get(FilenameUtils.separatorsToSystem( | ||
System.getProperty("sampleDir"))); | ||
private static final Path SOURCE_DIR_PATH = SAMPLE_DIR.resolve("graalvm-build-args"); | ||
private static final Path DOCKER_TARGET_PATH = | ||
SOURCE_DIR_PATH.resolve("target").resolve(DOCKER).resolve("native_args"); | ||
@Test | ||
public void validateDockerBuildOption() throws IOException, InterruptedException, KubernetesPluginException { | ||
Assert.assertEquals(KubernetesTestUtils.compileBallerinaProject(SOURCE_DIR_PATH), 0); | ||
File dockerFile = DOCKER_TARGET_PATH.resolve("Dockerfile").toFile(); | ||
String content = Files.readString(dockerFile.toPath(), StandardCharsets.UTF_8); | ||
Assert.assertTrue(dockerFile.exists()); | ||
Assert.assertTrue(content.contains("--static")); | ||
KubernetesUtils.deleteDirectory(DOCKER_TARGET_PATH); | ||
} | ||
|
||
@Test(dependsOnMethods = { "validateDockerBuildOption" }) | ||
public void validateK8sBuildOption() throws IOException, InterruptedException, KubernetesPluginException { | ||
Assert.assertEquals(KubernetesTestUtils.compileBallerinaProject(SOURCE_DIR_PATH, "k8s"), 0); | ||
File dockerFile = DOCKER_TARGET_PATH.resolve("Dockerfile").toFile(); | ||
String content = Files.readString(dockerFile.toPath(), StandardCharsets.UTF_8); | ||
Assert.assertTrue(dockerFile.exists()); | ||
Assert.assertTrue(content.contains("--static")); | ||
KubernetesUtils.deleteDirectory(DOCKER_TARGET_PATH); | ||
} | ||
} |
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
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
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
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 |
---|---|---|
|
@@ -15,4 +15,5 @@ | |
|
||
native-image -jar "$1" \ | ||
--no-fallback \ | ||
-H:Name="$2" | ||
-H:Name="${2}" \ | ||
${3:+$(echo " $3")} |
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,10 @@ | ||
[package] | ||
org = "hello" | ||
name= "native_args" | ||
version = "0.0.1" | ||
|
||
[build-options] | ||
observabilityIncluded = true | ||
cloud = "docker" | ||
graalvm = true | ||
graalvmBuildOptions = "--static --libc=musl" |
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,7 @@ | ||
[container.image] | ||
name = "build-arg" | ||
repository = "xlight05" | ||
tag = "1.0.0" | ||
|
||
[settings] | ||
buildImage = false |
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,25 @@ | ||
// Copyright (c) 2023 WSO2 Inc. (http://www.wso2.org) All Rights Reserved. | ||
// | ||
// WSO2 Inc. 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. | ||
|
||
import ballerina/http; | ||
|
||
listener http:Listener helloWorldEP = new (9095); | ||
|
||
service /hello on helloWorldEP { | ||
resource function get . () returns string { | ||
return "Hello World!"; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,4 +6,4 @@ version = "0.0.1" | |
[build-options] | ||
observabilityIncluded = true | ||
cloud = "k8s" | ||
native = true | ||
graalvm = true |
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