forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] port linux package packaging tests
Add packaging tests for the linux package distributions to the java test project and remove them from bats. Most of the tests that lived in 30_deb_package.bats and 40_rpm_package.bats are applicable to both package types and are combined into a single type of test case. Others are separated out into separate cases to make their intent more clear For elastic#26741
- Loading branch information
1 parent
3189ef4
commit ce74fde
Showing
22 changed files
with
1,119 additions
and
490 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
129 changes: 129 additions & 0 deletions
129
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/DebPreservationTestCase.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,129 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
import org.elasticsearch.packaging.util.Installation; | ||
import org.elasticsearch.packaging.util.Shell; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.FixMethodOrder; | ||
import org.junit.Test; | ||
import org.junit.runners.MethodSorters; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.stream.Stream; | ||
|
||
import static org.elasticsearch.packaging.util.Cleanup.cleanEverything; | ||
import static org.elasticsearch.packaging.util.Packages.SYSVINIT_SCRIPT; | ||
import static org.elasticsearch.packaging.util.Packages.assertInstalled; | ||
import static org.elasticsearch.packaging.util.Packages.assertRemoved; | ||
import static org.elasticsearch.packaging.util.Packages.install; | ||
import static org.elasticsearch.packaging.util.Packages.remove; | ||
import static org.elasticsearch.packaging.util.Packages.packageStatus; | ||
import static org.elasticsearch.packaging.util.Packages.verifyPackageInstallation; | ||
import static org.elasticsearch.packaging.util.Platforms.isDPKG; | ||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assume.assumeThat; | ||
import static org.junit.Assume.assumeTrue; | ||
|
||
@FixMethodOrder(MethodSorters.NAME_ASCENDING) | ||
public abstract class DebPreservationTestCase { | ||
|
||
private static Installation installation; | ||
|
||
protected abstract Distribution distribution(); | ||
|
||
@BeforeClass | ||
public static void cleanup() { | ||
installation = null; | ||
cleanEverything(); | ||
} | ||
|
||
@Before | ||
public void onlyCompatibleDistributions() { | ||
assumeTrue("only dpkg platforms", isDPKG()); | ||
assumeTrue("only compatible distributions", distribution().packaging.compatible); | ||
} | ||
|
||
@Test | ||
public void test10Install() { | ||
assertRemoved(distribution()); | ||
installation = install(distribution()); | ||
assertInstalled(distribution()); | ||
verifyPackageInstallation(installation, distribution()); | ||
} | ||
|
||
@Test | ||
public void test20Remove() { | ||
assumeThat(installation, is(notNullValue())); | ||
|
||
remove(distribution()); | ||
|
||
// some config files were not removed | ||
Stream.of( | ||
installation.config, | ||
installation.config("elasticsearch.yml"), | ||
installation.config("jvm.options"), | ||
installation.config("log4j2.properties") | ||
).forEach(path -> assertTrue(path + " should exist", Files.exists(path))); | ||
|
||
// keystore was removed | ||
Stream.of( | ||
installation.config("elasticsearch.keystore"), | ||
installation.config(".elasticsearch.keystore.initial_md5sum") | ||
).forEach(path -> assertFalse(path + " should not exist", Files.exists(path))); | ||
|
||
// doc files were removed | ||
Stream.of( | ||
"/usr/share/doc/" + distribution().flavor.name, | ||
"/usr/share/doc/" + distribution().flavor.name + "/copyright" | ||
).map(Paths::get).forEach(path -> assertFalse(path + " does not exist", Files.exists(path))); | ||
|
||
// sysvinit service file was not removed | ||
assertTrue(Files.exists(SYSVINIT_SCRIPT)); | ||
|
||
// defaults file was not removed | ||
assertTrue(Files.exists(installation.envFile)); | ||
} | ||
|
||
@Test | ||
public void test30Purge() { | ||
assumeThat(installation, is(notNullValue())); | ||
|
||
final Shell sh = new Shell(); | ||
sh.run("dpkg --purge " + distribution().flavor.name); | ||
|
||
assertRemoved(distribution()); | ||
|
||
Stream.of( | ||
installation.config, | ||
installation.envFile, | ||
SYSVINIT_SCRIPT | ||
).forEach(path -> assertFalse(path + " should not exist", Files.exists(path))); | ||
|
||
assertThat(packageStatus(distribution()).exitCode, is(1)); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/DefaultDebBasicTests.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,31 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
|
||
public class DefaultDebBasicTests extends PackageTestCase { | ||
|
||
@Override | ||
protected Distribution distribution() { | ||
return Distribution.DEFAULT_DEB; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/DefaultDebPreservationTests.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,30 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
|
||
public class DefaultDebPreservationTests extends DebPreservationTestCase { | ||
|
||
@Override | ||
protected Distribution distribution() { | ||
return Distribution.DEFAULT_DEB; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/DefaultRpmBasicTests.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,30 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
|
||
public class DefaultRpmBasicTests extends PackageTestCase { | ||
|
||
@Override | ||
protected Distribution distribution() { | ||
return Distribution.DEFAULT_RPM; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/DefaultRpmPreservationTests.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,30 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
|
||
public class DefaultRpmPreservationTests extends RpmPreservationTestCase { | ||
|
||
@Override | ||
protected Distribution distribution() { | ||
return Distribution.DEFAULT_RPM; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/OssDebBasicTests.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,30 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
|
||
public class OssDebBasicTests extends PackageTestCase { | ||
|
||
@Override | ||
protected Distribution distribution() { | ||
return Distribution.OSS_DEB; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/OssDebPreservationTests.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,30 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
|
||
public class OssDebPreservationTests extends DebPreservationTestCase { | ||
|
||
@Override | ||
protected Distribution distribution() { | ||
return Distribution.OSS_DEB; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
qa/vagrant/src/main/java/org/elasticsearch/packaging/test/OssRpmBasicTests.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,30 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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 org.elasticsearch.packaging.test; | ||
|
||
import org.elasticsearch.packaging.util.Distribution; | ||
|
||
public class OssRpmBasicTests extends PackageTestCase { | ||
|
||
@Override | ||
protected Distribution distribution() { | ||
return Distribution.OSS_RPM; | ||
} | ||
} |
Oops, something went wrong.