Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import io.trino.tests.product.launcher.env.common.KafkaSsl;
import io.trino.tests.product.launcher.env.common.Kerberos;
import io.trino.tests.product.launcher.env.common.Minio;
import io.trino.tests.product.launcher.env.common.OpenLdap;
import io.trino.tests.product.launcher.env.common.OpenLdapReferral;
import io.trino.tests.product.launcher.env.common.Standard;
import io.trino.tests.product.launcher.env.common.StandardMultinode;
import io.trino.tests.product.launcher.env.common.TaskRetriesMultinode;
Expand Down Expand Up @@ -86,6 +88,8 @@ public void configure(Binder binder)
binder.bind(TaskRetriesMultinode.class).in(SINGLETON);
binder.bind(Kerberos.class).in(SINGLETON);
binder.bind(Minio.class).in(SINGLETON);
binder.bind(OpenLdap.class).in(SINGLETON);
binder.bind(OpenLdapReferral.class).in(SINGLETON);

MapBinder<String, EnvironmentProvider> environments = newMapBinder(binder, String.class, EnvironmentProvider.class);
findEnvironmentsByBasePackage(ENVIRONMENT_PACKAGE).forEach(clazz -> environments.addBinding(nameForEnvironmentClass(clazz)).to(clazz).in(SINGLETON));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.tests.product.launcher.env.common;

import com.google.inject.Inject;
import io.trino.tests.product.launcher.env.DockerContainer;
import io.trino.tests.product.launcher.env.Environment;
import io.trino.tests.product.launcher.env.EnvironmentConfig;
import io.trino.tests.product.launcher.testcontainers.PortBinder;
import org.testcontainers.containers.startupcheck.IsRunningStartupCheckStrategy;

import java.time.Duration;

import static io.trino.tests.product.launcher.docker.ContainerUtil.forSelectedPorts;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.LDAP;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.isTrinoContainer;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;

public class OpenLdap
implements EnvironmentExtender
{
private static final int LDAP_PORT = 636;

private final PortBinder portBinder;
private final String imagesVersion;

@Inject
public OpenLdap(PortBinder portBinder, EnvironmentConfig environmentConfig)
{
this.portBinder = requireNonNull(portBinder, "portBinder is null");
this.imagesVersion = environmentConfig.getImagesVersion();
Comment thread
Praveen2112 marked this conversation as resolved.
Outdated
}

@Override
public void extendEnvironment(Environment.Builder builder)
{
String baseImage = format("ghcr.io/trinodb/testing/almalinux9-oj17-openldap:%s", imagesVersion);

builder.configureContainers(dockerContainer -> {
if (isTrinoContainer(dockerContainer.getLogicalName())) {
dockerContainer.setDockerImageName(baseImage);
}
});

builder.configureContainer(TESTS, dockerContainer -> dockerContainer.setDockerImageName(baseImage));

DockerContainer container = new DockerContainer(baseImage, LDAP)
.withStartupCheckStrategy(new IsRunningStartupCheckStrategy())
.waitingFor(forSelectedPorts(LDAP_PORT))
.withStartupTimeout(Duration.ofMinutes(5));
portBinder.exposePort(container, LDAP_PORT);
builder.addContainer(container);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.tests.product.launcher.env.common;

import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import io.trino.tests.product.launcher.env.Environment;
import io.trino.tests.product.launcher.env.EnvironmentConfig;

import java.util.List;

import static io.trino.tests.product.launcher.env.EnvironmentContainers.LDAP;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.isTrinoContainer;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;

public class OpenLdapReferral
implements EnvironmentExtender
{
private final OpenLdap openLdap;
private final String imagesVersion;

@Inject
public OpenLdapReferral(OpenLdap openLdap, EnvironmentConfig environmentConfig)
{
this.openLdap = requireNonNull(openLdap, "openLdap is null");
this.imagesVersion = environmentConfig.getImagesVersion();
}

@Override
public void extendEnvironment(Environment.Builder builder)
{
String baseImage = format("ghcr.io/trinodb/testing/almalinux9-oj17-openldap-referrals:%s", imagesVersion);

builder.configureContainers(dockerContainer -> {
if (isTrinoContainer(dockerContainer.getLogicalName())) {
dockerContainer.setDockerImageName(baseImage);
}
});

builder.configureContainer(TESTS, dockerContainer -> dockerContainer.setDockerImageName(baseImage));
builder.configureContainer(LDAP, dockerContainer -> dockerContainer.setDockerImageName(baseImage));
}

@Override
public List<EnvironmentExtender> getDependencies()
{
return ImmutableList.of(openLdap);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,54 @@
*/
package io.trino.tests.product.launcher.env.environment;

import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import io.trino.tests.product.launcher.docker.DockerFiles;
import io.trino.tests.product.launcher.env.EnvironmentConfig;
import io.trino.tests.product.launcher.env.Environment;
import io.trino.tests.product.launcher.env.EnvironmentProvider;
import io.trino.tests.product.launcher.env.common.Hadoop;
import io.trino.tests.product.launcher.env.common.OpenLdap;
import io.trino.tests.product.launcher.env.common.Standard;
import io.trino.tests.product.launcher.env.common.TestsEnvironment;
import io.trino.tests.product.launcher.testcontainers.PortBinder;

import static io.trino.tests.product.launcher.env.EnvironmentContainers.COORDINATOR;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TEMPTO_PROFILE_CONFIG;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TRINO_CONFIG_PROPERTIES;
import static java.util.Objects.requireNonNull;
import static org.testcontainers.utility.MountableFile.forHostPath;

@TestsEnvironment
public class EnvSinglenodeLdap
extends AbstractEnvSinglenodeLdap
extends EnvironmentProvider
{
private final DockerFiles dockerFiles;
private final PortBinder portBinder;

@Inject
public EnvSinglenodeLdap(Standard standard, Hadoop hadoop, DockerFiles dockerFiles, PortBinder portBinder, EnvironmentConfig config)
public EnvSinglenodeLdap(Standard standard, Hadoop hadoop, OpenLdap openLdap, DockerFiles dockerFiles, PortBinder portBinder)
{
super(ImmutableList.of(standard, hadoop), dockerFiles, portBinder, config);
super(standard, hadoop, openLdap);
this.dockerFiles = requireNonNull(dockerFiles, "dockerFiles is null");
this.portBinder = requireNonNull(portBinder, "portBinder is null");
}

@Override
protected String getPasswordAuthenticatorConfigPath()
public void extendEnvironment(Environment.Builder builder)
{
return "conf/environment/singlenode-ldap/password-authenticator.properties";
builder.addPasswordAuthenticator("ldap", forHostPath(dockerFiles.getDockerFilesHostPath("conf/environment/singlenode-ldap/password-authenticator.properties")));
builder.configureContainer(COORDINATOR, dockerContainer -> {
dockerContainer.withCopyFileToContainer(
forHostPath(dockerFiles.getDockerFilesHostPath("conf/environment/singlenode-ldap/config.properties")),
CONTAINER_TRINO_CONFIG_PROPERTIES);

portBinder.exposePort(dockerContainer, 8443);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already exposed? I think it is something that should be exposed for coordinator as it is a common case. If not maybe it should land in Standard instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on the type of Coordinator - Only with for server with TLS 8443 is exposed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard exposes 8080 - But 8443 is special port so we could expose them on Environment specific.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have Tls env extender?

});

builder.configureContainer(TESTS, dockerContainer -> {
dockerContainer.withCopyFileToContainer(
forHostPath(dockerFiles.getDockerFilesHostPath("conf/tempto/tempto-configuration-for-docker-ldap.yaml")),
CONTAINER_TEMPTO_PROFILE_CONFIG);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,46 @@
*/
package io.trino.tests.product.launcher.env.environment;

import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import io.trino.tests.product.launcher.docker.DockerFiles;
import io.trino.tests.product.launcher.docker.DockerFiles.ResourceProvider;
import io.trino.tests.product.launcher.env.Environment;
import io.trino.tests.product.launcher.env.EnvironmentConfig;
import io.trino.tests.product.launcher.env.EnvironmentProvider;
import io.trino.tests.product.launcher.env.common.Hadoop;
import io.trino.tests.product.launcher.env.common.OpenLdap;
import io.trino.tests.product.launcher.env.common.Standard;
import io.trino.tests.product.launcher.env.common.TestsEnvironment;
import io.trino.tests.product.launcher.testcontainers.PortBinder;

import static io.trino.tests.product.launcher.env.EnvironmentContainers.COORDINATOR;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.trino.tests.product.launcher.env.EnvironmentContainers.configureTempto;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TEMPTO_PROFILE_CONFIG;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TRINO_CONFIG_PROPERTIES;
import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TRINO_ETC;
import static java.util.Objects.requireNonNull;
import static org.testcontainers.utility.MountableFile.forHostPath;

@TestsEnvironment
public class EnvSinglenodeLdapAndFile
extends AbstractEnvSinglenodeLdap
extends EnvironmentProvider
{
private final PortBinder portBinder;
private final DockerFiles dockerFiles;

@Inject
public EnvSinglenodeLdapAndFile(Standard standard, Hadoop hadoop, DockerFiles dockerFiles, PortBinder portBinder, EnvironmentConfig config)
public EnvSinglenodeLdapAndFile(Standard standard, Hadoop hadoop, OpenLdap openLdap, DockerFiles dockerFiles, PortBinder portBinder)
{
super(ImmutableList.of(standard, hadoop), dockerFiles, portBinder, config);
super(standard, hadoop, openLdap);
this.dockerFiles = requireNonNull(dockerFiles, "dockerFiles is null");
this.portBinder = requireNonNull(portBinder, "portBinder is null");
}

@Override
public void extendEnvironment(Environment.Builder builder)
{
super.extendEnvironment(builder);
ResourceProvider configDir = dockerFiles.getDockerFilesHostDirectory("conf/environment/singlenode-ldap-and-file");
builder.addPasswordAuthenticator("ldap", forHostPath(configDir.getPath("password-authenticator.properties")));
builder.addPasswordAuthenticator(
"file",
forHostPath(configDir.getPath("file-authenticator.properties")),
Expand All @@ -57,14 +65,15 @@ public void extendEnvironment(Environment.Builder builder)
.withCopyFileToContainer(
forHostPath(configDir.getPath("password.db")),
CONTAINER_TRINO_ETC + "/password.db");
portBinder.exposePort(dockerContainer, 8443);
});

configureTempto(builder, configDir);
}
builder.configureContainer(TESTS, dockerContainer -> {
dockerContainer.withCopyFileToContainer(
forHostPath(dockerFiles.getDockerFilesHostPath("conf/tempto/tempto-configuration-for-docker-ldap.yaml")),
CONTAINER_TEMPTO_PROFILE_CONFIG);
});

@Override
protected String getPasswordAuthenticatorConfigPath()
{
return "conf/environment/singlenode-ldap/password-authenticator.properties";
configureTempto(builder, configDir);
}
}
Loading