Code Monkey home page Code Monkey logo

Comments (7)

wwn0594 avatar wwn0594 commented on June 20, 2024 1

Since you give a fixed port there can't be multiple (mini)redises running at the same time, but go test runs separate packages in parallel by default. Try running go test with: go test -p=1 etc, so it'll only run a single test at the same time.

It works! Thanks a lot

from miniredis.

alicebob avatar alicebob commented on June 20, 2024

from miniredis.

alicebob avatar alicebob commented on June 20, 2024
/go/pkg/mod/github.com/alicebob/miniredis/[email protected]/server/server.go:122 +0x3c

That's https://github.com/alicebob/miniredis/blob/master/server/server.go#L122

s.mu.Lock()

I don't get the error locally, and looking at the code, might it be that you start a redis server in a Go routine, and it's not ready starting yet when you use it? Would it otherwise be possible to make a standalone test case?

from miniredis.

wwn0594 avatar wwn0594 commented on June 20, 2024

@alicebob Thanks for investigation! I didn't start redis on go routine, instead I put it on a init() func, and start on a fixed port.

		if addr != "" {
			return addr, "", 0, tls, nil
		}
		log.Info().Msg("No redis set on env, start mini redis.")

		mr := miniredis.NewMiniRedis()
		mr.StartAddr(":15678")

		addr = mr.Addr()
		return addr, "", 0, tls, nil

That's very strange, I met the panic only if set -coverpkg=./... on go test

from miniredis.

alicebob avatar alicebob commented on June 20, 2024

from miniredis.

alicebob avatar alicebob commented on June 20, 2024

Since you give a fixed port there can't be multiple (mini)redises running at the same time, but go test runs separate packages in parallel by default. Try running go test with: go test -p=1 etc, so it'll only run a single test at the same time.

from miniredis.

wwn0594 avatar wwn0594 commented on June 20, 2024

@alicebob aha, got the errMsg

panic: listen tcp :15678: bind: address already in use

It seems -coverpkg=./... makes the tests run concurrence between different package.

from miniredis.

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.