From 6615fc48b47fa761479e67404ab755a206a92bdf Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Tue, 5 Jul 2022 09:39:52 +0100 Subject: [PATCH] Fix IsIncludedOutOfTheBox to account for snapshots (#45) --- .../Products/SubProduct.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Elastic.Stack.ArtifactsApi/Products/SubProduct.cs b/src/Elastic.Stack.ArtifactsApi/Products/SubProduct.cs index a34df1b..521adf2 100644 --- a/src/Elastic.Stack.ArtifactsApi/Products/SubProduct.cs +++ b/src/Elastic.Stack.ArtifactsApi/Products/SubProduct.cs @@ -35,8 +35,19 @@ public SubProduct(string subProject, Func isValid = null, public string GetExistsMoniker(ElasticVersion version) => _getExistsMoniker(version); /// Whether the sub project is included in the distribution out of the box for the given version - public bool IsIncludedOutOfTheBox(ElasticVersion version) => - ShippedByDefaultAsOf != null && version >= ShippedByDefaultAsOf; + public bool IsIncludedOutOfTheBox(ElasticVersion version) + { + if (ShippedByDefaultAsOf is null) + return false; + + // When we are using a snapshot version of Elasticsearch compare on base version. + // This ensures that when testing with a snapshot, we install plugins correctly. + // e.g. When testing with 8.4.0-SNAPSHOT of elasticsearch, we don't expect to ingest-attachment, + // added in-box in 8.4.0 to be installed. + return version.ArtifactBuildState == ArtifactBuildState.Snapshot + ? version.BaseVersion() >= ShippedByDefaultAsOf.BaseVersion() + : version >= ShippedByDefaultAsOf; + } /// Whether the subProject is valid for the given version public bool IsValid(ElasticVersion version) => IsIncludedOutOfTheBox(version) || _isValid(version);