GithubHelp home page GithubHelp logo

Comments (7)

Luap99 avatar Luap99 commented on July 26, 2024

Is conn closed?
Looks like it blocks on read() and I would expect read to return once the connection is closed.

from conmon-rs.

Luap99 avatar Luap99 commented on July 26, 2024

On a second look not conn must be closed but rather cfg.Streams.Stdin since we read from there.

from conmon-rs.

saschagrunert avatar saschagrunert commented on July 26, 2024

@Luap99 yeah we also block on read in the tests, but I see that as not critical:

go func() {
line, err := stdoutBuf.ReadString('\n')
Expect(err).To(BeNil())
fmt.Println(line)
// Stdout test
line, err = stdoutBuf.ReadString('\n')
Expect(err).To(BeNil())
fmt.Println(line)
Expect(line).To(ContainSubstring("Hello world"))
}()
go func() {
line, err := stderrBuf.ReadString('\n')
Expect(err).To(BeNil())
fmt.Println(line)
Expect(line).To(ContainSubstring("Hello world"))
}()

Do you consider working on a fix for that?

from conmon-rs.

Luap99 avatar Luap99 commented on July 26, 2024

I assume cfg.Streams.Stdin is supposed to be closed by the caller, i.e. the test here?

Also the goroutines in the ginkgo tests need a defer GinkgoRecover() at the top in order to work properly, https://onsi.github.io/ginkgo/#mental-model-how-ginkgo-handles-failure

from conmon-rs.

Luap99 avatar Luap99 commented on July 26, 2024

I know next to nothing about the conmon-rs internal but the test is not working.

change the testAttach function to in order to actually make sure it is executed:

func testAttach(stdinWrite io.Writer, stdoutRead, stderrRead io.Reader) {
	wg := &sync.WaitGroup{}
	wg.Add(3)
	// Stdin
	stdoutBuf := bufio.NewReader(stdoutRead)
	stderrBuf := bufio.NewReader(stderrRead)
	go func() {
		defer GinkgoRecover()
		defer wg.Done()
		_, err := fmt.Fprintf(stdinWrite, "/busybox echo Hello world\r")
		Expect(err).To(BeNil())

		_, err = fmt.Fprintf(stdinWrite, "/busybox echo Hello world >&2\r\n")
		Expect(err).To(BeNil())
		fmt.Println("stdin done")
	}()

	go func() {
		defer GinkgoRecover()
		defer wg.Done()

		// Stdout test
		line, err := stdoutBuf.ReadString('\n')
		Expect(err).To(BeNil())
		fmt.Println(line)
		Expect(line).To(ContainSubstring("Hello world"))

		fmt.Println("stdout done")
	}()

	go func() {
		defer GinkgoRecover()
		defer wg.Done()
		line, err := stderrBuf.ReadString('\n')
		Expect(err).To(BeNil())
		fmt.Println(line)
		Expect(line).To(ContainSubstring("Hello world"))

		fmt.Println("stderr done")
	}()
	wg.Wait()
}

There seems to be at least two problems that I can see:

  1. the terminal test cannot work with both stdour/err since a terminal only uses one stream.
    It is failing with and just hangs.
2022-07-21T14:47:14.725434Z ERROR backend:create_container{container_id="7b5d1daad76b330d663e0cb73524170cff34f98a5a4c417ac4455126f5be6927" uuid="17e3bede-4368-4a3e-a2cf-a63e9d39d137"}:listen:read_loop: conmon::terminal: 210: Stdout read loop failure: write to attach endpoints: write to attach endpoint: Broken pipe (os error 32)
  1. The test without terminal read the input but never sends any output back and therefore also hangs

from conmon-rs.

saschagrunert avatar saschagrunert commented on July 26, 2024

@Luap99 thank you for the investigations here. I think we can split-up the tests to test the terminal / non terminal cases in a more separated fashion.

from conmon-rs.

saschagrunert avatar saschagrunert commented on July 26, 2024

I think the tests are still broken, even with #579. I have to dig more into that.

from conmon-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.