mirror of https://github.com/docker/compose.git
Add compose logs test
Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
parent
1e7ce90561
commit
9be77beb73
|
@ -94,8 +94,8 @@ func podToContainerSummary(pod corev1.Pod) compose.ContainerSummary {
|
|||
}
|
||||
|
||||
// GetLogs retrieves pod logs
|
||||
func (c *KubeClient) GetLogs(ctx context.Context, projectName string, consumer compose.LogConsumer, follow bool) error {
|
||||
pods, err := c.client.CoreV1().Pods(c.namespace).List(ctx, metav1.ListOptions{
|
||||
func (kc *KubeClient) GetLogs(ctx context.Context, projectName string, consumer compose.LogConsumer, follow bool) error {
|
||||
pods, err := kc.client.CoreV1().Pods(kc.namespace).List(ctx, metav1.ListOptions{
|
||||
LabelSelector: fmt.Sprintf("%s=%s", compose.ProjectTag, projectName),
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -103,7 +103,7 @@ func (c *KubeClient) GetLogs(ctx context.Context, projectName string, consumer c
|
|||
}
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
for _, pod := range pods.Items {
|
||||
request := c.client.CoreV1().Pods(c.namespace).GetLogs(pod.Name, &corev1.PodLogOptions{Follow: follow})
|
||||
request := kc.client.CoreV1().Pods(kc.namespace).GetLogs(pod.Name, &corev1.PodLogOptions{Follow: follow})
|
||||
service := pod.Labels[compose.ServiceTag]
|
||||
w := utils.GetWriter(service, pod.Name, consumer)
|
||||
|
||||
|
|
|
@ -108,6 +108,11 @@ func TestComposeUp(t *testing.T) {
|
|||
c.WaitForCmdResult(icmd.Command("docker", "--context", "default", "exec", "e2e-control-plane", "curl", endpoint), StdoutContains(`"word":`), 3*time.Minute, 3*time.Second)
|
||||
})
|
||||
|
||||
t.Run("compose logs web", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "--project-name", projectName, "logs", "web")
|
||||
assert.Assert(t, strings.Contains(res.Stdout(), "Listening on port 80"), res.Stdout())
|
||||
})
|
||||
|
||||
t.Run("down", func(t *testing.T) {
|
||||
_ = c.RunDockerCmd("compose", "--project-name", projectName, "down")
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue