Skip to content

Commit

Permalink
Merge pull request #15134 from SimonRichardson/bootstrap-dqlite-agent…
Browse files Browse the repository at this point in the history
…-tests

[JUJU-2627] Ensure that we boostrap dqlite in agent tests
  • Loading branch information
manadart committed Feb 1, 2023
2 parents 2551ffc + 974073e commit 88941dd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmd/jujud/agent/agenttest/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
package agenttest

import (
"context"
"fmt"

"github.com/juju/clock"
"github.com/juju/cmd/v3"
"github.com/juju/cmd/v3/cmdtesting"
"github.com/juju/loggo"
"github.com/juju/mgo/v3"
mgotesting "github.com/juju/mgo/v3/testing"
"github.com/juju/names/v4"
Expand All @@ -22,6 +24,7 @@ import (
cmdutil "github.com/juju/juju/cmd/jujud/util"
"github.com/juju/juju/controller"
"github.com/juju/juju/core/network"
"github.com/juju/juju/database"
"github.com/juju/juju/environs/filestorage"
"github.com/juju/juju/environs/simplestreams"
sstesting "github.com/juju/juju/environs/simplestreams/testing"
Expand All @@ -37,6 +40,10 @@ import (
"github.com/juju/juju/worker/peergrouper"
)

// TODO (stickupkid): Remove this once we have a better way of using a logger
// in tests.
var logger = loggo.GetLogger("juju.agenttest.agent")

type patchingSuite interface {
PatchValue(interface{}, interface{})
}
Expand Down Expand Up @@ -109,6 +116,11 @@ type AgentSuite struct {
testing.JujuConnSuite
}

func (s *AgentSuite) SetUpSuite(c *gc.C) {
s.JujuConnSuite.SetUpSuite(c)
s.PatchValue(&database.DefaultBindAddress, "127.0.0.1")
}

// PrimeAgent writes the configuration file and tools for an agent
// with the given entity name. It returns the agent's configuration and the
// current tools.
Expand Down Expand Up @@ -191,6 +203,10 @@ func (s *AgentSuite) PrimeStateAgentVersion(c *gc.C, tag names.Tag, password str

conf := s.WriteStateAgentConfig(c, tag, password, vers, model.ModelTag())
s.primeAPIHostPorts(c)

err = database.BootstrapDqlite(context.TODO(), database.NewOptionFactory(conf, logger), logger)
c.Assert(err, jc.ErrorIsNil)

return conf, agentTools
}

Expand Down

0 comments on commit 88941dd

Please sign in to comment.