Skip to content

Commit

Permalink
test : Update ApiVersionIT and PluralizeIT to work with OKD 4.14.0
Browse files Browse the repository at this point in the history
+ Relax assertion check in ApiVersionsIT to not match exact hostname for
  server address
+ Add an exception in PluralizeIT for type ResourceAccessReview, it's
  singular name is coming as localresourceaccessreview from OpenShift
  Aggregated Discovery API

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Oct 21, 2024
1 parent a0c399d commit d477988
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ void testApiVersions() {
.asInstanceOf(InstanceOfAssertFactories.list(ServerAddressByClientCIDR.class))
.singleElement()
.hasFieldOrPropertyWithValue("clientCIDR", "0.0.0.0/0")
.hasFieldOrPropertyWithValue("serverAddress",
String.format("%s:%d", client.getMasterUrl().getHost(), client.getMasterUrl().getPort()));
.extracting("serverAddress")
.asString()
.isNotBlank();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.junit.jupiter.params.provider.MethodSource;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.stream.Stream;
Expand All @@ -39,6 +40,10 @@
@RequireK8sVersionAtLeast(majorVersion = 1, minorVersion = 16)
class PluralizeIT {

// This might be a mistake in OpenShift Aggregated Discovery API,
// The resource kind is ResourceAccessReview, and it's singularName is set as localresourceaccessreview
private static final String[] EXCEPTIONAL_SINGULAR_NAME = new String[] { "localresourceaccessreview" };

@DisplayName("toPlural, should return argument's plural")
@ParameterizedTest(name = "{index} {0}: ''{1}'' plural is ''{2}''")
@MethodSource("toPluralInput")
Expand Down Expand Up @@ -66,7 +71,9 @@ static Stream<Arguments> toPluralInput() {
.map(ar -> arguments(
ar.getKind(),
// So far singularName field is always blank, we fall back to lower-cased kind
Utils.isNullOrEmpty(ar.getSingularName()) ? ar.getKind().toLowerCase(Locale.ROOT) : ar.getSingularName(),
Utils.isNullOrEmpty(ar.getSingularName()) || Arrays.asList(EXCEPTIONAL_SINGULAR_NAME).contains(ar.getSingularName())
? ar.getKind().toLowerCase(Locale.ROOT)
: ar.getSingularName(),
ar.getName()));
}
}

0 comments on commit d477988

Please sign in to comment.