Commit ad6bf35c authored by abhi's avatar abhi

Test cases to verify container log stats

The commit contains test case modifications to test and verify changes for container log stats feature. Signed-off-by: 's avatarabhi <abhi@docker.com>
parent 6649d38c
...@@ -845,7 +845,8 @@ func (m *kubeGenericRuntimeManager) removeContainerLog(containerID string) error ...@@ -845,7 +845,8 @@ func (m *kubeGenericRuntimeManager) removeContainerLog(containerID string) error
return fmt.Errorf("failed to get container status %q: %v", containerID, err) return fmt.Errorf("failed to get container status %q: %v", containerID, err)
} }
labeledInfo := getContainerInfoFromLabels(status.Labels) labeledInfo := getContainerInfoFromLabels(status.Labels)
path := BuildContainerLogsDirectory(labeledInfo.PodUID, labeledInfo.ContainerName) annotatedInfo := getContainerInfoFromAnnotations(status.Annotations)
path := buildFullContainerLogsPath(labeledInfo.PodUID, labeledInfo.ContainerName, annotatedInfo.RestartCount)
if err := m.osInterface.Remove(path); err != nil && !os.IsNotExist(err) { if err := m.osInterface.Remove(path); err != nil && !os.IsNotExist(err) {
return fmt.Errorf("failed to remove container %q log %q: %v", containerID, path, err) return fmt.Errorf("failed to remove container %q log %q: %v", containerID, path, err)
} }
......
...@@ -61,7 +61,7 @@ func TestRemoveContainer(t *testing.T) { ...@@ -61,7 +61,7 @@ func TestRemoveContainer(t *testing.T) {
err = m.removeContainer(containerId) err = m.removeContainer(containerId)
assert.NoError(t, err) assert.NoError(t, err)
// Verify container log is removed // Verify container log is removed
expectedContainerLogPath := filepath.Join(podLogsRootDirectory, "12345678", "foo_0.log") expectedContainerLogPath := filepath.Join(podLogsRootDirectory, "12345678", "foo", "0.log")
expectedContainerLogSymlink := legacyLogSymlink(containerId, "foo", "bar", "new") expectedContainerLogSymlink := legacyLogSymlink(containerId, "foo", "bar", "new")
assert.Equal(t, fakeOS.Removes, []string{expectedContainerLogPath, expectedContainerLogSymlink}) assert.Equal(t, fakeOS.Removes, []string{expectedContainerLogPath, expectedContainerLogSymlink})
// Verify container is removed // Verify container is removed
......
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package stats
import (
"k8s.io/kubernetes/pkg/volume"
)
type fakeLogMetrics struct {
fakeStats map[string]*volume.Metrics
}
func NewFakeLogMetricsService(stats map[string]*volume.Metrics) LogMetricsService {
return &fakeLogMetrics{fakeStats: stats}
}
func (l *fakeLogMetrics) createLogMetricsProvider(path string) volume.MetricsProvider {
return NewFakeMetricsDu(path, l.fakeStats[path])
}
type fakeMetricsDu struct {
fakeStats *volume.Metrics
}
func NewFakeMetricsDu(path string, stats *volume.Metrics) volume.MetricsProvider {
return &fakeMetricsDu{fakeStats: stats}
}
func (f *fakeMetricsDu) GetMetrics() (*volume.Metrics, error) {
return f.fakeStats, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment