github.com/google/cadvisor@v0.49.1/metrics/prometheus_fake.go (about)

     1  // Copyright 2020 Google Inc. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package metrics
    16  
    17  import (
    18  	"errors"
    19  	"time"
    20  
    21  	info "github.com/google/cadvisor/info/v1"
    22  	v2 "github.com/google/cadvisor/info/v2"
    23  )
    24  
    25  type testSubcontainersInfoProvider struct{}
    26  
    27  func (p testSubcontainersInfoProvider) GetVersionInfo() (*info.VersionInfo, error) {
    28  	return &info.VersionInfo{
    29  		KernelVersion:      "4.1.6-200.fc22.x86_64",
    30  		ContainerOsVersion: "Fedora 22 (Twenty Two)",
    31  		DockerVersion:      "1.8.1",
    32  		CadvisorVersion:    "0.16.0",
    33  		CadvisorRevision:   "abcdef",
    34  	}, nil
    35  }
    36  
    37  func (p testSubcontainersInfoProvider) GetMachineInfo() (*info.MachineInfo, error) {
    38  	return &info.MachineInfo{
    39  		Timestamp:        time.Unix(1395066363, 0),
    40  		NumCores:         4,
    41  		NumPhysicalCores: 1,
    42  		NumSockets:       1,
    43  		MemoryCapacity:   1024,
    44  		MemoryByType: map[string]*info.MemoryInfo{
    45  			"Non-volatile-RAM": {Capacity: 2168421613568, DimmCount: 8},
    46  			"Unbuffered-DDR4":  {Capacity: 412316860416, DimmCount: 12},
    47  		},
    48  		NVMInfo: info.NVMInfo{
    49  			MemoryModeCapacity:    429496729600,
    50  			AppDirectModeCapacity: 1735166787584,
    51  		},
    52  		MachineID:  "machine-id-test",
    53  		SystemUUID: "system-uuid-test",
    54  		BootID:     "boot-id-test",
    55  		Topology: []info.Node{
    56  			{
    57  				Id:     0,
    58  				Memory: 33604804608,
    59  				HugePages: []info.HugePagesInfo{
    60  					{
    61  						PageSize: uint64(1048576),
    62  						NumPages: uint64(0),
    63  					},
    64  					{
    65  						PageSize: uint64(2048),
    66  						NumPages: uint64(0),
    67  					},
    68  				},
    69  				Cores: []info.Core{
    70  					{
    71  						Id:      0,
    72  						Threads: []int{0, 1},
    73  						Caches: []info.Cache{
    74  							{
    75  								Size:  32768,
    76  								Type:  "Data",
    77  								Level: 1,
    78  							},
    79  							{
    80  								Size:  32768,
    81  								Type:  "Instruction",
    82  								Level: 1,
    83  							},
    84  							{
    85  								Size:  262144,
    86  								Type:  "Unified",
    87  								Level: 2,
    88  							},
    89  						},
    90  					},
    91  					{
    92  						Id:      1,
    93  						Threads: []int{2, 3},
    94  						Caches: []info.Cache{
    95  							{
    96  								Size:  32764,
    97  								Type:  "Data",
    98  								Level: 1,
    99  							},
   100  							{
   101  								Size:  32764,
   102  								Type:  "Instruction",
   103  								Level: 1,
   104  							},
   105  							{
   106  								Size:  262148,
   107  								Type:  "Unified",
   108  								Level: 2,
   109  							},
   110  						},
   111  					},
   112  
   113  					{
   114  						Id:      2,
   115  						Threads: []int{4, 5},
   116  						Caches: []info.Cache{
   117  							{
   118  								Size:  32768,
   119  								Type:  "Data",
   120  								Level: 1,
   121  							},
   122  							{
   123  								Size:  32768,
   124  								Type:  "Instruction",
   125  								Level: 1,
   126  							},
   127  							{
   128  								Size:  262144,
   129  								Type:  "Unified",
   130  								Level: 2,
   131  							},
   132  						},
   133  					},
   134  					{
   135  						Id:      3,
   136  						Threads: []int{6, 7},
   137  						Caches: []info.Cache{
   138  							{
   139  								Size:  32764,
   140  								Type:  "Data",
   141  								Level: 1,
   142  							},
   143  							{
   144  								Size:  32764,
   145  								Type:  "Instruction",
   146  								Level: 1,
   147  							},
   148  							{
   149  								Size:  262148,
   150  								Type:  "Unified",
   151  								Level: 2,
   152  							},
   153  						},
   154  					},
   155  				},
   156  				Distances: []uint64{
   157  					10,
   158  					12,
   159  				},
   160  			},
   161  			{
   162  				Id:     1,
   163  				Memory: 33604804606,
   164  				HugePages: []info.HugePagesInfo{
   165  					{
   166  						PageSize: uint64(1048576),
   167  						NumPages: uint64(2),
   168  					},
   169  					{
   170  						PageSize: uint64(2048),
   171  						NumPages: uint64(4),
   172  					},
   173  				},
   174  				Cores: []info.Core{
   175  					{
   176  						Id:      4,
   177  						Threads: []int{8, 9},
   178  						Caches: []info.Cache{
   179  							{
   180  								Size:  32768,
   181  								Type:  "Data",
   182  								Level: 1,
   183  							},
   184  							{
   185  								Size:  32768,
   186  								Type:  "Instruction",
   187  								Level: 1,
   188  							},
   189  							{
   190  								Size:  262144,
   191  								Type:  "Unified",
   192  								Level: 2,
   193  							},
   194  						},
   195  					},
   196  					{
   197  						Id:      5,
   198  						Threads: []int{10, 11},
   199  						Caches: []info.Cache{
   200  							{
   201  								Size:  32764,
   202  								Type:  "Data",
   203  								Level: 1,
   204  							},
   205  							{
   206  								Size:  32764,
   207  								Type:  "Instruction",
   208  								Level: 1,
   209  							},
   210  							{
   211  								Size:  262148,
   212  								Type:  "Unified",
   213  								Level: 2,
   214  							},
   215  						},
   216  					},
   217  					{
   218  						Id:      6,
   219  						Threads: []int{12, 13},
   220  						Caches: []info.Cache{
   221  							{
   222  								Size:  32768,
   223  								Type:  "Data",
   224  								Level: 1,
   225  							},
   226  							{
   227  								Size:  32768,
   228  								Type:  "Instruction",
   229  								Level: 1,
   230  							},
   231  							{
   232  								Size:  262144,
   233  								Type:  "Unified",
   234  								Level: 2,
   235  							},
   236  						},
   237  					},
   238  					{
   239  						Id:      7,
   240  						Threads: []int{14, 15},
   241  						Caches: []info.Cache{
   242  							{
   243  								Size:  32764,
   244  								Type:  "Data",
   245  								Level: 1,
   246  							},
   247  							{
   248  								Size:  32764,
   249  								Type:  "Instruction",
   250  								Level: 1,
   251  							},
   252  							{
   253  								Size:  262148,
   254  								Type:  "Unified",
   255  								Level: 2,
   256  							},
   257  						},
   258  					},
   259  				},
   260  				Caches: []info.Cache{
   261  					{
   262  						Size:  8388608,
   263  						Type:  "Unified",
   264  						Level: 3,
   265  					},
   266  				},
   267  				Distances: []uint64{
   268  					12,
   269  					10,
   270  				},
   271  			},
   272  		},
   273  	}, nil
   274  }
   275  
   276  func (p testSubcontainersInfoProvider) GetRequestedContainersInfo(string, v2.RequestOptions) (map[string]*info.ContainerInfo, error) {
   277  	return map[string]*info.ContainerInfo{
   278  		"testcontainer": {
   279  			ContainerReference: info.ContainerReference{
   280  				Name:    "testcontainer",
   281  				Aliases: []string{"testcontaineralias"},
   282  			},
   283  			Spec: info.ContainerSpec{
   284  				Image:  "test",
   285  				HasCpu: true,
   286  				Cpu: info.CpuSpec{
   287  					Limit:  1000,
   288  					Period: 100000,
   289  					Quota:  10000,
   290  				},
   291  				Memory: info.MemorySpec{
   292  					Limit:       2048,
   293  					Reservation: 1024,
   294  					SwapLimit:   4096,
   295  				},
   296  				HasHugetlb:   true,
   297  				HasProcesses: true,
   298  				Processes: info.ProcessSpec{
   299  					Limit: 100,
   300  				},
   301  				CreationTime: time.Unix(1257894000, 0),
   302  				Labels: map[string]string{
   303  					"foo.label": "bar",
   304  				},
   305  				Envs: map[string]string{
   306  					"foo+env": "prod",
   307  				},
   308  			},
   309  			Stats: []*info.ContainerStats{
   310  				{
   311  					Timestamp: time.Unix(1395066363, 0),
   312  					Cpu: info.CpuStats{
   313  						Usage: info.CpuUsage{
   314  							Total:  1,
   315  							PerCpu: []uint64{2, 3, 4, 5},
   316  							User:   6,
   317  							System: 7,
   318  						},
   319  						CFS: info.CpuCFS{
   320  							Periods:          723,
   321  							ThrottledPeriods: 18,
   322  							ThrottledTime:    1724314000,
   323  						},
   324  						Schedstat: info.CpuSchedstat{
   325  							RunTime:      53643567,
   326  							RunqueueTime: 479424566378,
   327  							RunPeriods:   984285,
   328  						},
   329  						LoadAverage: 2,
   330  					},
   331  					Memory: info.MemoryStats{
   332  						Usage:      8,
   333  						MaxUsage:   8,
   334  						WorkingSet: 9,
   335  						ContainerData: info.MemoryStatsMemoryData{
   336  							Pgfault:    10,
   337  							Pgmajfault: 11,
   338  							NumaStats: info.MemoryNumaStats{
   339  								File:        map[uint8]uint64{0: 16649, 1: 10000},
   340  								Anon:        map[uint8]uint64{0: 10000, 1: 7109},
   341  								Unevictable: map[uint8]uint64{0: 8900, 1: 10000},
   342  							},
   343  						},
   344  						HierarchicalData: info.MemoryStatsMemoryData{
   345  							Pgfault:    12,
   346  							Pgmajfault: 13,
   347  							NumaStats: info.MemoryNumaStats{
   348  								File:        map[uint8]uint64{0: 36649, 1: 10000},
   349  								Anon:        map[uint8]uint64{0: 20000, 1: 7109},
   350  								Unevictable: map[uint8]uint64{0: 8900, 1: 20000},
   351  							},
   352  						},
   353  						Cache:       14,
   354  						RSS:         15,
   355  						MappedFile:  16,
   356  						KernelUsage: 17,
   357  						Swap:        8192,
   358  					},
   359  					Hugetlb: map[string]info.HugetlbStats{
   360  						"2Mi": {
   361  							Usage:    4,
   362  							MaxUsage: 10,
   363  							Failcnt:  1,
   364  						},
   365  						"1Gi": {
   366  							Usage:    0,
   367  							MaxUsage: 0,
   368  							Failcnt:  0,
   369  						},
   370  					},
   371  					Network: info.NetworkStats{
   372  						InterfaceStats: info.InterfaceStats{
   373  							Name:      "eth0",
   374  							RxBytes:   14,
   375  							RxPackets: 15,
   376  							RxErrors:  16,
   377  							RxDropped: 17,
   378  							TxBytes:   18,
   379  							TxPackets: 19,
   380  							TxErrors:  20,
   381  							TxDropped: 21,
   382  						},
   383  						Interfaces: []info.InterfaceStats{
   384  							{
   385  								Name:      "eth0",
   386  								RxBytes:   14,
   387  								RxPackets: 15,
   388  								RxErrors:  16,
   389  								RxDropped: 17,
   390  								TxBytes:   18,
   391  								TxPackets: 19,
   392  								TxErrors:  20,
   393  								TxDropped: 21,
   394  							},
   395  						},
   396  						Tcp: info.TcpStat{
   397  							Established: 13,
   398  							SynSent:     0,
   399  							SynRecv:     0,
   400  							FinWait1:    0,
   401  							FinWait2:    0,
   402  							TimeWait:    0,
   403  							Close:       0,
   404  							CloseWait:   0,
   405  							LastAck:     0,
   406  							Listen:      3,
   407  							Closing:     0,
   408  						},
   409  						Tcp6: info.TcpStat{
   410  							Established: 11,
   411  							SynSent:     0,
   412  							SynRecv:     0,
   413  							FinWait1:    0,
   414  							FinWait2:    0,
   415  							TimeWait:    0,
   416  							Close:       0,
   417  							CloseWait:   0,
   418  							LastAck:     0,
   419  							Listen:      3,
   420  							Closing:     0,
   421  						},
   422  						TcpAdvanced: info.TcpAdvancedStat{
   423  							TCPFullUndo:               2361,
   424  							TCPMD5NotFound:            0,
   425  							TCPDSACKRecv:              83680,
   426  							TCPSackShifted:            2,
   427  							TCPSackShiftFallback:      298,
   428  							PFMemallocDrop:            0,
   429  							EstabResets:               37,
   430  							InSegs:                    140370590,
   431  							TCPPureAcks:               24251339,
   432  							TCPDSACKOldSent:           15633,
   433  							IPReversePathFilter:       0,
   434  							TCPFastOpenPassiveFail:    0,
   435  							InCsumErrors:              0,
   436  							TCPRenoFailures:           43414,
   437  							TCPMemoryPressuresChrono:  0,
   438  							TCPDeferAcceptDrop:        0,
   439  							TW:                        10436427,
   440  							TCPSpuriousRTOs:           0,
   441  							TCPDSACKIgnoredNoUndo:     71885,
   442  							RtoMax:                    120000,
   443  							ActiveOpens:               11038621,
   444  							EmbryonicRsts:             0,
   445  							RcvPruned:                 0,
   446  							TCPLossProbeRecovery:      401,
   447  							TCPHPHits:                 56096478,
   448  							TCPPartialUndo:            3,
   449  							TCPAbortOnMemory:          0,
   450  							AttemptFails:              48997,
   451  							RetransSegs:               462961,
   452  							SyncookiesFailed:          0,
   453  							OfoPruned:                 0,
   454  							TCPAbortOnLinger:          0,
   455  							TCPAbortFailed:            0,
   456  							TCPRenoReorder:            839,
   457  							TCPRcvCollapsed:           0,
   458  							TCPDSACKIgnoredOld:        0,
   459  							TCPReqQFullDrop:           0,
   460  							OutOfWindowIcmps:          0,
   461  							TWKilled:                  0,
   462  							TCPLossProbes:             88648,
   463  							TCPRenoRecoveryFail:       394,
   464  							TCPFastOpenCookieReqd:     0,
   465  							TCPHPAcks:                 21490641,
   466  							TCPSACKReneging:           0,
   467  							TCPTSReorder:              3,
   468  							TCPSlowStartRetrans:       290832,
   469  							MaxConn:                   -1,
   470  							SyncookiesRecv:            0,
   471  							TCPSackFailures:           60,
   472  							DelayedACKLocked:          90,
   473  							TCPDSACKOfoSent:           1,
   474  							TCPSynRetrans:             988,
   475  							TCPDSACKOfoRecv:           10,
   476  							TCPSACKDiscard:            0,
   477  							TCPMD5Unexpected:          0,
   478  							TCPSackMerged:             6,
   479  							RtoMin:                    200,
   480  							CurrEstab:                 22,
   481  							TCPTimeWaitOverflow:       0,
   482  							ListenOverflows:           0,
   483  							DelayedACKs:               503975,
   484  							TCPLossUndo:               61374,
   485  							TCPOrigDataSent:           130698387,
   486  							TCPBacklogDrop:            0,
   487  							TCPReqQFullDoCookies:      0,
   488  							TCPFastOpenPassive:        0,
   489  							PAWSActive:                0,
   490  							OutRsts:                   91699,
   491  							TCPSackRecoveryFail:       2,
   492  							DelayedACKLost:            18843,
   493  							TCPAbortOnData:            8,
   494  							TCPMinTTLDrop:             0,
   495  							PruneCalled:               0,
   496  							TWRecycled:                0,
   497  							ListenDrops:               0,
   498  							TCPAbortOnTimeout:         0,
   499  							SyncookiesSent:            0,
   500  							TCPSACKReorder:            11,
   501  							TCPDSACKUndo:              33,
   502  							TCPMD5Failure:             0,
   503  							TCPLostRetransmit:         0,
   504  							TCPAbortOnClose:           7,
   505  							TCPFastOpenListenOverflow: 0,
   506  							OutSegs:                   211580512,
   507  							InErrs:                    31,
   508  							TCPTimeouts:               27422,
   509  							TCPLossFailures:           729,
   510  							TCPSackRecovery:           159,
   511  							RtoAlgorithm:              1,
   512  							PassiveOpens:              59,
   513  							LockDroppedIcmps:          0,
   514  							TCPRenoRecovery:           3519,
   515  							TCPFACKReorder:            0,
   516  							TCPFastRetrans:            11794,
   517  							TCPRetransFail:            0,
   518  							TCPMemoryPressures:        0,
   519  							TCPFastOpenActive:         0,
   520  							TCPFastOpenActiveFail:     0,
   521  							PAWSEstab:                 0,
   522  						},
   523  						Udp: info.UdpStat{
   524  							Listen:   0,
   525  							Dropped:  0,
   526  							RxQueued: 0,
   527  							TxQueued: 0,
   528  						},
   529  						Udp6: info.UdpStat{
   530  							Listen:   0,
   531  							Dropped:  0,
   532  							RxQueued: 0,
   533  							TxQueued: 0,
   534  						},
   535  					},
   536  					DiskIo: info.DiskIoStats{
   537  						IoServiceBytes: []info.PerDiskStats{{
   538  							Device: "/dev/sdb",
   539  							Major:  8,
   540  							Minor:  0,
   541  							Stats: map[string]uint64{
   542  								"Async":   1,
   543  								"Discard": 2,
   544  								"Read":    3,
   545  								"Sync":    4,
   546  								"Total":   5,
   547  								"Write":   6,
   548  							},
   549  						}},
   550  					},
   551  					Filesystem: []info.FsStats{
   552  						{
   553  							Device:          "sda1",
   554  							InodesFree:      524288,
   555  							Inodes:          2097152,
   556  							Limit:           22,
   557  							Usage:           23,
   558  							ReadsCompleted:  24,
   559  							ReadsMerged:     25,
   560  							SectorsRead:     26,
   561  							ReadTime:        27,
   562  							WritesCompleted: 28,
   563  							WritesMerged:    39,
   564  							SectorsWritten:  40,
   565  							WriteTime:       41,
   566  							IoInProgress:    42,
   567  							IoTime:          43,
   568  							WeightedIoTime:  44,
   569  						},
   570  						{
   571  							Device:          "sda2",
   572  							InodesFree:      262144,
   573  							Inodes:          2097152,
   574  							Limit:           37,
   575  							Usage:           38,
   576  							ReadsCompleted:  39,
   577  							ReadsMerged:     40,
   578  							SectorsRead:     41,
   579  							ReadTime:        42,
   580  							WritesCompleted: 43,
   581  							WritesMerged:    44,
   582  							SectorsWritten:  45,
   583  							WriteTime:       46,
   584  							IoInProgress:    47,
   585  							IoTime:          48,
   586  							WeightedIoTime:  49,
   587  						},
   588  					},
   589  					Accelerators: []info.AcceleratorStats{
   590  						{
   591  							Make:        "nvidia",
   592  							Model:       "tesla-p100",
   593  							ID:          "GPU-deadbeef-1234-5678-90ab-feedfacecafe",
   594  							MemoryTotal: 20304050607,
   595  							MemoryUsed:  2030405060,
   596  							DutyCycle:   12,
   597  						},
   598  						{
   599  							Make:        "nvidia",
   600  							Model:       "tesla-k80",
   601  							ID:          "GPU-deadbeef-0123-4567-89ab-feedfacecafe",
   602  							MemoryTotal: 10203040506,
   603  							MemoryUsed:  1020304050,
   604  							DutyCycle:   6,
   605  						},
   606  					},
   607  					Processes: info.ProcessStats{
   608  						ProcessCount:   1,
   609  						FdCount:        5,
   610  						SocketCount:    3,
   611  						ThreadsCurrent: 5,
   612  						ThreadsMax:     100,
   613  						Ulimits: []info.UlimitSpec{
   614  							{
   615  								Name:      "max_open_files",
   616  								SoftLimit: 16384,
   617  								HardLimit: 16384,
   618  							},
   619  						},
   620  					},
   621  					TaskStats: info.LoadStats{
   622  						NrSleeping:        50,
   623  						NrRunning:         51,
   624  						NrStopped:         52,
   625  						NrUninterruptible: 53,
   626  						NrIoWait:          54,
   627  					},
   628  					CustomMetrics: map[string][]info.MetricVal{
   629  						"container_custom_app_metric_1": {
   630  							{
   631  								FloatValue: float64(1.1),
   632  								Timestamp:  time.Now(),
   633  								Label:      "testlabel_1_1_1",
   634  								Labels:     map[string]string{"test_label": "1_1", "test_label_2": "2_1"},
   635  							},
   636  							{
   637  								FloatValue: float64(1.2),
   638  								Timestamp:  time.Now(),
   639  								Label:      "testlabel_1_1_2",
   640  								Labels:     map[string]string{"test_label": "1_2", "test_label_2": "2_2"},
   641  							},
   642  						},
   643  						"container_custom_app_metric_2": {
   644  							{
   645  								FloatValue: float64(2),
   646  								Timestamp:  time.Now(),
   647  								Label:      "testlabel2",
   648  								Labels:     map[string]string{"test_label": "test_value"},
   649  							},
   650  						},
   651  						"container_custom_app_metric_3": {
   652  							{
   653  								FloatValue: float64(3),
   654  								Timestamp:  time.Now(),
   655  								Label:      "testlabel3",
   656  								Labels:     map[string]string{"test_label": "test_value"},
   657  							},
   658  						},
   659  					},
   660  					PerfStats: []info.PerfStat{
   661  						{
   662  							PerfValue: info.PerfValue{
   663  								ScalingRatio: 1.0,
   664  								Value:        123,
   665  								Name:         "instructions",
   666  							},
   667  							Cpu: 0,
   668  						},
   669  						{
   670  							PerfValue: info.PerfValue{
   671  								ScalingRatio: 0.5,
   672  								Value:        456,
   673  								Name:         "instructions",
   674  							},
   675  							Cpu: 1,
   676  						},
   677  						{
   678  							PerfValue: info.PerfValue{
   679  								ScalingRatio: 0.66666666666,
   680  								Value:        321,
   681  								Name:         "instructions_retired",
   682  							},
   683  							Cpu: 0,
   684  						},
   685  						{
   686  							PerfValue: info.PerfValue{
   687  								ScalingRatio: 0.33333333333,
   688  								Value:        789,
   689  								Name:         "instructions_retired",
   690  							},
   691  							Cpu: 1,
   692  						},
   693  					},
   694  					PerfUncoreStats: []info.PerfUncoreStat{
   695  						{
   696  							PerfValue: info.PerfValue{
   697  								ScalingRatio: 1.0,
   698  								Value:        1231231512.0,
   699  								Name:         "cas_count_read",
   700  							},
   701  							Socket: 0,
   702  							PMU:    "uncore_imc_0",
   703  						},
   704  						{
   705  							PerfValue: info.PerfValue{
   706  								ScalingRatio: 1.0,
   707  								Value:        1111231331.0,
   708  								Name:         "cas_count_read",
   709  							},
   710  							Socket: 1,
   711  							PMU:    "uncore_imc_0",
   712  						},
   713  					},
   714  					ReferencedMemory: 1234,
   715  					Resctrl: info.ResctrlStats{
   716  						MemoryBandwidth: []info.MemoryBandwidthStats{
   717  							{
   718  								TotalBytes: 4512312,
   719  								LocalBytes: 2390393,
   720  							},
   721  							{
   722  								TotalBytes: 2173713,
   723  								LocalBytes: 1231233,
   724  							},
   725  						},
   726  						Cache: []info.CacheStats{
   727  							{
   728  								LLCOccupancy: 162626,
   729  							},
   730  							{
   731  								LLCOccupancy: 213777,
   732  							},
   733  						},
   734  					},
   735  					CpuSet: info.CPUSetStats{MemoryMigrate: 1},
   736  				},
   737  			},
   738  		},
   739  	}, nil
   740  }
   741  
   742  type erroringSubcontainersInfoProvider struct {
   743  	successfulProvider testSubcontainersInfoProvider
   744  	shouldFail         bool
   745  }
   746  
   747  func (p *erroringSubcontainersInfoProvider) GetVersionInfo() (*info.VersionInfo, error) {
   748  	if p.shouldFail {
   749  		return nil, errors.New("Oops 1")
   750  	}
   751  	return p.successfulProvider.GetVersionInfo()
   752  }
   753  
   754  func (p *erroringSubcontainersInfoProvider) GetMachineInfo() (*info.MachineInfo, error) {
   755  	if p.shouldFail {
   756  		return nil, errors.New("Oops 2")
   757  	}
   758  	return p.successfulProvider.GetMachineInfo()
   759  }
   760  
   761  func (p *erroringSubcontainersInfoProvider) GetRequestedContainersInfo(
   762  	a string, opt v2.RequestOptions) (map[string]*info.ContainerInfo, error) {
   763  	if p.shouldFail {
   764  		return map[string]*info.ContainerInfo{}, errors.New("Oops 3")
   765  	}
   766  	return p.successfulProvider.GetRequestedContainersInfo(a, opt)
   767  }