-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Extract Ldap as an EnvironmentExtender #22958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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(); | ||
| } | ||
|
|
||
| @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 |
|---|---|---|
|
|
@@ -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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should have |
||
| }); | ||
|
|
||
| builder.configureContainer(TESTS, dockerContainer -> { | ||
| dockerContainer.withCopyFileToContainer( | ||
| forHostPath(dockerFiles.getDockerFilesHostPath("conf/tempto/tempto-configuration-for-docker-ldap.yaml")), | ||
| CONTAINER_TEMPTO_PROFILE_CONFIG); | ||
| }); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.