Example #1
0
func waitForStaticEvent(containerId string, urlRequest string, t *testing.T, fm framework.Framework, typeEvent info.EventType) {
	einfo, err := fm.Cadvisor().Client().EventStaticInfo(urlRequest)
	require.NoError(t, err)
	found := false
	for _, ev := range einfo {
		if ev.EventType == typeEvent {
			if strings.Contains(ev.ContainerName, containerId) {
				found = true
				break
			}
		}
	}
	require.True(t, found)
}
Example #2
0
// Waits up to 5s for a container with the specified alias to appear.
func waitForContainer(alias string, fm framework.Framework) {
	err := framework.RetryForDuration(func() error {
		ret, err := fm.Cadvisor().Client().DockerContainer(alias, &info.ContainerInfoRequest{
			NumStats: 1,
		})
		if err != nil {
			return err
		}
		if len(ret.Stats) != 1 {
			return fmt.Errorf("no stats returned for container %q", alias)
		}

		return nil
	}, 5*time.Second)
	require.NoError(fm.T(), err, "Timed out waiting for container %q to be available in cAdvisor: %v", alias, err)
}
Example #3
0
func getDockerMinorVersion(fm framework.Framework) int {
	val, err := strconv.Atoi(fm.Docker().Version()[1])
	assert.Nil(fm.T(), err)
	return val
}