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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow-up changes for fixing RepositoryResolver install lists for tolerated dependencies #19963

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
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,17 @@ public class RepositoryResolver {

/**
* Map from symbolic name to feature for all features returned as resolved by the kernel resolver
* <p>
* Keyset is mutually exclusive with {@link #featuresMissing} and {@link #requirementsFoundForOtherProducts}
*/
Map<String, ProvisioningFeatureDefinition> resolvedFeatures;

/**
* List of requested features that were reported missing by the kernel resolver and weren't found in the repository applicable to another product.
* <p>
* May include sample names if they were missing
* <p>
* Mutually exclusive with {@link #resolvedFeatures} and {@link #requirementsFoundForOtherProducts}
*/
List<String> featuresMissing;
Comment on lines 83 to 97
Copy link
Member Author

@Azquelt Azquelt Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fairly straightforward to validate that these sets (and requirementsFoundForOtherProducts) are mutually exclusive as they only have items added to them within the resolveFeatures() method.

The kernel resolver returns a list of resolved features and a list of missing features, and then the missing features are split between the featuresMissing and requirementsFoundForOtherProducts sets.


Expand All @@ -101,6 +105,8 @@ public class RepositoryResolver {
* List of requirements which couldn't be resolved but for which we found a solution that applied to the wrong product
* <p>
* Each requirement will be a symbolic name, feature name or sample name
* <p>
* Mutually exclusive with {@link #resolvedFeatures} and {@link #featuresMissing}
*/
Set<String> requirementsFoundForOtherProducts;

Expand Down Expand Up @@ -547,7 +553,7 @@ List<RepositoryResource> createInstallList(SampleResource resource) {
if (feature == null) {
allDependenciesResolved = false;
// Unless we know it exists but applies to another product, note the missing requirement as well
if (!requirementsFoundForOtherProducts.contains(featureName) && featuresMissing.contains(featureName)) {
if (featuresMissing.contains(featureName)) {
missingRequirements.add(new MissingRequirement(featureName, resource));
}
} else {
Expand Down Expand Up @@ -593,7 +599,7 @@ List<RepositoryResource> createInstallList(String featureName) {
if (feature == null) {
// Feature missing
missingTopLevelRequirements.add(featureName);
if (!requirementsFoundForOtherProducts.contains(featureName) && featuresMissing.contains(featureName)) {
if (featuresMissing.contains(featureName)) {
missingRequirements.add(new MissingRequirement(featureName, null));
}
return Collections.emptyList();
Expand Down Expand Up @@ -701,7 +707,7 @@ boolean populateMaxDistanceMap(Map<String, Integer> maxDistanceMap, String featu
// We found the dependency, continue populating the distance map
result &= populateMaxDistanceMap(maxDistanceMap, resolvedFeatureName, currentDistance + 1, currentStack, missingRequirements);
} else {
if (!requirementsFoundForOtherProducts.contains(featureName) && featuresMissing.contains(dependency.getSymbolicName())) {
if (featuresMissing.contains(dependency.getSymbolicName())) {
// The dependency was totally missing, add it to the list of missing requirements
missingRequirements.add(new MissingRequirement(dependency.getSymbolicName(), getResource(feature)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ public void testCreateInstallListAutoFeature() {
*/
@Test
public void testCreateInstallListToleratesPartiallyInstalled() {
@SuppressWarnings("unused")
MockFeature base10 = new MockFeature("com.example.base-1.0");
MockFeature base20 = new MockFeature("com.example.base-2.0");

Expand All @@ -282,6 +281,7 @@ public void testCreateInstallListToleratesPartiallyInstalled() {
featureB.addRequireFeatureWithTolerates("com.example.base-2.0", Collections.emptyList());

RepositoryResolver resolver = testResolver().withResolvedInstalledFeature(base20, featureA)
.withInstalledFeature(base10, internalA10)
.withResolvedFeature(internalA20, featureB)
.build();

Expand Down Expand Up @@ -321,6 +321,11 @@ public ResolverBuilder withResolvedFeature(EsaResource... esas) {
return this;
}

public ResolverBuilder withInstalledFeature(ProvisioningFeatureDefinition... definitions) {
installedFeatures.addAll(Arrays.asList(definitions));
return this;
}

public ResolverBuilder withResolvedInstalledFeature(ProvisioningFeatureDefinition... definitions) {
installedFeatures.addAll(Arrays.asList(definitions));
for (ProvisioningFeatureDefinition feature : definitions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2019 IBM Corporation and others.
* Copyright (c) 2018, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 IBM Corporation and others.
* Copyright (c) 2018, 2022 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down