Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public int hashCode() {
@JsonIgnoreProperties(ignoreUnknown = true)
public static final class IndexConfig {
@JsonProperty("Mirrors")
private String mirrors;
private List<String> mirrors;

@JsonProperty("Name")
private String name;
Expand All @@ -111,14 +111,14 @@ public static final class IndexConfig {
* @see #mirrors
*/
@CheckForNull
public String getMirrors() {
public List<String> getMirrors() {
return mirrors;
}

/**
* @see #mirrors
*/
public IndexConfig withMirrors(String mirrors) {
public IndexConfig withMirrors(List<String> mirrors) {
this.mirrors = mirrors;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ private CertificateUtils() {

public static boolean verifyCertificatesExist(String dockerCertPath) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Method is static so you can place in src/test/resource/$package/$class/method 3 files and call this method with test path, should be pretty simple.

String[] files = {"ca.pem", "cert.pem", "key.pem"};
boolean result = true;
for (String file : files) {
File path = new File(dockerCertPath, file);
return path.exists();
result &= path.exists();
}

return true;
return result;
}

public static KeyStore createKeyStore(final String dockerCertPath) throws NoSuchAlgorithmException,
Expand Down
158 changes: 158 additions & 0 deletions src/test/java/com/github/dockerjava/api/model/InfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -169,4 +170,161 @@ public void serder1Json() throws IOException {

assertThat(info, is(withInfo));
}

@Test
public void serder2Json() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
final JavaType type = mapper.getTypeFactory().constructType(Info.class);

final Info info = testRoundTrip(VERSION_1_22,
"info/2.json",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you rename filename to something meaningful to initial issue that you had?
I called initial dump as 1.json because it was the first real dump, but it seems was bad idea to name file in such way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

or if it tests everything, then you can keep it.

type
);

final List<List<String>> driverStatus = asList(
asList("Pool Name", "docker-253:2-17567992-pool"),
asList("Pool Blocksize", "65.54 kB"),
asList("Base Device Size", "107.4 GB"),
asList("Backing Filesystem", "ext4"),
asList("Data file", "/dev/loop0"),
asList("Metadata file", "/dev/loop1"),
asList("Data Space Used", "3.89 GB"),
asList("Data Space Total", "107.4 GB"),
asList("Data Space Available", "103.5 GB"),
asList("Metadata Space Used", "5.46 MB"),
asList("Metadata Space Total", "2.147 GB"),
asList("Metadata Space Available", "2.142 GB"),
asList("Udev Sync Supported", "true"),
asList("Deferred Removal Enabled", "false"),
asList("Deferred Deletion Enabled", "false"),
asList("Deferred Deleted Device Count", "0"),
asList("Data loop file", "/var/lib/docker/devicemapper/devicemapper/data"),
asList("Metadata loop file", "/var/lib/docker/devicemapper/devicemapper/metadata"),
asList("Library Version", "1.02.107-RHEL7 (2015-12-01)")
);

final Map<String, List<String>> plugins = new LinkedHashMap<>();
plugins.put("Volume", singletonList("local"));
plugins.put("Network", asList("null", "host", "bridge"));
plugins.put("Authorization", null);

assertThat(info, notNullValue());
assertThat(info.getArchitecture(), equalTo("x86_64"));
assertThat(info.getContainersStopped(), is(2));
assertThat(info.getContainersPaused(), is(0));
assertThat(info.getContainersRunning(), is(0));
assertThat(info.getCpuCfsPeriod(), is(true));

// not available in this dump
assertThat(info.getCpuCfsQuota(), is(true));
assertThat(info.getDiscoveryBackend(), nullValue());
assertThat(info.getOomScoreAdj(), nullValue());

assertThat(info.getDriverStatuses(), notNullValue());
assertThat(info.getDriverStatuses(), hasSize(19));
assertThat(info.getDriverStatuses(), equalTo(driverStatus));

assertThat(info.getNGoroutines(), is(30));

assertThat(info.getSystemStatus(), CoreMatchers.nullValue());

assertThat(info.getPlugins(), equalTo(plugins));
assertThat(info.getPlugins(), hasEntry("Volume", singletonList("local")));
assertThat(info.getPlugins(), hasEntry("Authorization", null));

assertThat(info.getExperimentalBuild(), is(false));

assertThat(info.getHttpProxy(), isEmptyString());
assertThat(info.getHttpsProxy(), isEmptyString());
assertThat(info.getNoProxy(), isEmptyString());
assertThat(info.getOomKillDisable(), is(true));
assertThat(info.getOsType(), equalTo("linux"));

final InfoRegistryConfig registryConfig = info.getRegistryConfig();
assertThat(registryConfig, notNullValue());
final List<String> cidRs = registryConfig.getInsecureRegistryCIDRs();
assertThat(cidRs, notNullValue());
assertThat(cidRs, contains("127.0.0.0/8"));

final Map<String, IndexConfig> indexConfigs = registryConfig.getIndexConfigs();
assertThat(indexConfigs, notNullValue());
final IndexConfig indexConfig = new IndexConfig().withMirrors(null).withName("docker.io")
.withSecure(true).withOfficial(true);
assertThat(indexConfigs, hasEntry("docker.io", indexConfig));
final IndexConfig indexConfig2 = new IndexConfig().withMirrors(Collections.<String>emptyList()).withName("somehost:80")
.withSecure(false).withOfficial(false);
assertThat(indexConfigs, hasEntry("somehost:80", indexConfig2));
assertThat(registryConfig.getMirrors(), nullValue());

assertThat(info.getSystemTime(), is("2016-03-20T17:32:06.598846244+01:00"));
assertThat(info.getServerVersion(), is("1.10.2"));

assertThat(info.getCpuSet(), is(true));
assertThat(info.getCpuShares(), is(true));
assertThat(info.getIPv4Forwarding(), is(true));
assertThat(info.getBridgeNfIptables(), is(false));
assertThat(info.getBridgeNfIp6tables(), is(false));
assertThat(info.getDebug(), is(false));
assertThat(info.getNFd(), is(13));
assertThat(info.getOomKillDisable(), is(true));
assertThat(info.getLoggingDriver(), is("json-file"));
assertThat(info.getOperatingSystem(), is("Red Hat Enterprise Linux Workstation 7.2 (Maipo)"));
assertThat(info.getClusterStore(), is(""));


final Info withInfo = new Info().withArchitecture("x86_64")
.withContainers(2)
.withContainersRunning(0)
.withContainersPaused(0)
.withContainersStopped(2)
.withImages(55)
.withId("H52J:52LG:YP4W:EHKY:SRK5:RYG6:ETWR:7AR3:MTFJ:PC6C:4YF2:NTN2")
.withDriver("devicemapper")
.withDriverStatuses(driverStatus)
.withSystemStatus(null)
.withPlugins(plugins)
.withMemoryLimit(true)
.withSwapLimit(true)
.withCpuCfsPeriod(true)
.withCpuCfsQuota(true)
.withCpuShares(true)
.withCpuSet(true)
.withIPv4Forwarding(true)
.withBridgeNfIptables(false)
.withBridgeNfIp6tables(false)
.withDebug(false)
.withNFd(13)
.withOomKillDisable(true)
.withNGoroutines(30)
.withSystemTime("2016-03-20T17:32:06.598846244+01:00")
.withExecutionDriver("native-0.2")
.withLoggingDriver("json-file")
.withNEventsListener(0)
.withKernelVersion("3.10.0-327.10.1.el7.x86_64")
.withOperatingSystem("Red Hat Enterprise Linux Workstation 7.2 (Maipo)")
.withOsType("linux")
.withIndexServerAddress("https://index.docker.io/v1/")
.withRegistryConfig(registryConfig)
.withInitSha1("672d65f3cf8816fbda421afeed7e52c0ca17d5e7")
.withInitPath("/usr/libexec/docker/dockerinit")
.withNCPU(8)
.withMemTotal(33350918144L)
.withDockerRootDir("/var/lib/docker")
.withHttpProxy("")
.withHttpsProxy("")
.withNoProxy("")
.withName("somename")
.withLabels(null)
.withExperimentalBuild(false)
.withServerVersion("1.10.2")
.withClusterStore("")
.withClusterAdvertise("")
//shredinger-fields
.withDiscoveryBackend(null)
.withOomScoreAdj(null)
.withSockets(null)
;

assertThat(info, is(withInfo));
}
}
165 changes: 165 additions & 0 deletions src/test/resources/samples/1.22/info/2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it real dump or copy-paste of existed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You might notice that the DriverStatus part is quite different. Took me some time to put that all in. Also the other IDs, OS and so on are different. This is a dump from my machine. the only thing changed is the host name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 Hard work, i spent a lot of time filling and comparing all this things initially.

"ID":"H52J:52LG:YP4W:EHKY:SRK5:RYG6:ETWR:7AR3:MTFJ:PC6C:4YF2:NTN2",
"Containers":2,
"ContainersRunning":0,
"ContainersPaused":0,
"ContainersStopped":2,
"Images":55,
"Driver":"devicemapper",
"DriverStatus":[
[
"Pool Name",
"docker-253:2-17567992-pool"
],
[
"Pool Blocksize",
"65.54 kB"
],
[
"Base Device Size",
"107.4 GB"
],
[
"Backing Filesystem",
"ext4"
],
[
"Data file",
"/dev/loop0"
],
[
"Metadata file",
"/dev/loop1"
],
[
"Data Space Used",
"3.89 GB"
],
[
"Data Space Total",
"107.4 GB"
],
[
"Data Space Available",
"103.5 GB"
],
[
"Metadata Space Used",
"5.46 MB"
],
[
"Metadata Space Total",
"2.147 GB"
],
[
"Metadata Space Available",
"2.142 GB"
],
[
"Udev Sync Supported",
"true"
],
[
"Deferred Removal Enabled",
"false"
],
[
"Deferred Deletion Enabled",
"false"
],
[
"Deferred Deleted Device Count",
"0"
],
[
"Data loop file",
"/var/lib/docker/devicemapper/devicemapper/data"
],
[
"Metadata loop file",
"/var/lib/docker/devicemapper/devicemapper/metadata"
],
[
"Library Version",
"1.02.107-RHEL7 (2015-12-01)"
]
],
"SystemStatus":null,
"Plugins":{
"Volume":[
"local"
],
"Network":[
"null",
"host",
"bridge"
],
"Authorization":null
},
"MemoryLimit":true,
"SwapLimit":true,
"CpuCfsPeriod":true,
"CpuCfsQuota":true,
"CPUShares":true,
"CPUSet":true,
"IPv4Forwarding":true,
"BridgeNfIptables":false,
"BridgeNfIp6tables":false,
"Debug":false,
"NFd":13,
"OomKillDisable":true,
"NGoroutines":30,
"SystemTime":"2016-03-20T17:32:06.598846244+01:00",
"ExecutionDriver":"native-0.2",
"LoggingDriver":"json-file",
"NEventsListener":0,
"KernelVersion":"3.10.0-327.10.1.el7.x86_64",
"PkgVersion":"docker-1.10.2-6.git0f5ac89.el7.x86_64",
"OperatingSystem":"Red Hat Enterprise Linux Workstation 7.2 (Maipo)",
"OSType":"linux",
"Architecture":"x86_64",
"IndexServerAddress":"https://index.docker.io/v1/",
"IndexServerName":"docker.io",
"RegistryConfig":{
"InsecureRegistryCIDRs":[
"127.0.0.0/8"
],
"IndexConfigs":{
"docker.io":{
"Name":"docker.io",
"Mirrors":null,
"Secure":true,
"Official":true
},
"somehost:80":{
"Name":"somehost:80",
"Mirrors":[

],
"Secure":false,
"Official":false
}
},
"Mirrors":null
},
"InitSha1":"672d65f3cf8816fbda421afeed7e52c0ca17d5e7",
"InitPath":"/usr/libexec/docker/dockerinit",
"NCPU":8,
"MemTotal":33350918144,
"DockerRootDir":"/var/lib/docker",
"HttpProxy":"",
"HttpsProxy":"",
"NoProxy":"",
"Name":"somename",
"Labels":null,
"ExperimentalBuild":false,
"ServerVersion":"1.10.2",
"ClusterStore":"",
"ClusterAdvertise":"",
"Registries":[
{
"Name":"docker.io",
"Secure":true
}
]
}