66 "github.com/docker/docker/api/types/container"
77 "github.com/docker/go-connections/nat"
88 "github.com/smartcontractkit/chainlink-testing-framework/framework"
9+ "github.com/smartcontractkit/chainlink-testing-framework/framework/components/postgres"
910 tc "github.com/testcontainers/testcontainers-go"
1011 tcwait "github.com/testcontainers/testcontainers-go/wait"
1112 "os"
@@ -19,14 +20,14 @@ const (
1920)
2021
2122type Input struct {
22- Image string `toml:"image"`
23- GRPCPort string `toml:"grpc_port"`
24- WSRPCPort string `toml:"wsrpc_port"`
25- DBURL string `toml:"db_url "`
26- CSAEncryptionKey string `toml:"csa_encryption_key "`
27- DockerFilePath string `toml:"docker_file "`
28- DockerContext string `toml:"docker_ctx "`
29- Out * Output `toml:"out"`
23+ Image string `toml:"image"`
24+ GRPCPort string `toml:"grpc_port"`
25+ WSRPCPort string `toml:"wsrpc_port"`
26+ CSAEncryptionKey string `toml:"csa_encryption_key "`
27+ DockerFilePath string `toml:"docker_file "`
28+ DockerContext string `toml:"docker_ctx "`
29+ DBInput * postgres. Input `toml:"db "`
30+ Out * Output `toml:"out"`
3031}
3132
3233type Output struct {
@@ -49,6 +50,16 @@ func defaults(in *Input) {
4950 }
5051}
5152
53+ func defaultJDDB () * postgres.Input {
54+ return & postgres.Input {
55+ Image : "postgres:12" ,
56+ Port : 14000 ,
57+ Name : "jd-db" ,
58+ VolumeName : "jd" ,
59+ JDDatabase : true ,
60+ }
61+ }
62+
5263func NewJD (in * Input ) (* Output , error ) {
5364 if in .Out != nil && in .Out .UseCache {
5465 return in .Out , nil
@@ -59,6 +70,13 @@ func NewJD(in *Input) (*Output, error) {
5970 if jdImg != "" {
6071 in .Image = jdImg
6172 }
73+ if in .DBInput == nil {
74+ in .DBInput = defaultJDDB ()
75+ }
76+ pgOut , err := postgres .NewPostgreSQL (in .DBInput )
77+ if err != nil {
78+ return nil , err
79+ }
6280 containerName := framework .DefaultTCName ("jd" )
6381 bindPort := fmt .Sprintf ("%s/tcp" , in .GRPCPort )
6482 req := tc.ContainerRequest {
@@ -74,7 +92,7 @@ func NewJD(in *Input) (*Output, error) {
7492 h .PortBindings = framework .MapTheSamePort (bindPort )
7593 },
7694 Env : map [string ]string {
77- "DATABASE_URL" : in . DBURL ,
95+ "DATABASE_URL" : pgOut . JDDockerInternalURL ,
7896 "PORT" : in .GRPCPort ,
7997 "NODE_RPC_PORT" : in .WSRPCPort ,
8098 "CSA_KEY_ENCRYPTION_SECRET" : in .CSAEncryptionKey ,
0 commit comments