Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
loicottet committed Oct 22, 2024
1 parent 8798480 commit 7589a43
Show file tree
Hide file tree
Showing 16 changed files with 231 additions and 112 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/quarkus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,10 @@ jobs:
if: startsWith(matrix.os-name, 'ubuntu')
env:
TEST_MODULES: ${{matrix.test-modules}}
MATRIX_DUMP: ${{ toJson(matrix) }}
run: |
cd ${QUARKUS_PATH}
echo "$MATRIX_DUMP"
${GRAALVM_HOME}/bin/native-image --version
./mvnw $COMMON_MAVEN_ARGS -f integration-tests -pl "$TEST_MODULES" $NATIVE_TEST_MAVEN_ARGS
- name: Prepare failure archive (if maven failed)
Expand All @@ -184,3 +186,28 @@ jobs:
with:
name: test-reports-native-${{matrix.category}}
path: 'test-reports.tgz'
- name: "Probe stats"
run: ls ${QUARKUS_PATH}/integration-tests/*/target/quarkus-integration-test-*-999-SNAPSHOT-native-image-source-jar/reports
- name: "Upload stats"
id: upload
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ strategy.job-index }}
path: ${{ env.QUARKUS_PATH }}/integration-tests/*/target/quarkus-integration-test-*-999-SNAPSHOT-native-image-source-jar/reports/stats.json
retention-days: 1

gather-stats:
name: "Gather stats files"
runs-on: ubuntu-latest
if: success() || failure()
needs: [ native-tests ]
steps:
- name: "Download build stats"
uses: actions/download-artifact@v4
with:
path: artifacts
- name: "Report build stats"
run: |
ls -R artifacts
grep . artifacts/**/stats.json
38 changes: 35 additions & 3 deletions .github/workflows/reachability-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ jobs:
- name: "Checkout oracle/graalvm-reachability-metadata"
uses: actions/checkout@v4
with:
repository: oracle/graalvm-reachability-metadata
repository: loicottet/graalvm-reachability-metadata
ref: lottet/update
- name: Download GraalVM JDK build
uses: actions/download-artifact@v4
with:
Expand All @@ -134,6 +135,37 @@ jobs:
sudo systemctl daemon-reload
sudo systemctl restart docker
- name: "Run '${{ matrix.coordinates }}' tests"
id: run
run: |
./gradlew test -Pcoordinates=${{ matrix.coordinates }}
./gradlew test -Pcoordinates=${{ matrix.coordinates }} --continue
- name: "Transform coordinate"
id: coordinate
run: |
echo ${{ matrix.coordinates }} > coords.txt
sed -i "s/:/\//g" coords.txt
echo "COORDS=$(cat coords.txt)" > $GITHUB_ENV
sed -i "s/\//-/g" coords.txt
echo "ESC_COORDS=$(cat coords.txt)" >> $GITHUB_ENV
- name: "Upload stats"
id: upload
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ env.ESC_COORDS }}
path: tests/src/${{ env.COORDS }}/build/native/nativeTestCompile/reports/stats.json
retention-days: 1

gather-stats:
name: "Gather stats files"
runs-on: ubuntu-latest
if: success() || failure()
needs: [test-all-metadata]
steps:
- name: "Download build stats"
uses: actions/download-artifact@v4
with:
path: artifacts
- name: "Report build stats"
run: |
grep . artifacts/*/stats.json
3 changes: 3 additions & 0 deletions .github/workflows/spring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ jobs:
run: |
cd ${{ env.SPRING_PETCLINIC_PATH }}
./gradlew nativeTest
- name: "Report build stats"
run: |
cat ${{ env.SPRING_PETCLINIC_PATH }}/build/native/nativeTestCompile/reports/stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
*/
package org.graalvm.nativeimage.impl;

import java.util.concurrent.atomic.AtomicInteger;

public interface RuntimeReflectionSupport extends ReflectionRegistry {
// needed as reflection-specific ImageSingletons key
void registerAllMethodsQuery(ConfigurationCondition condition, boolean queriedOnly, Class<?> clazz);
Expand Down Expand Up @@ -67,4 +69,19 @@ public interface RuntimeReflectionSupport extends ReflectionRegistry {
void registerAllSignersQuery(ConfigurationCondition condition, Class<?> clazz);

void registerClassLookupException(ConfigurationCondition condition, String typeName, Throwable t);

AtomicInteger count = new AtomicInteger(0);
AtomicInteger relevantCount = new AtomicInteger(0);

static void increaseCount(boolean interest) {
count.incrementAndGet();
if (interest) {
relevantCount.incrementAndGet();
}
}

static int getCount(boolean interest) {
return interest ? relevantCount.get() : count.get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.Set;

import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;

import com.oracle.svm.core.SubstrateUtil;
Expand Down Expand Up @@ -228,6 +229,7 @@ protected static long asLong(Object value, String propertyName) {
protected UnresolvedConfigurationCondition parseCondition(EconomicMap<String, Object> data, boolean runtimeCondition) {
Object conditionData = data.get(CONDITIONAL_KEY);
if (conditionData != null) {
RuntimeReflectionSupport.increaseCount(false);
EconomicMap<String, Object> conditionObject = asMap(conditionData, "Attribute 'condition' must be an object");
if (conditionObject.containsKey(TYPE_REACHABLE_KEY) && conditionObject.containsKey(TYPE_REACHED_KEY)) {
failOnSchemaError("condition can not have both '" + TYPE_REACHED_KEY + "' and '" + TYPE_REACHABLE_KEY + "' set.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.graalvm.collections.EconomicMap;
import org.graalvm.collections.MapCursor;
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;

import com.oracle.svm.core.TypeResult;
Expand Down Expand Up @@ -109,6 +110,7 @@ private void parseResourcesObject(Object resourcesObject, Object origin) {
private void parsePatternEntry(Object data, BiConsumer<C, String> resourceRegistry, GlobPatternConsumer<C> globRegistry, String parentType) {
EconomicMap<String, Object> resource = asMap(data, "Elements of " + parentType + " must be a resource descriptor object");
checkAttributes(resource, "regex resource descriptor object", Collections.singletonList("pattern"), Collections.singletonList(CONDITIONAL_KEY));
RuntimeReflectionSupport.increaseCount(false);
TypeResult<C> resolvedConfigurationCondition = conditionResolver.resolveCondition(parseCondition(resource, false));
if (!resolvedConfigurationCondition.isPresent()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.util.List;

import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.ImageSingletons;
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;
import org.graalvm.nativeimage.impl.RuntimeSerializationSupport;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;

Expand Down Expand Up @@ -86,6 +88,7 @@ protected void parseSerializationDescriptorObject(EconomicMap<String, Object> da
} else {
checkAttributes(data, "serialization descriptor object", Collections.singleton(NAME_KEY), Arrays.asList(CUSTOM_TARGET_CONSTRUCTOR_CLASS_KEY, CONDITIONAL_KEY));
}
RuntimeReflectionSupport.increaseCount(false);

ConfigurationTypeDescriptor targetSerializationClass = new NamedConfigurationTypeDescriptor(asString(data.get(NAME_KEY)));
UnresolvedConfigurationCondition unresolvedCondition = parseCondition(data, false);
Expand All @@ -99,6 +102,9 @@ protected void parseSerializationDescriptorObject(EconomicMap<String, Object> da
serializationSupport.registerLambdaCapturingClass(condition.get(), className);
} else {
Object optionalCustomCtorValue = data.get(CUSTOM_TARGET_CONSTRUCTOR_CLASS_KEY);
if (optionalCustomCtorValue != null) {
RuntimeReflectionSupport.increaseCount(false);
}
String customTargetConstructorClass = optionalCustomCtorValue != null ? asString(optionalCustomCtorValue) : null;
if (targetSerializationClass instanceof NamedConfigurationTypeDescriptor namedClass) {
serializationSupport.registerWithTargetConstructorClass(condition.get(), namedClass.name(), customTargetConstructorClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.stream.Collectors;

import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;

import com.oracle.svm.core.TypeResult;
import com.oracle.svm.util.LogUtils;
Expand Down Expand Up @@ -75,6 +76,9 @@ protected void parseClassArray(List<Object> classes) {
protected abstract void parseClass(EconomicMap<String, Object> data);

protected void registerIfNotDefault(EconomicMap<String, Object> data, boolean defaultValue, T clazz, String propertyName, Runnable register) {
if (data.containsKey(propertyName)) {
RuntimeReflectionSupport.increaseCount(false);
}
if (data.containsKey(propertyName) ? asBoolean(data.get(propertyName), propertyName) : defaultValue) {
try {
register.run();
Expand All @@ -92,6 +96,7 @@ protected void parseFields(C condition, List<Object> fields, T clazz) {

private void parseField(C condition, EconomicMap<String, Object> data, T clazz) {
checkAttributes(data, "reflection field descriptor object", Collections.singleton("name"), Arrays.asList("allowWrite", "allowUnsafeAccess"));
RuntimeReflectionSupport.increaseCount(false);
String fieldName = asString(data.get("name"), "name");
boolean allowWrite = data.containsKey("allowWrite") && asBoolean(data.get("allowWrite"), "allowWrite");

Expand All @@ -112,6 +117,7 @@ protected void parseMethods(C condition, boolean queriedOnly, List<Object> metho

private void parseMethod(C condition, boolean queriedOnly, EconomicMap<String, Object> data, T clazz) {
checkAttributes(data, "reflection method descriptor object", Collections.singleton("name"), Collections.singleton("parameterTypes"));
RuntimeReflectionSupport.increaseCount(false);
String methodName = asString(data.get("name"), "name");
List<T> methodParameterTypes = null;
Object parameterTypes = data.get("parameterTypes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.graalvm.collections.EconomicMap;
import org.graalvm.collections.MapCursor;
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;

import com.oracle.svm.core.TypeResult;
Expand Down Expand Up @@ -59,6 +60,7 @@ public void parseAndRegister(Object json, URI origin) {
@Override
protected void parseClass(EconomicMap<String, Object> data) {
checkAttributes(data, "reflection class descriptor object", List.of(TYPE_KEY), OPTIONAL_REFLECT_METADATA_ATTRS);
RuntimeReflectionSupport.increaseCount(false);

Optional<ConfigurationTypeDescriptor> type = parseTypeContents(data.get(TYPE_KEY));
if (type.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.stream.Collectors;

import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;

import com.oracle.svm.core.TypeResult;
Expand Down Expand Up @@ -69,6 +70,7 @@ protected void parseBundlesObject(Object bundlesObject) {
private void parseBundle(Object bundle) {
EconomicMap<String, Object> resource = asMap(bundle, "Elements of 'bundles' list must be a bundle descriptor object");
checkAttributes(resource, "bundle descriptor object", Collections.singletonList("name"), Arrays.asList("locales", "classNames", "condition"));
RuntimeReflectionSupport.increaseCount(false);
String basename = asString(resource.get("name"));
TypeResult<C> resolvedConfigurationCondition = conditionResolver.resolveCondition(parseCondition(resource));
if (!resolvedConfigurationCondition.isPresent()) {
Expand Down Expand Up @@ -122,6 +124,7 @@ protected interface GlobPatternConsumer<T> {
private void parseGlobEntry(Object data, GlobPatternConsumer<C> resourceRegistry) {
EconomicMap<String, Object> globObject = asMap(data, "Elements of 'globs' list must be a glob descriptor objects");
checkAttributes(globObject, "glob resource descriptor object", Collections.singletonList(GLOB_KEY), List.of(CONDITIONAL_KEY, MODULE_KEY));
RuntimeReflectionSupport.increaseCount(false);
TypeResult<C> resolvedConfigurationCondition = conditionResolver.resolveCondition(parseCondition(globObject));
if (!resolvedConfigurationCondition.isPresent()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Optional;

import org.graalvm.collections.EconomicMap;
import org.graalvm.nativeimage.impl.RuntimeReflectionSupport;
import org.graalvm.nativeimage.impl.RuntimeSerializationSupport;
import org.graalvm.nativeimage.impl.UnresolvedConfigurationCondition;

Expand All @@ -49,6 +50,7 @@ public void parseAndRegister(Object json, URI origin) {
@Override
protected void parseSerializationDescriptorObject(EconomicMap<String, Object> data, boolean lambdaCapturingType) {
checkAttributes(data, "serialization descriptor object", List.of(TYPE_KEY), List.of(CONDITIONAL_KEY, CUSTOM_TARGET_CONSTRUCTOR_CLASS_KEY));
RuntimeReflectionSupport.increaseCount(false);

Optional<ConfigurationTypeDescriptor> targetSerializationClass = parseTypeContents(data.get(TYPE_KEY));
if (targetSerializationClass.isEmpty()) {
Expand All @@ -62,6 +64,9 @@ protected void parseSerializationDescriptorObject(EconomicMap<String, Object> da
}

Object optionalCustomCtorValue = data.get(CUSTOM_TARGET_CONSTRUCTOR_CLASS_KEY);
if (optionalCustomCtorValue != null) {
RuntimeReflectionSupport.increaseCount(false);
}
registerType(targetSerializationClass.get(), condition.get(), optionalCustomCtorValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.FeatureImpl.BeforeImageWriteAccessImpl;
import com.oracle.svm.hosted.ProgressReporter.LinkStrategy;
import com.oracle.svm.hosted.ProgressReporterJsonHelper.ImageDetailKey;
import com.oracle.svm.hosted.image.NativeImageHeap.ObjectInfo;
import com.oracle.svm.hosted.meta.HostedClass;
import com.oracle.svm.hosted.meta.HostedMetaAccess;
Expand Down Expand Up @@ -162,15 +161,15 @@ protected void calculate(BeforeImageWriteAccessImpl access) {
}
}
}
reporter.recordJsonMetric(ImageDetailKey.RESOURCE_SIZE_BYTES, resourcesByteArraySize);
// reporter.recordJsonMetric(ImageDetailKey.RESOURCE_SIZE_BYTES, resourcesByteArraySize);
if (resourcesByteArraySize > 0) {
addEntry(entries, byteArrayEntry, new HeapBreakdownEntry(BYTE_ARRAY_PREFIX, "embedded resources", "#glossary-embedded-resources"), resourcesByteArraySize, resourcesByteArrayCount);
}
}
/* Extract byte[] for graph encodings. */
if (graphEncodingByteLength >= 0) {
long graphEncodingSize = objectLayout.getArraySize(JavaKind.Byte, graphEncodingByteLength, true);
reporter.recordJsonMetric(ImageDetailKey.GRAPH_ENCODING_SIZE, graphEncodingSize);
// reporter.recordJsonMetric(ImageDetailKey.GRAPH_ENCODING_SIZE, graphEncodingSize);
addEntry(entries, byteArrayEntry, new HeapBreakdownEntry(BYTE_ARRAY_PREFIX, "graph encodings", "#glossary-graph-encodings"), graphEncodingSize, 1);
}
/* Add remaining byte[]. */
Expand Down
Loading

0 comments on commit 7589a43

Please sign in to comment.