-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve and test
jetty.sh
behaviors (#10753)
* Issue #10696 - Addressing start-stop-daemon behaviors in jetty.sh * disable internal pid-file management of start-stop-daemon * IssueDo not test for file system permissions if user is root, or process will switch to JETTY_USER * Fixing bad UID / JETTY_USER condition * Avoid FS test with setuid use as well * Fixing stop behavior * Adding jetty.sh docker testing --------- Signed-off-by: Joakim Erdfelt <[email protected]> Signed-off-by: Olivier Lamy <[email protected]> Co-authored-by: Olivier Lamy <[email protected]>
- Loading branch information
Showing
15 changed files
with
622 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...distribution/src/test/java/org/eclipse/jetty/tests/distribution/jettysh/ImageFromDSL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.tests.distribution.jettysh; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import org.testcontainers.images.builder.ImageFromDockerfile; | ||
import org.testcontainers.images.builder.dockerfile.DockerfileBuilder; | ||
|
||
/** | ||
* Simplify the use of {@link ImageFromDockerfile} to get some sanity in naming convention | ||
* and {@link #toString()} behaviors so that Test execution makes sense. | ||
*/ | ||
public class ImageFromDSL extends ImageFromDockerfile | ||
{ | ||
private ImageFromDSL parentImage; | ||
|
||
public ImageFromDSL(ImageFromDSL baseImage, String suffix, Consumer<DockerfileBuilder> builderConsumer) | ||
{ | ||
this(baseImage.getDockerImageName() + "-" + suffix, builderConsumer); | ||
this.parentImage = baseImage; | ||
} | ||
|
||
public ImageFromDSL(String name, Consumer<DockerfileBuilder> builderConsumer) | ||
{ | ||
super(name, false); | ||
withDockerfileFromBuilder(builderConsumer); | ||
} | ||
|
||
public ImageFromDSL getParentImage() | ||
{ | ||
return parentImage; | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return getDockerImageName(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/jettysh/ImageOS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.tests.distribution.jettysh; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.function.Consumer; | ||
|
||
import org.eclipse.jetty.tests.hometester.JettyHomeTester; | ||
import org.testcontainers.images.builder.dockerfile.DockerfileBuilder; | ||
|
||
public abstract class ImageOS extends ImageFromDSL | ||
{ | ||
public static final String REGISTRY = "registry.jetty.org"; | ||
public static final String REPOSITORY = REGISTRY + "/jetty-sh"; | ||
|
||
private Path jettyHomePath; | ||
|
||
public ImageOS(String osid, Consumer<DockerfileBuilder> builderConsumer) | ||
{ | ||
super(REPOSITORY + ":" + osid, builderConsumer); | ||
} | ||
|
||
protected File getJettyHomeDir() | ||
{ | ||
if (jettyHomePath == null) | ||
{ | ||
String jettyVersion = System.getProperty("jettyVersion"); | ||
try | ||
{ | ||
JettyHomeTester homeTester = JettyHomeTester.Builder.newInstance() | ||
.jettyVersion(jettyVersion) | ||
.mavenLocalRepository(System.getProperty("mavenRepoPath")) | ||
.build(); | ||
jettyHomePath = homeTester.getJettyHome(); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new RuntimeException("Unable to get unpacked JETTY_HOME dir", e); | ||
} | ||
} | ||
return jettyHomePath.toFile(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...n/src/test/java/org/eclipse/jetty/tests/distribution/jettysh/ImageOSAmazonCorretto11.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.tests.distribution.jettysh; | ||
|
||
/** | ||
* An OS Image of linux specific for running on Amazon AWS. | ||
* This is based on Amazon Linux 2 (which is based on Alpine 3). | ||
* Amazon Corretto JDK 11 is installed. | ||
* This image does NOT come with start-stop-daemon installed. | ||
* Instead of apt, it uses yum (the redhat package manager) | ||
*/ | ||
public class ImageOSAmazonCorretto11 extends ImageOS | ||
{ | ||
public ImageOSAmazonCorretto11() | ||
{ | ||
super("amazoncorretto-jdk11", | ||
builder -> | ||
builder | ||
.from("amazoncorretto:11.0.20") | ||
.run("yum update -y ; " + | ||
"yum install -y curl tar gzip vim shadow-utils net-tools") | ||
.env("TEST_DIR", "/var/test") | ||
.env("JETTY_HOME", "$TEST_DIR/jetty-home") | ||
.env("JETTY_BASE", "$TEST_DIR/jetty-base") | ||
.env("PATH", "$PATH:${JETTY_HOME}/bin/") | ||
.user("root") | ||
// Configure /etc/default/jetty | ||
.run("echo \"JETTY_HOME=${JETTY_HOME}\" > /etc/default/jetty ; " + | ||
"echo \"JETTY_BASE=${JETTY_BASE}\" >> /etc/default/jetty ; " + | ||
"echo \"JETTY_RUN=${JETTY_BASE}\" >> /etc/default/jetty ") | ||
// setup Jetty Home | ||
.copy("/opt/jetty/", "${JETTY_HOME}/") | ||
.env("PATH", "$PATH:${JETTY_HOME}/bin/") | ||
.run("chmod ugo+x ${JETTY_HOME}/bin/jetty.sh") | ||
.build() | ||
); | ||
withFileFromFile("/opt/jetty/", getJettyHomeDir()); | ||
} | ||
} |
Oops, something went wrong.