Skip to content

Commit

Permalink
Add unit tests for VBV-1954 and VBV-1955
Browse files Browse the repository at this point in the history
Both issues were due to a missing schema in the registry address. The
schema was missing because the registries were HTTPS registries and the
HTTPS schema is the default one.

This commit adds two test cases that will ensure all supported variants
(http/https/no schema) are covered by the code.

Change-Id: I65b965d114525b4a38af2a85d6fc6189a03d57c1
Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/31284
Closures-Verified: jenkins <[email protected]>
Upgrade-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
Reviewed-by: Antonio Filipov <[email protected]>
CS-Verified: jenkins <[email protected]>
  • Loading branch information
shadjiiski committed Apr 13, 2018
1 parent ee1a688 commit be7021c
Showing 1 changed file with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public void testFilterRegistriesByPath() throws Throwable {
createRegistry("https://test.registry.com:5000/vmware/test", null),
createRegistry("https://test.registry.com:5000/test", null),
createRegistry("https://test.registry.com:5000/test2", null),
createRegistry("https://test.registry.com:5001/vmware", null),
createRegistry("https://test.registry.com:5001", null)
createRegistry("http://test.registry.com:5001/vmware", null),
createRegistry("http://test.registry.com:5001", null),
createRegistry("test.registry.com:5002/no-schema", null)
);

host.log("Test same path different hosts");
Expand All @@ -123,7 +124,7 @@ public void testFilterRegistriesByPath() throws Throwable {
filteredRegistries = RegistryUtil.filterRegistriesByPath(host, registries, image);
assertNotNull(filteredRegistries);
assertEquals(1, filteredRegistries.size());
assertEquals("https://test.registry.com:5001", filteredRegistries.get(0).address);
assertEquals("http://test.registry.com:5001", filteredRegistries.get(0).address);

host.log("Test registry no path");
image = DockerImage.fromParts("test.registry.com:5001", "vmware",
Expand Down Expand Up @@ -152,8 +153,32 @@ public void testFilterRegistriesByPath() throws Throwable {
filteredRegistries.stream().forEach(r -> {
assertTrue(r.address.contains("test.registry.com:5000/test"));
});

host.log("Test registry without schema");
image = DockerImage.fromParts("test.registry.com:5002", "no-schema", "test", "latest");
filteredRegistries = RegistryUtil.filterRegistriesByPath(host, registries, image);
assertNotNull(filteredRegistries);
assertEquals(1, filteredRegistries.size());
filteredRegistries.stream().forEach(r -> {
assertTrue(r.address.contains("test.registry.com:5002/no-schema"));
});
}

@Test
public void testFindRegistriesByHostnameWithDifferentSchemas() throws Throwable {
List<RegistryState> expectedRegistries = new ArrayList<>();
expectedRegistries.add(createRegistry("http://test.registry.com:5000", null));
expectedRegistries.add(createRegistry("https://test.registry.com:5000", null));
expectedRegistries.add(createRegistry("test.registry.com:5000", null));

// unexpected registries
createRegistry("ftp://test.registry.com:5000", null);
createRegistry("file://test.registry.com:5000", null);
createRegistry("http://test.registry.com:5001", null);
createRegistry("https://test.registry.com:5002", null);

verifyRegistryLinksByHostname("test.registry.com:5000", (String) null, expectedRegistries);
}

private void verifyRegistryLinksByHostname(String hostname, String tenantLink,
Collection<RegistryState> expectedRegistries) {
Expand Down

0 comments on commit be7021c

Please sign in to comment.