Question: I want to have automated tests for testing import commands from datasource A (oracle) to datasource B (postgres).
Both datasources should be created with testcontainers.

The basic setup is done but the problem is:

**testcontainers** *oracleContainer* starts before the entrypoint defined in the Dokerfile has a change to finish up and create the user needed for the tests.

After the container is running, some sql scripts are executed creating tables and filling them with data. Those scripts fail because the user mentioned in the script is not created yet.

**testcontainers** is not waiting for the complete setup.

---

I've setup the container like this:

```
        OracleContainer oracleContainer = new OracleContainer("webdizz/oracle-xe-11g-sa:latest")
            .withStartupTimeoutSeconds(10000)
            .withEnv("DATABASES", "xyz");

```

The database is definitely created, but after a rather long time (tested by running the test forever and checking the database with docker exec)

I tried to set a wait strategy for the container multiple ways, for example like this:

```
        oracleContainer.setWaitStrategy(new LogMessageWaitStrategy().withRegEx("*.Enjoy!*"));

```

but it didn't result in anything.

---

By checking the logs with:

```
Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(LOGGER);
    oracleContainer.followOutput(logConsumer);

```

I can see that testcontainers never waits for it to finish.

All I found online regarding this "bug" or "problem" is this BugReport on github:
<https://github.com/testcontainers/testcontainers-java/issues/1292>

and it seems like the user is even using the same container as me. However the solution mentioned in the issue didn't work for me.

Answer: 
Honestly there are a plenty of ways of accomplishing this task, I have provided to you very high-level solution:

```
myList = [{'2013-01': 0.4,
  '2013-02': 0.5,
'2016-05': 0.4,
  'id': 1},
{'2013-05': 0.1,
  '2013-02': 0.4,
'2017-05': 0.4,
  'id': 2},
{'2013-06': 0.1,
'2014-05': 0.4,
'2018-05': 0.4,
  'id': 3}

];

def formatmyList(arr, numberOfDifferentYears):
    if(not(isinstance(arr, list))):
        raise Exception("Not List.")

    __dict = dict.__new__(dict, ())
    for item in arr:
        name = None
        keys = item.keys()
        keys.sort() # make sure to sort 'cause of python's built-in problems
        for i in range(numberOfDifferentYears):
                try:
                        name = str(keys[i])
                        if(name!="id"):
                                __dict[tuple((str(keys[i]), item[keys[i]]))] = item[keys[keys.__len__()-1]]
                except IndexError:
                         pass
    return __dict

print(formatmyList(myList, 3)) # e.g. three different years

```
We can use list comprehension here:

```
{
    (k, subd['id']): v
    for subd in data
    for k, v in subd.items()
    if k != 'id'
}

```

this produces:

```
>>> {
...     (k, subd['id']): v
...     for subd in data
...     for k, v in subd.items()
...     if k != 'id'
... }
{('2013-01', 1): 0.4, ('2013-02', 1): 0.5, ('2013-01', 2): 0.1, ('2013-02', 2): 0.4}

```

Or we can use pandas here:

```
import pandas as pd

pd.DataFrame(data).set_index('id').stack().reset_index().set_index(['level_1', 'id'])[0].to_dict()

```

This gives us:

```
>>> pd.DataFrame(data).set_index('id').stack().reset_index().set_index(['level_1', 'id'])[0].to_dict()
{('2013-01', 1): 0.4, ('2013-02', 1): 0.5, ('2013-01', 2): 0.1, ('2013-02', 2): 0.4}

```