@@ -21,14 +21,27 @@ type ElasticSearch struct {
2121
2222func NewElasticSearch (ctx context.Context ) (* ElasticSearch , error ) {
2323 _ = os .Setenv ("TC_HOST" , "localhost" )
24+ //volumeConfig := map[string]string{
25+ // "host-path": "my_es_data",
26+ // "container-path": "/usr/share/elasticsearch/data",
27+ //}
2428 req := testcontainers.ContainerRequest {
2529 Image : getEnvString ("ES_CONTAINER_IMAGE" , "docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0" ),
26- //Image: getEnvString("ES_CONTAINER_IMAGE", "157529275398.dkr.ecr.ap-south-1.amazonaws.com/ci-libraries/docker.elastic.co/ elasticsearch/elasticsearch:6.4.2 "),
30+ //Image: getEnvString("ES_CONTAINER_IMAGE", "elasticsearch:7.0.0 "),
2731 Env : map [string ]string {
2832 "discovery.type" : "single-node" ,
2933 "network.host" : "0.0.0.0" ,
3034 "network.bind_host" : "0.0.0.0" ,
3135 },
36+ //Mounts: testcontainers.ContainerMounts{
37+ // {
38+ // Source: testcontainers.GenericVolumeMountSource{
39+ // Name: volumeConfig["host-path"],
40+ // },
41+ // Target: testcontainers.ContainerMountTarget(volumeConfig["container-path"]),
42+ // ReadOnly: false,
43+ // },
44+ //},
3245 ExposedPorts : []string {"9200/tcp" , "9300/tcp" },
3346 WaitingFor : wait .ForListeningPort ("9200" ).WithStartupTimeout (time .Minute * 3 ), // Default timeout is 1 minute
3447 //WaitingFor: wait.ForHTTP("/").WithPort("9200/tcp").WithStartupTimeout(time.Minute * 3),
@@ -46,16 +59,16 @@ func NewElasticSearch(ctx context.Context) (*ElasticSearch, error) {
4659 }
4760 host , _ := container .Host (ctx )
4861 port , _ := container .MappedPort (ctx , "9200" )
49- port2 , _ := container .MappedPort (ctx , "9300" )
50- endpoint , err := container .Endpoint (ctx , "" )
51- endpoint = fmt .Sprintf ("http://%s" , endpoint )
62+ // port2, _ := container.MappedPort(ctx, "9300")
63+ // endpoint, err := container.Endpoint(ctx, "")
64+ endpoint : = fmt .Sprintf ("http://%s:%s " , host , port . Port () )
5265
5366 if err != nil {
5467 return nil , err
5568 }
5669
5770 client , err := elasticsearch .NewClient (elasticsearch.Config {
58- Addresses : []string {endpoint , fmt .Sprintf ("http://%s:%s" , host , port2 .Port ())},
71+ Addresses : []string {endpoint }, // , fmt.Sprintf("http://%s:%s", host, port2.Port())},
5972 EnableRetryOnTimeout : true ,
6073 })
6174 if err != nil {
0 commit comments