[TEST] Fix failing distro tests for linux packages (#569) (#733)

Changes to fix the failing OpenSearch distribution tests for packages (linux-archive, linux-archive-aarch64, debian, rpm, docker) on supported linux distros. 

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-05-20 14:11:03 -07:00 committed by GitHub
parent 864466cbdb
commit 3290932fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 15 deletions

View File

@ -1,4 +1,4 @@
OpenSearch
OpenSearch (https://opensearch.org/)
Copyright 2021 OpenSearch Contributors
This product includes software developed by

2
Vagrantfile vendored
View File

@ -387,7 +387,7 @@ def linux_common(config,
# This prevents leftovers from previous tests using the
# same VM from messing up the current test
config.vm.provision 'clean es installs in tmp', run: 'always', type: 'shell', inline: <<-SHELL
config.vm.provision 'clean opensearch installs in tmp', run: 'always', type: 'shell', inline: <<-SHELL
rm -rf /tmp/opensearch*
SHELL

View File

@ -89,7 +89,7 @@ class InternalDistributionArchiveCheckPluginFuncTest extends AbstractGradleFuncT
def "fails on unexpected notice content"() {
given:
license(file("LICENSE.txt"))
file("NOTICE.txt").text = """OpenSearch
file("NOTICE.txt").text = """OpenSearch (https://opensearch.org/)
Copyright 2009-2018 Acme Coorp"""
buildFile << """
apply plugin:'base'

View File

@ -39,6 +39,9 @@ import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import java.nio.file.Files
import java.nio.file.attribute.PosixFilePermissions
/**
* A task to create a notice file which includes dependencies' notices.
*/
@ -149,6 +152,7 @@ class NoticeTask extends DefaultTask {
}
}
outputFile.setText(output.toString(), 'UTF-8')
Files.setPosixFilePermissions(outputFile.toPath(), PosixFilePermissions.fromString("rw-r--r--"))
}
@InputFiles

View File

@ -103,7 +103,10 @@ public class InternalDistributionArchiveCheckPlugin implements Plugin<Project> {
task.doLast(new Action<Task>() {
@Override
public void execute(Task task) {
final List<String> noticeLines = Arrays.asList("OpenSearch", "Copyright 2021 OpenSearch Contributors");
final List<String> noticeLines = Arrays.asList(
"OpenSearch (https://opensearch.org/)",
"Copyright 2021 OpenSearch Contributors"
);
final Path noticePath = checkExtraction.get()
.getDestinationDir()
.toPath()

View File

@ -294,7 +294,7 @@ apply plugin: 'nebula.ospackage-base'
// this is package indepdendent configuration
ospackage {
maintainer 'OpenSearch Team'
maintainer 'OpenSearch Team <opensearch@amazon.com>'
summary 'Distributed RESTful search engine built for the cloud'
packageDescription '''
Reference documentation can be found at
@ -341,6 +341,7 @@ Closure commonDebConfig(boolean jdk, String architecture) {
into('/usr/share/lintian/overrides') {
from('src/deb/lintian/opensearch')
fileMode 0644
}
}
}
@ -361,7 +362,7 @@ Closure commonRpmConfig(boolean jdk, String architecture) {
return {
configure(commonPackageConfig('rpm', jdk, architecture))
license 'ASL 2.0'
license 'ASL-2.0'
packageGroup 'Application/Internet'
requires '/bin/bash'
@ -499,7 +500,7 @@ subprojects {
(project.name.contains('deb') && dpkgExists.call(it)) || (project.name.contains('rpm') && rpmExists.call(it))
}
doLast {
final List<String> noticeLines = Arrays.asList("OpenSearch", "Copyright 2021 OpenSearch Contributors")
final List<String> noticeLines = Arrays.asList("OpenSearch (https://opensearch.org/)", "Copyright 2021 OpenSearch Contributors")
final Path noticePath = packageExtractionDir.toPath().resolve("usr/share/opensearch/NOTICE.txt")
assertLinesInFile(noticePath, noticeLines)
}

View File

@ -358,7 +358,7 @@ public class DockerTests extends PackagingTestCase {
// expected group.
final Shell localSh = new Shell();
final String findResults = localSh.run(
"docker run --rm --tty " + getImageName(distribution) + " bash -c ' touch data/test && find . -not -gid 0 ' "
"docker run --rm --tty " + getImageName() + " bash -c ' touch data/test && find . -not -gid 0 ' "
).stdout;
assertThat("Found some files whose GID != 0", findResults, is(emptyString()));

View File

@ -90,7 +90,7 @@ public class Docker {
* @param distribution details about the docker image to potentially load.
*/
public static void ensureImageIsLoaded(Distribution distribution) {
Shell.Result result = sh.run("docker image ls --format '{{.Repository}}' " + getImageName(distribution));
Shell.Result result = sh.run("docker image ls --format '{{.Repository}}' " + getImageName());
final long count = Arrays.stream(result.stdout.split("\n")).map(String::trim).filter(s -> s.isEmpty() == false).count();
@ -224,7 +224,7 @@ public class Docker {
}
// Image name
args.add(getImageName(distribution));
args.add(getImageName());
final String command = String.join(" ", args);
logger.info("Running command: " + command);
@ -581,7 +581,7 @@ public class Docker {
public static Map<String, String> getImageLabels(Distribution distribution) throws Exception {
// The format below extracts the .Config.Labels value, and prints it as json. Without the json
// modifier, a stringified Go map is printed instead, which isn't helpful.
String labelsJson = sh.run("docker inspect -f '{{json .Config.Labels}}' " + getImageName(distribution)).stdout;
String labelsJson = sh.run("docker inspect -f '{{json .Config.Labels}}' " + getImageName()).stdout;
ObjectMapper mapper = new ObjectMapper();
@ -598,7 +598,7 @@ public class Docker {
return sh.run("docker logs " + containerId);
}
public static String getImageName(Distribution distribution) {
return ":test";
public static String getImageName() {
return "opensearch:test";
}
}

View File

@ -137,7 +137,9 @@ public class Packages {
}
private static Result runPackageManager(Distribution distribution, Shell sh, PackageManagerCommand command) {
final String distributionArg = distribution.path.toString();
final String distributionArg = command == PackageManagerCommand.QUERY || command == PackageManagerCommand.REMOVE
? "opensearch"
: distribution.path.toString();
if (Platforms.isRPM()) {
String rpmOptions = RPM_OPTIONS.get(command);
@ -216,7 +218,7 @@ public class Packages {
if (distribution.packaging == Distribution.Packaging.RPM) {
assertThat(opensearch.home.resolve("LICENSE.txt"), file(File, "root", "root", p644));
} else {
Path copyrightDir = Paths.get(sh.run("readlink -f /usr/share/doc/").stdout.trim());
Path copyrightDir = Paths.get(sh.run("readlink -f /usr/share/doc/opensearch").stdout.trim());
assertThat(copyrightDir, file(Directory, "root", "root", p755));
assertThat(copyrightDir.resolve("copyright"), file(File, "root", "root", p644));
}