How to use getDescription method of org.testcontainers.dockerclient.DockerClientProviderStrategy class

Best Testcontainers-java code snippet using org.testcontainers.dockerclient.DockerClientProviderStrategy.getDescription

Source:DockerClientProviderStrategy.java Github

copy

Full Screen

...48 private static final AtomicBoolean FAIL_FAST_ALWAYS = new AtomicBoolean(false);49 /**50 * @return a short textual description of the strategy51 */52 public abstract String getDescription();53 protected boolean isApplicable() {54 return true;55 }56 protected boolean isPersistable() {57 return true;58 }59 /**60 * @return highest to lowest priority value61 */62 protected int getPriority() {63 return 0;64 }65 /**66 * @throws InvalidConfigurationException if this strategy fails67 */68 public abstract TransportConfig getTransportConfig() throws InvalidConfigurationException;69 /**70 * @return a usable, tested, Docker client configuration for the host system environment71 *72 * @deprecated use {@link #getDockerClient()}73 */74 @Deprecated75 public DockerClient getClient() {76 DockerClient dockerClient = getDockerClient();77 try {78 Unreliables.retryUntilSuccess(30, TimeUnit.SECONDS, () -> {79 return PING_RATE_LIMITER.getWhenReady(() -> {80 log.debug("Pinging docker daemon...");81 dockerClient.pingCmd().exec();82 log.debug("Pinged");83 return true;84 });85 });86 } catch (TimeoutException e) {87 IOUtils.closeQuietly(dockerClient);88 throw e;89 }90 return dockerClient;91 }92 /**93 * Determine the right DockerClientConfig to use for building clients by trial-and-error.94 *95 * @return a working DockerClientConfig, as determined by successful execution of a ping command96 */97 public static DockerClientProviderStrategy getFirstValidStrategy(List<DockerClientProviderStrategy> strategies) {98 if (FAIL_FAST_ALWAYS.get()) {99 throw new IllegalStateException("Previous attempts to find a Docker environment failed. Will not retry. Please see logs and check configuration");100 }101 List<String> configurationFailures = new ArrayList<>();102 List<DockerClientProviderStrategy> allStrategies = new ArrayList<>();103 // The environment has the highest priority104 allStrategies.add(new EnvironmentAndSystemPropertyClientProviderStrategy());105 // Next strategy to try out is the one configured using the Testcontainers configuration mechanism106 loadConfiguredStrategy().ifPresent(allStrategies::add);107 // Finally, add all other strategies ordered by their internal priority108 strategies109 .stream()110 .sorted(Comparator.comparing(DockerClientProviderStrategy::getPriority).reversed())111 .collect(Collectors.toCollection(() -> allStrategies));112 Predicate<DockerClientProviderStrategy> distinctStrategyClassPredicate = new Predicate<DockerClientProviderStrategy>() {113 final Set<Class<? extends DockerClientProviderStrategy>> classes = new HashSet<>();114 @Override115 public boolean test(DockerClientProviderStrategy dockerClientProviderStrategy) {116 return classes.add(dockerClientProviderStrategy.getClass());117 }118 };119 return allStrategies120 .stream()121 .filter(distinctStrategyClassPredicate)122 .filter(DockerClientProviderStrategy::isApplicable)123 .filter(strategy -> tryOutStrategy(configurationFailures, strategy))124 .findFirst()125 .orElseThrow(() -> {126 log.error("Could not find a valid Docker environment. Please check configuration. Attempted configurations were:");127 for (String failureMessage : configurationFailures) {128 log.error(" " + failureMessage);129 }130 log.error("As no valid configuration was found, execution cannot continue");131 FAIL_FAST_ALWAYS.set(true);132 return new IllegalStateException("Could not find a valid Docker environment. Please see logs and check configuration");133 });134 }135 private static boolean tryOutStrategy(List<String> configurationFailures, DockerClientProviderStrategy strategy) {136 try {137 log.debug("Trying out strategy: {}", strategy.getClass().getSimpleName());138 DockerClient dockerClient = strategy.getDockerClient();139 Info info;140 try {141 info = Unreliables.retryUntilSuccess(TestcontainersConfiguration.getInstance().getClientPingTimeout(), TimeUnit.SECONDS, () -> {142 return strategy.PING_RATE_LIMITER.getWhenReady(() -> {143 log.debug("Pinging docker daemon...");144 return dockerClient.infoCmd().exec();145 });146 });147 } catch (TimeoutException e) {148 IOUtils.closeQuietly(dockerClient);149 throw e;150 }151 log.info("Found Docker environment with {}", strategy.getDescription());152 log.debug(153 "Transport type: '{}', Docker host: '{}'",154 TestcontainersConfiguration.getInstance().getTransportType(),155 strategy.getTransportConfig().getDockerHost()156 );157 log.debug("Checking Docker OS type for {}", strategy.getDescription());158 String osType = info.getOsType();159 if (StringUtils.isBlank(osType)) {160 log.warn("Could not determine Docker OS type");161 } else if (!osType.equals("linux")) {162 log.warn("{} is currently not supported", osType);163 throw new InvalidConfigurationException(osType + " containers are currently not supported");164 }165 if (strategy.isPersistable()) {166 TestcontainersConfiguration.getInstance().updateUserConfig("docker.client.strategy", strategy.getClass().getName());167 }168 return true;169 } catch (Exception | ExceptionInInitializerError | NoClassDefFoundError e) {170 @Nullable String throwableMessage = e.getMessage();171 @SuppressWarnings("ThrowableResultOfMethodCallIgnored")...

Full Screen

Full Screen

getDescription

Using AI Code Generation

copy

Full Screen

1 public String getDescription() {2 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",3 envVars, systemProperties, dockerHost);4 }5 public String getDescription() {6 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",7 envVars, systemProperties, dockerHost);8 }9 public String getDescription() {10 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",11 envVars, systemProperties, dockerHost);12 }13 public String getDescription() {14 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",15 envVars, systemProperties, dockerHost);16 }17 public String getDescription() {18 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",19 envVars, systemProperties, dockerHost);20 }21 public String getDescription() {22 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",23 envVars, systemProperties, dockerHost);24 }25 public String getDescription() {26 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",27 envVars, systemProperties, dockerHost);28 }29 public String getDescription() {30 return String.format("Docker client configured with environment variables %s and system properties %s. Resolved dockerHost=%s",31 envVars, systemProperties, dockerHost);32 }

Full Screen

Full Screen

getDescription

Using AI Code Generation

copy

Full Screen

1 .getDefaultStrategy()2 .getDescription();3 .getDefaultStrategy()4 .getDockerClient();5 .getDefaultStrategy()6 .getApiVersion();7 .getDefaultStrategy()8 .getDockerHostIpAddress();9 .getDefaultStrategy()10 .getDockerHostIpAddress();11 .getDefaultStrategy()12 .getDockerHostIpAddress();13 .getDefaultStrategy()

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testcontainers-java automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful