github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/docker/vsock_test.go (about)

     1  // Copyright (c) 2018 Intel Corporation
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package docker
     6  
     7  import (
     8  	. "github.com/kata-containers/tests"
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("vsock test", func() {
    14  	var (
    15  		args     []string
    16  		name     string
    17  		stdout   string
    18  		stderr   string
    19  		exitCode int
    20  	)
    21  
    22  	BeforeEach(func() {
    23  		name = randomDockerName()
    24  	})
    25  
    26  	AfterEach(func() {
    27  		Expect(RemoveDockerContainer(name)).To(BeTrue())
    28  		Expect(ExistDockerContainer(name)).NotTo(BeTrue())
    29  	})
    30  
    31  	Context("when using vsock", func() {
    32  		It("should not create a kata-proxy process", func() {
    33  			if !KataConfig.Hypervisor[KataHypervisor].Vsock {
    34  				Skip("Use of vsock not enabled")
    35  			}
    36  			args = []string{"--name", name, "-d", Image, "top"}
    37  			_, _, exitCode = dockerRun(args...)
    38  			Expect(exitCode).To(Equal(0))
    39  
    40  			ctrID, _, exitCode := dockerInspect("--format", "{{.Id}}", name)
    41  			Expect(exitCode).To(Equal(0))
    42  
    43  			// Check no kata-proxy process is running
    44  			Expect(ProxyRunning(ctrID)).To(BeFalse())
    45  
    46  		})
    47  
    48  		It("should print the agent logs in the shim journal", func() {
    49  			if !KataConfig.Hypervisor[KataHypervisor].Vsock {
    50  				Skip("Use of vsock not enabled")
    51  			}
    52  			if !KataConfig.Shim[DefaultShim].Debug {
    53  				Skip("Shim debug is not enabled")
    54  			}
    55  			args = []string{"--name", name, Image, "sh"}
    56  			_, _, exitCode = dockerRun(args...)
    57  			Expect(exitCode).To(BeZero())
    58  
    59  			cmd := NewCommand("journalctl", "-e", "-q", "-b", "-n", "10",
    60  				"-t", DefaultShim+"-shim")
    61  			stdout, stderr, exitCode = cmd.Run()
    62  			Expect(exitCode).To(BeZero())
    63  			Expect(stderr).To(BeEmpty())
    64  			Expect(stdout).To(ContainSubstring("source=agent"))
    65  		})
    66  	})
    67  })