dobi
dobi copied to clipboard
running tests on CircleCI
Somewhy I cannot access another container from the dobi process at CircleCI. I think it might have something to do with how the bind-mount flag works. Any thoughts?
Simple test
tests:
docker:
- image: onnidev/circle
steps:
- checkout
- setup_remote_docker
- run: |
gopath.sh /go/src/github.com/onnidev/api
docker login -u $DOCKER_USER --password $DOCKER_PASS
docker run -d -p 27017 mongo:3.2
docker ps
dobi --no-bind-mount test || true
=== RUN TestSpecReturn
TRACE 2018/02/21 15:39:11 [VIPER] DB db: onni
TRACE 2018/02/21 15:39:11 [VIPER] JWTSECRET jwtsecret: IlIC91CpujjOf29rhXww39OKO...
TRACE 2018/02/21 15:39:11 [VIPER] MONGOHOST mongohost: localhost
TRACE 2018/02/21 15:39:11 [VIPER] MONGOPASS mongopass:
TRACE 2018/02/21 15:39:11 [VIPER] MONGOPORT mongoport: 27017
TRACE 2018/02/21 15:39:11 [VIPER] MONGOUSER mongouser:
TRACE 2018/02/21 15:39:11 [VIPER] PORT port: 7000
TRACE 2018/02/21 15:39:11 [VIPER] SENDINBLUE sendinblue: sh1RqU...
TRACE 2018/02/21 15:39:11 [VIPER] TESTING testing: false
TRACE 2018/02/21 15:39:11 [VIPER] VALIDATION validation: false
TRACE 2018/02/21 15:39:11 [VIPER] VERBOSE verbose: true
TRACE 2018/02/21 15:39:11 [VIPER] X-AUTH-APPLICATION-TOKEN x-auth-application-token: mYX5a43As?V
TRACE 2018/02/21 15:39:14 [MONGO] Failed on attempt [1]
TRACE 2018/02/21 15:39:18 [MONGO] Failed on attempt [2]
TRACE 2018/02/21 15:39:21 [MONGO] Failed on attempt [3]
TRACE 2018/02/21 15:39:25 [MONGO] Failed on attempt [4]
TRACE 2018/02/21 15:39:29 [MONGO] Failed on attempt [5]
TRACE 2018/02/21 15:39:29 [MONGO] error: [no reachable servers]
func Mongo(db string) {
mongoGLOBAL = MongoStore{
Database: db,
AuthDatabase: "admin",
User: viper.GetString("MONGOUSER"),
Password: viper.GetString("MONGOPASS"),
Host: viper.GetString("MONGOHOST"),
Port: viper.GetInt("MONGOPORT"),
Logger: NewLogger("MONGO")}
mongoGLOBAL.retry()
}
func (store MongoStore) retry() {
tryFunc := func(attempt int) (bool, error) {
var err error
mongoGLOBAL.Session, err = store.connect()
if err != nil {
mongoGLOBAL.Logger.Printf(" Failed on attempt %d\n", attempt)
return attempt < 5, err // try 5 times
}
mongoGLOBAL.Session.SetMode(mgo.Monotonic, true)
mongoGLOBAL.Logger.Printf(" Connected on attempt %d\n", attempt)
return true, nil // try 5 times
}
err := try.Do(tryFunc)
if err != nil {
mongoGLOBAL.Logger.Printf("error: %s", err)
}
}
func (store MongoStore) connect() (*mgo.Session, error) {
inf := &mgo.DialInfo{
Addrs: []string{store.Host + ":" + strconv.Itoa(store.Port)},
Database: store.AuthDatabase,
Username: store.User,
Password: store.Password,
Timeout: 2 * time.Second}
session, err := mgo.DialWithInfo(inf)
if err != nil {
return session, err
}
if err = session.Ping(); err != nil {
return session, err
}
return session, nil
}
I think you need -p 27017:27017 otherwise it will pick a random port on the host.
i thought -p 27017 was the short for -p 27017:27017.
but that does not solve the issue