簡體   English   中英

TestContainers - 無法連接到 MySQLContainer Docker - 集成測試

[英]TestContainers - Can't connect to MySQLContainer Docker - Integration Test

I'm Trying to run my Integration Test using MySQLContainer in Docker, however when i run the tests, the application gets caught in a loop trying to establish a JDBC Connection, find bellow my integration Test class and the log of the Spring Boot Application.

集成測試 Class

package com.recargaslda.multiplatform.repositorios;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import java.time.LocalDate;

import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.testcontainers.containers.MySQLContainer;

import com.recargaslda.multiplatform.entidades.Album;

@SpringBootTest
@ContextConfiguration(initializers = { AlbumRepositorioTesteIntegracao.Initializer.class })
public class AlbumRepositorioTesteIntegracao {
    // Even When i change the image version to 5.5 it still fails to connect
    @Rule
    private static MySQLContainer sqlContainer = new MySQLContainer<>("mysql:8.0");

    static {
        sqlContainer.withDatabaseName("teste-integração-album-repositorio").withUsername("root").withPassword("root");
        sqlContainer.start();
    }

    static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {

        @Override
        public void initialize(ConfigurableApplicationContext applicationContext) {
            TestPropertyValues.of("spring.datasource.url=" + sqlContainer.getJdbcUrl(),
                    "spring.datasource.username=" + sqlContainer.getUsername(),
                    "spring.datasource.password=" + sqlContainer.getPassword()).applyTo(applicationContext);
        }

    }

    @Autowired
    AlbumRepositorio albumRepositorio;

    @Test
    public void DevePersistirUmNovoAlbumSemImagens() {
        Album album = new Album("album", LocalDate.now(), "Capa");

        albumRepositorio.save(album);

        Album albumEncontrado = albumRepositorio.findByNome("album");

        assertThat(album.getNome(), is(albumEncontrado.getNome()));

    }

}

循環期間的控制台日志:

13:48:00.676 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]: no resource found for suffixes {-context.xml, Context.groovy}.
13:48:00.678 [main] DEBUG org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Ignoring class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao$Initializer]; it must be static, non-private, non-final, and annotated with @Configuration to be considered a default configuration class.
13:48:00.678 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]: AlbumRepositorioTesteIntegracao does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
13:48:00.770 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]
13:48:00.990 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\Pete\Documents\Workspace\MultiPlatformAplicacao\target\classes\com\recargaslda\multiplatform\MultiPlatformApplication.class]
13:48:00.993 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.recargaslda.multiplatform.MultiPlatformApplication for test class com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao
13:48:01.216 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]: using defaults.
13:48:01.217 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener, org.springframework.security.test.context.support.ReactorContextTestExecutionListener]
13:48:01.269 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@2eae8e6e, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@8f2ef19, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@470734c3, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@2cf3d63b, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7674f035, org.springframework.test.context.transaction.TransactionalTestExecutionListener@69e153c5, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@173ed316, org.springframework.test.context.event.EventPublishingTestExecutionListener@25ce9dc4, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener@74ea2410, org.springframework.security.test.context.support.ReactorContextTestExecutionListener@17f62e33, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@76b1e9b8, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@27406a17, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@2af004b, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@248e319b, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@5d0bf09b]
13:48:01.737 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.NpipeSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
13:48:02.995 [ducttape-0] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Pinging docker daemon...
13:48:03.311 [ducttape-0] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: org.testcontainers.dockerclient.transport.okhttp.OkHttpDockerCmdExecFactory$1@298aadd0
13:48:03.418 [main] INFO org.testcontainers.dockerclient.NpipeSocketClientProviderStrategy - Accessing docker with local Npipe socket (npipe:////./pipe/docker_engine)
13:48:03.419 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with local Npipe socket (npipe:////./pipe/docker_engine)
13:48:03.419 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Checking Docker OS type for local Npipe socket (npipe:////./pipe/docker_engine)
13:48:03.421 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.exec.InfoCmdExec@1115ec15
13:48:03.715 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
13:48:03.717 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.exec.InfoCmdExec@6155d082
13:48:03.738 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.exec.VersionCmdExec@7803bfd
13:48:03.770 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker: 
  Server Version: 19.03.8
  API Version: 1.40
  Operating System: Docker Desktop
  Total Memory: 1989 MB
13:48:03.770 [main] DEBUG org.testcontainers.DockerClientFactory - Ryuk is enabled
13:48:03.776 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ListImagesCmdImpl[imageNameFilter=quay.io/testcontainers/ryuk:0.2.3,showAll=false,filters=com.github.dockerjava.core.util.FiltersBuilder@0,execution=com.github.dockerjava.core.exec.ListImagesCmdExec@4f25b795]
13:48:03.851 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: quay.io/testcontainers/ryuk:0.2.3
13:48:03.851 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: C:\Users\Pete\.docker\config.json (exists) and commandPathPrefix: 
13:48:03.860 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [quay.io] for dockerImageName [quay.io/testcontainers/ryuk:0.2.3]
13:48:03.861 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Executing docker credential provider: docker-credential-desktop to locate auth config for: quay.io
13:48:03.878 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Executing [docker-credential-desktop, get].
13:48:03.885 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Started java.lang.ProcessImpl@3212a8d7
13:48:04.044 [WaitForProcess-java.lang.ProcessImpl@3212a8d7] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.WaitForProcess - java.lang.ProcessImpl@3212a8d7 stopped with exit code 1
13:48:04.048 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Executing [docker-credential-desktop, get].
13:48:04.053 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Started java.lang.ProcessImpl@71454b9d
13:48:04.188 [WaitForProcess-java.lang.ProcessImpl@71454b9d] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.WaitForProcess - java.lang.ProcessImpl@71454b9d stopped with exit code 1
13:48:04.190 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Got credentials not found error message from docker credential helper - credentials not found in native keychain
13:48:04.192 [main] INFO org.testcontainers.utility.RegistryAuthLocator - Credential helper/store (docker-credential-desktop) does not have credentials for quay.io
13:48:04.195 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - no matching Auth Configs - falling back to defaultAuthConfig [null]
13:48:04.195 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - Effective auth config [null]
13:48:04.239 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CreateContainerCmdImpl@584f54e6[name=testcontainers-ryuk-c9db393d-d0ec-4740-848a-134abfe549c5,hostName=<null>,domainName=<null>,user=<null>,attachStdin=<null>,attachStdout=<null>,attachStderr=<null>,portSpecs=<null>,tty=<null>,stdinOpen=<null>,stdInOnce=<null>,env=<null>,cmd=<null>,healthcheck=<null>,argsEscaped=<null>,entrypoint=<null>,image=quay.io/testcontainers/ryuk:0.2.3,volumes=com.github.dockerjava.api.model.Volumes@23aa363a,workingDir=<null>,macAddress=<null>,onBuild=<null>,networkDisabled=<null>,exposedPorts=com.github.dockerjava.api.model.ExposedPorts@5ef6ae06,stopSignal=<null>,stopTimeout=<null>,hostConfig=com.github.dockerjava.api.model.HostConfig@55dfebeb[binds=com.github.dockerjava.api.model.Binds@604f2bd2,blkioWeight=<null>,blkioWeightDevice=<null>,blkioDeviceReadBps=<null>,blkioDeviceWriteBps=<null>,blkioDeviceReadIOps=<null>,blkioDeviceWriteIOps=<null>,memorySwappiness=<null>,nanoCPUs=<null>,capAdd=<null>,capDrop=<null>,containerIDFile=<null>,cpuPeriod=<null>,cpuRealtimePeriod=<null>,cpuRealtimeRuntime=<null>,cpuShares=<null>,cpuQuota=<null>,cpusetCpus=<null>,cpusetMems=<null>,devices=<null>,deviceCgroupRules=<null>,diskQuota=<null>,dns=<null>,dnsOptions=<null>,dnsSearch=<null>,extraHosts=<null>,groupAdd=<null>,ipcMode=<null>,cgroup=<null>,links=<null>,logConfig=<null>,lxcConf=<null>,memory=<null>,memorySwap=<null>,memoryReservation=<null>,kernelMemory=<null>,networkMode=<null>,oomKillDisable=<null>,init=<null>,autoRemove=true,oomScoreAdj=<null>,portBindings=<null>,privileged=false,publishAllPorts=true,readonlyRootfs=<null>,restartPolicy=<null>,ulimits=<null>,cpuCount=<null>,cpuPercent=<null>,ioMaximumIOps=<null>,ioMaximumBandwidth=<null>,volumesFrom=<null>,mounts=<null>,pidMode=<null>,isolation=<null>,securityOpts=<null>,storageOpt=<null>,cgroupParent=<null>,volumeDriver=<null>,shmSize=<null>,pidsLimit=<null>,runtime=<null>,tmpFs=<null>,utSMode=<null>,usernsMode=<null>,sysctls=<null>,consoleSize=<null>],labels={org.testcontainers=true},shell=<null>,networkingConfig=<null>,ipv4Address=<null>,ipv6Address=<null>,aliases=<null>,authConfig=<null>,execution=com.github.dockerjava.core.exec.CreateContainerCmdExec@1d3ac898]
13:48:05.184 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: 63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0,com.github.dockerjava.core.exec.StartContainerCmdExec@56e8b606
13:48:06.714 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: 63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@366c4480
13:48:06.718 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0/json], queryParams={})
13:48:06.892 [testcontainers-ryuk] DEBUG org.testcontainers.utility.ResourceReaper - Sending 'label=org.testcontainers%3Dtrue&label=org.testcontainers.sessionId%3Dc9db393d-d0ec-4740-848a-134abfe549c5' to Ryuk
13:48:06.895 [testcontainers-ryuk] DEBUG org.testcontainers.utility.ResourceReaper - Received 'ACK' from Ryuk
13:48:06.895 [main] INFO org.testcontainers.DockerClientFactory - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
13:48:06.895 [main] DEBUG org.testcontainers.DockerClientFactory - Checks are enabled
13:48:06.895 [main] INFO org.testcontainers.DockerClientFactory - Checking the system...
13:48:06.896 [main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
13:48:06.899 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: 63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0,<null>,true,<null>,<null>,<null>,<null>,{df,-P},<null>,<null>,com.github.dockerjava.core.exec.ExecCreateCmdExec@2a79d4b1
13:48:07.015 [tc-okhttp-stream-1130346421] DEBUG com.github.dockerjava.core.command.ExecStartResultCallback - STDOUT: Filesystem           1024-blocks    Used Available Capacity Mounted on
overlay               61255652   3271272  54843048   6% /
tmpfs                    65536         0     65536   0% /dev
tmpfs                  1018508         0   1018508   0% /sys/fs/cgroup
shm                      65536         0     65536   0% /dev/shm
/dev/sda1             61255652   3271272  54843048   6% /etc/resolv.conf
/dev/sda1             61255652   3271272  54843048   6% /etc/hostname
/dev/sda1             61255652   3271272  54843048   6% /etc/hosts
overlay                1018508       400   1018108   0% /run/docker.sock
tmpfs                  1018508         0   1018508   0% /proc/acpi
tmpfs                    65536         0     65536   0% /proc/kcore
tmpfs                    65536         0     65536   0% /proc/keys
tmpfs                    65536         0     65536   0% /proc/timer_list
tmpfs                    65536         0     65536   0% /proc/sched_debug
tmpfs                  1018508         0   1018508   0% /sys/firmware
13:48:07.045 [main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker environment should have more than 2GB free disk space
13:48:07.046 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ListImagesCmdImpl[imageNameFilter=<null>,showAll=false,filters=com.github.dockerjava.core.util.FiltersBuilder@0,execution=com.github.dockerjava.core.exec.ListImagesCmdExec@56c698e3]
13:48:07.091 [main] DEBUG org.testcontainers.images.AbstractImagePullPolicy - Using locally available and not pulling image: mysql:8.0
13:48:07.091 [main] DEBUG 🐳 [mysql:8.0] - Starting container: mysql:8.0
13:48:07.092 [main] DEBUG 🐳 [mysql:8.0] - Trying to start container: mysql:8.0
13:48:07.092 [main] DEBUG 🐳 [mysql:8.0] - Trying to start container: mysql:8.0 (attempt 1/3)
13:48:07.092 [main] DEBUG 🐳 [mysql:8.0] - Starting container: mysql:8.0
13:48:07.092 [main] INFO 🐳 [mysql:8.0] - Creating container for image: mysql:8.0
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: mysql:8.0
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: C:\Users\Pete\.docker\config.json (exists) and commandPathPrefix: 
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [index.docker.io] for dockerImageName [mysql:8.0]
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Executing docker credential provider: docker-credential-desktop to locate auth config for: index.docker.io
13:48:07.093 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Executing [docker-credential-desktop, get].
13:48:07.097 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Started java.lang.ProcessImpl@5c8504fd
13:48:07.224 [WaitForProcess-java.lang.ProcessImpl@5c8504fd] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.WaitForProcess - java.lang.ProcessImpl@5c8504fd stopped with exit code 0
13:48:07.225 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Credential helper/store provided auth config for: index.docker.io
13:48:07.232 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - found creds store auth config [AuthConfig{username=petechiboleca, password=hidden non-blank value, auth=blank, email=null, registryAddress=index.docker.io, registryToken=blank}]
13:48:07.232 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - Effective auth config [AuthConfig{username=petechiboleca, password=hidden non-blank value, auth=blank, email=null, registryAddress=index.docker.io, registryToken=blank}]
13:48:07.243 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CreateContainerCmdImpl@5c153b9e[name=<null>,hostName=<null>,domainName=<null>,user=<null>,attachStdin=<null>,attachStdout=<null>,attachStderr=<null>,portSpecs=<null>,tty=<null>,stdinOpen=<null>,stdInOnce=<null>,env={MYSQL_DATABASE=teste-integração-album-repositorio,MYSQL_PASSWORD=root,MYSQL_USER=root,MYSQL_ROOT_PASSWORD=root},cmd={},healthcheck=<null>,argsEscaped=<null>,entrypoint=<null>,image=mysql:8.0,volumes=com.github.dockerjava.api.model.Volumes@2a7686a7,workingDir=<null>,macAddress=<null>,onBuild=<null>,networkDisabled=<null>,exposedPorts=com.github.dockerjava.api.model.ExposedPorts@758a34ce,stopSignal=<null>,stopTimeout=<null>,hostConfig=com.github.dockerjava.api.model.HostConfig@7ec3394b[binds=com.github.dockerjava.api.model.Binds@bff34c6,blkioWeight=<null>,blkioWeightDevice=<null>,blkioDeviceReadBps=<null>,blkioDeviceWriteBps=<null>,blkioDeviceReadIOps=<null>,blkioDeviceWriteIOps=<null>,memorySwappiness=<null>,nanoCPUs=<null>,capAdd=<null>,capDrop=<null>,containerIDFile=<null>,cpuPeriod=<null>,cpuRealtimePeriod=<null>,cpuRealtimeRuntime=<null>,cpuShares=<null>,cpuQuota=<null>,cpusetCpus=<null>,cpusetMems=<null>,devices=<null>,deviceCgroupRules=<null>,diskQuota=<null>,dns=<null>,dnsOptions=<null>,dnsSearch=<null>,extraHosts={},groupAdd=<null>,ipcMode=<null>,cgroup=<null>,links=com.github.dockerjava.api.model.Links@1522d8a0,logConfig=<null>,lxcConf=<null>,memory=<null>,memorySwap=<null>,memoryReservation=<null>,kernelMemory=<null>,networkMode=<null>,oomKillDisable=<null>,init=<null>,autoRemove=<null>,oomScoreAdj=<null>,portBindings={},privileged=<null>,publishAllPorts=true,readonlyRootfs=<null>,restartPolicy=<null>,ulimits=<null>,cpuCount=<null>,cpuPercent=<null>,ioMaximumIOps=<null>,ioMaximumBandwidth=<null>,volumesFrom={},mounts=<null>,pidMode=<null>,isolation=<null>,securityOpts=<null>,storageOpt=<null>,cgroupParent=<null>,volumeDriver=<null>,shmSize=<null>,pidsLimit=<null>,runtime=<null>,tmpFs=<null>,utSMode=<null>,usernsMode=<null>,sysctls=<null>,consoleSize=<null>],labels={org.testcontainers=true, org.testcontainers.sessionId=c9db393d-d0ec-4740-848a-134abfe549c5},shell=<null>,networkingConfig=<null>,ipv4Address=<null>,ipv6Address=<null>,aliases=<null>,authConfig=AuthConfig[username=petechiboleca,password=tWindrifter12345,email=<null>,registryAddress=index.docker.io,auth=<null>,registrytoken=<null>,identitytoken=<null>,stackOrchestrator=<null>],execution=com.github.dockerjava.core.exec.CreateContainerCmdExec@5644dc81]
13:48:08.194 [main] DEBUG org.testcontainers.utility.MountableFile - Copying classpath resource(s) from jar:file:/C:/Users/Pete/.m2/repository/org/testcontainers/mysql/1.13.0/mysql-1.13.0.jar!/mysql-default-conf to C:\Users\Pete\AppData\Local\Temp\.testcontainers-tmp-5095191207689237918 to permit Docker to bind
13:48:08.194 [main] DEBUG org.testcontainers.utility.MountableFile - Copying resource mysql-default-conf from JAR file C:\Users\Pete\.m2\repository\org\testcontainers\mysql\1.13.0\mysql-1.13.0.jar
13:48:08.194 [main] DEBUG org.testcontainers.utility.MountableFile - Copying classpath resource(s) from jar:file:/C:/Users/Pete/.m2/repository/org/testcontainers/mysql/1.13.0/mysql-1.13.0.jar!/mysql-default-conf to C:\Users\Pete\AppData\Local\Temp\.testcontainers-tmp-5095191207689237918 to permit Docker to bind
13:48:08.195 [main] DEBUG org.testcontainers.utility.MountableFile - Copying resource mysql-default-conf from JAR file C:\Users\Pete\.m2\repository\org\testcontainers\mysql\1.13.0\mysql-1.13.0.jar
13:48:08.202 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@57fd91c9
13:48:08.203 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:08.234 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CopyArchiveToContainerCmdImpl@25e2a451[cp ,<null>, ,ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,:,/]
13:48:08.379 [main] INFO 🐳 [mysql:8.0] - Starting container with ID: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d
13:48:08.379 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,com.github.dockerjava.core.exec.StartContainerCmdExec@63b1d4fa
13:48:09.716 [main] INFO 🐳 [mysql:8.0] - Container mysql:8.0 is starting: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d
13:48:09.718 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@75459c75
13:48:09.718 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.735 [ducttape-0] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@410298f0
13:48:09.737 [ducttape-0] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.753 [main] INFO 🐳 [mysql:8.0] - Waiting for database connection to become available at jdbc:mysql://localhost:32851/teste-integração-album-repositorio using query 'SELECT 1'
13:48:09.753 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@2a3c96e3
13:48:09.753 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.792 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@a8e6492
13:48:09.792 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.799 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}
13:48:10.233 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@1e5f4170
13:48:10.233 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:10.240 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}
13:48:09.799 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}
13:48:10.233 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec@1e5f4170
13:48:10.233 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient@2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:10.240 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}

MySQL 容器 Docker 依賴和 MySQL 連接器 8.0 依賴(Spring Boot 正在管理我的連接器)

<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
version>1.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>

注意:當我使用 PostgreSQLContainer 時,測試成功通過

注 2:當循環中斷時,它會顯示 *Communications link failure

您不能在 mysql 中創建名為“root”的用戶,因為它已經存在。 刪除這部分,看看它是否有幫助:

.withUsername("root")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM