|
7 | 7 | import org.testng.annotations.Test; |
8 | 8 |
|
9 | 9 | import java.io.IOException; |
| 10 | +import java.util.Collections; |
10 | 11 | import java.util.LinkedHashMap; |
11 | 12 | import java.util.List; |
12 | 13 | import java.util.Map; |
@@ -169,4 +170,161 @@ public void serder1Json() throws IOException { |
169 | 170 |
|
170 | 171 | assertThat(info, is(withInfo)); |
171 | 172 | } |
| 173 | + |
| 174 | + @Test |
| 175 | + public void serder2Json() throws IOException { |
| 176 | + final ObjectMapper mapper = new ObjectMapper(); |
| 177 | + final JavaType type = mapper.getTypeFactory().constructType(Info.class); |
| 178 | + |
| 179 | + final Info info = testRoundTrip(VERSION_1_22, |
| 180 | + "info/2.json", |
| 181 | + type |
| 182 | + ); |
| 183 | + |
| 184 | + final List<List<String>> driverStatus = asList( |
| 185 | + asList("Pool Name", "docker-253:2-17567992-pool"), |
| 186 | + asList("Pool Blocksize", "65.54 kB"), |
| 187 | + asList("Base Device Size", "107.4 GB"), |
| 188 | + asList("Backing Filesystem", "ext4"), |
| 189 | + asList("Data file", "/dev/loop0"), |
| 190 | + asList("Metadata file", "/dev/loop1"), |
| 191 | + asList("Data Space Used", "3.89 GB"), |
| 192 | + asList("Data Space Total", "107.4 GB"), |
| 193 | + asList("Data Space Available", "103.5 GB"), |
| 194 | + asList("Metadata Space Used", "5.46 MB"), |
| 195 | + asList("Metadata Space Total", "2.147 GB"), |
| 196 | + asList("Metadata Space Available", "2.142 GB"), |
| 197 | + asList("Udev Sync Supported", "true"), |
| 198 | + asList("Deferred Removal Enabled", "false"), |
| 199 | + asList("Deferred Deletion Enabled", "false"), |
| 200 | + asList("Deferred Deleted Device Count", "0"), |
| 201 | + asList("Data loop file", "/var/lib/docker/devicemapper/devicemapper/data"), |
| 202 | + asList("Metadata loop file", "/var/lib/docker/devicemapper/devicemapper/metadata"), |
| 203 | + asList("Library Version", "1.02.107-RHEL7 (2015-12-01)") |
| 204 | + ); |
| 205 | + |
| 206 | + final Map<String, List<String>> plugins = new LinkedHashMap<>(); |
| 207 | + plugins.put("Volume", singletonList("local")); |
| 208 | + plugins.put("Network", asList("null", "host", "bridge")); |
| 209 | + plugins.put("Authorization", null); |
| 210 | + |
| 211 | + assertThat(info, notNullValue()); |
| 212 | + assertThat(info.getArchitecture(), equalTo("x86_64")); |
| 213 | + assertThat(info.getContainersStopped(), is(2)); |
| 214 | + assertThat(info.getContainersPaused(), is(0)); |
| 215 | + assertThat(info.getContainersRunning(), is(0)); |
| 216 | + assertThat(info.getCpuCfsPeriod(), is(true)); |
| 217 | + |
| 218 | + // not available in this dump |
| 219 | + assertThat(info.getCpuCfsQuota(), is(true)); |
| 220 | + assertThat(info.getDiscoveryBackend(), nullValue()); |
| 221 | + assertThat(info.getOomScoreAdj(), nullValue()); |
| 222 | + |
| 223 | + assertThat(info.getDriverStatuses(), notNullValue()); |
| 224 | + assertThat(info.getDriverStatuses(), hasSize(19)); |
| 225 | + assertThat(info.getDriverStatuses(), equalTo(driverStatus)); |
| 226 | + |
| 227 | + assertThat(info.getNGoroutines(), is(30)); |
| 228 | + |
| 229 | + assertThat(info.getSystemStatus(), CoreMatchers.nullValue()); |
| 230 | + |
| 231 | + assertThat(info.getPlugins(), equalTo(plugins)); |
| 232 | + assertThat(info.getPlugins(), hasEntry("Volume", singletonList("local"))); |
| 233 | + assertThat(info.getPlugins(), hasEntry("Authorization", null)); |
| 234 | + |
| 235 | + assertThat(info.getExperimentalBuild(), is(false)); |
| 236 | + |
| 237 | + assertThat(info.getHttpProxy(), isEmptyString()); |
| 238 | + assertThat(info.getHttpsProxy(), isEmptyString()); |
| 239 | + assertThat(info.getNoProxy(), isEmptyString()); |
| 240 | + assertThat(info.getOomKillDisable(), is(true)); |
| 241 | + assertThat(info.getOsType(), equalTo("linux")); |
| 242 | + |
| 243 | + final InfoRegistryConfig registryConfig = info.getRegistryConfig(); |
| 244 | + assertThat(registryConfig, notNullValue()); |
| 245 | + final List<String> cidRs = registryConfig.getInsecureRegistryCIDRs(); |
| 246 | + assertThat(cidRs, notNullValue()); |
| 247 | + assertThat(cidRs, contains("127.0.0.0/8")); |
| 248 | + |
| 249 | + final Map<String, IndexConfig> indexConfigs = registryConfig.getIndexConfigs(); |
| 250 | + assertThat(indexConfigs, notNullValue()); |
| 251 | + final IndexConfig indexConfig = new IndexConfig().withMirrors(null).withName("docker.io") |
| 252 | + .withSecure(true).withOfficial(true); |
| 253 | + assertThat(indexConfigs, hasEntry("docker.io", indexConfig)); |
| 254 | + final IndexConfig indexConfig2 = new IndexConfig().withMirrors(Collections.<String>emptyList()).withName("somehost:80") |
| 255 | + .withSecure(false).withOfficial(false); |
| 256 | + assertThat(indexConfigs, hasEntry("somehost:80", indexConfig2)); |
| 257 | + assertThat(registryConfig.getMirrors(), nullValue()); |
| 258 | + |
| 259 | + assertThat(info.getSystemTime(), is("2016-03-20T17:32:06.598846244+01:00")); |
| 260 | + assertThat(info.getServerVersion(), is("1.10.2")); |
| 261 | + |
| 262 | + assertThat(info.getCpuSet(), is(true)); |
| 263 | + assertThat(info.getCpuShares(), is(true)); |
| 264 | + assertThat(info.getIPv4Forwarding(), is(true)); |
| 265 | + assertThat(info.getBridgeNfIptables(), is(false)); |
| 266 | + assertThat(info.getBridgeNfIp6tables(), is(false)); |
| 267 | + assertThat(info.getDebug(), is(false)); |
| 268 | + assertThat(info.getNFd(), is(13)); |
| 269 | + assertThat(info.getOomKillDisable(), is(true)); |
| 270 | + assertThat(info.getLoggingDriver(), is("json-file")); |
| 271 | + assertThat(info.getOperatingSystem(), is("Red Hat Enterprise Linux Workstation 7.2 (Maipo)")); |
| 272 | + assertThat(info.getClusterStore(), is("")); |
| 273 | + |
| 274 | + |
| 275 | + final Info withInfo = new Info().withArchitecture("x86_64") |
| 276 | + .withContainers(2) |
| 277 | + .withContainersRunning(0) |
| 278 | + .withContainersPaused(0) |
| 279 | + .withContainersStopped(2) |
| 280 | + .withImages(55) |
| 281 | + .withId("H52J:52LG:YP4W:EHKY:SRK5:RYG6:ETWR:7AR3:MTFJ:PC6C:4YF2:NTN2") |
| 282 | + .withDriver("devicemapper") |
| 283 | + .withDriverStatuses(driverStatus) |
| 284 | + .withSystemStatus(null) |
| 285 | + .withPlugins(plugins) |
| 286 | + .withMemoryLimit(true) |
| 287 | + .withSwapLimit(true) |
| 288 | + .withCpuCfsPeriod(true) |
| 289 | + .withCpuCfsQuota(true) |
| 290 | + .withCpuShares(true) |
| 291 | + .withCpuSet(true) |
| 292 | + .withIPv4Forwarding(true) |
| 293 | + .withBridgeNfIptables(false) |
| 294 | + .withBridgeNfIp6tables(false) |
| 295 | + .withDebug(false) |
| 296 | + .withNFd(13) |
| 297 | + .withOomKillDisable(true) |
| 298 | + .withNGoroutines(30) |
| 299 | + .withSystemTime("2016-03-20T17:32:06.598846244+01:00") |
| 300 | + .withExecutionDriver("native-0.2") |
| 301 | + .withLoggingDriver("json-file") |
| 302 | + .withNEventsListener(0) |
| 303 | + .withKernelVersion("3.10.0-327.10.1.el7.x86_64") |
| 304 | + .withOperatingSystem("Red Hat Enterprise Linux Workstation 7.2 (Maipo)") |
| 305 | + .withOsType("linux") |
| 306 | + .withIndexServerAddress("https://index.docker.io/v1/") |
| 307 | + .withRegistryConfig(registryConfig) |
| 308 | + .withInitSha1("672d65f3cf8816fbda421afeed7e52c0ca17d5e7") |
| 309 | + .withInitPath("/usr/libexec/docker/dockerinit") |
| 310 | + .withNCPU(8) |
| 311 | + .withMemTotal(33350918144L) |
| 312 | + .withDockerRootDir("/var/lib/docker") |
| 313 | + .withHttpProxy("") |
| 314 | + .withHttpsProxy("") |
| 315 | + .withNoProxy("") |
| 316 | + .withName("somename") |
| 317 | + .withLabels(null) |
| 318 | + .withExperimentalBuild(false) |
| 319 | + .withServerVersion("1.10.2") |
| 320 | + .withClusterStore("") |
| 321 | + .withClusterAdvertise("") |
| 322 | + //shredinger-fields |
| 323 | + .withDiscoveryBackend(null) |
| 324 | + .withOomScoreAdj(null) |
| 325 | + .withSockets(null) |
| 326 | + ; |
| 327 | + |
| 328 | + assertThat(info, is(withInfo)); |
| 329 | + } |
172 | 330 | } |
0 commit comments