forked from eclipse-tycho/tycho
-
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.
Add Integration Test for issue eclipse-tycho#2875
This integration test shows that `download.md5` and `download.checksum.md5` are present after running the `fix-artifacts-metadata` goal when they shouldn't. If these are not removed and the content of the artifact changed then, after the recalculation done by this goal, new p2 libs will see an outdated value for these old checksum algorithms and will fail the installation due to a checksum mismatch.
- Loading branch information
Showing
4 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
tycho-its/projects/p2Repository.fixArtifactsMetadata.oldChecksums/category.xml
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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<site> | ||
<bundle id="org.slf4j.api" version="0.0.0"/> | ||
</site> |
54 changes: 54 additions & 0 deletions
54
tycho-its/projects/p2Repository.fixArtifactsMetadata.oldChecksums/pom.xml
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,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>tycho-its-project.p2Repository.fixArtifactsMetadata.oldChecksums</groupId> | ||
<artifactId>pfo.repository</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>eclipse-repository</packaging> | ||
|
||
<properties> | ||
<tycho-version>4.0.8</tycho-version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-maven-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<extensions>true</extensions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>target-platform-configuration</artifactId> | ||
<version>${tycho-version}</version> | ||
<configuration> | ||
<target> | ||
<file>test.target</file> | ||
</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.tycho</groupId> | ||
<artifactId>tycho-p2-repository-plugin</artifactId> | ||
<version>${tycho-version}</version> | ||
<executions> | ||
<execution> | ||
<id>fix</id> | ||
<goals> | ||
<goal>fix-artifacts-metadata</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>verify</id> | ||
<goals> | ||
<goal>verify-repository</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
14 changes: 14 additions & 0 deletions
14
tycho-its/projects/p2Repository.fixArtifactsMetadata.oldChecksums/test.target
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,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?pde version="3.8"?> | ||
|
||
<target name="p2Repository.fixArtifactsMetadata.oldChecksums.target" sequenceNumber="1"> | ||
|
||
<locations> | ||
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="slicer" includeSource="false" type="InstallableUnit"> | ||
<unit id="org.slf4j.api" version="0.0.0"/> | ||
|
||
<repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20220531185310/repository/"/> | ||
</location> | ||
</locations> | ||
|
||
</target> |
81 changes: 81 additions & 0 deletions
81
...org/eclipse/tycho/test/p2Repository/P2RepositoryFixArtifactsMetadataOldChecksumsTest.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,81 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Martin D'Aloia and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.test.p2Repository; | ||
|
||
import static java.util.Arrays.asList; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.maven.it.Verifier; | ||
import org.codehaus.plexus.util.xml.Xpp3Dom; | ||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder; | ||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; | ||
import org.eclipse.tycho.test.AbstractTychoIntegrationTest; | ||
import org.junit.Test; | ||
import org.tukaani.xz.XZInputStream; | ||
|
||
/** | ||
* Test that the goal `tycho-p2-repository:fix-artifacts-metadata` removes | ||
* old checksums if they are present in the source metadata. | ||
* New p2 libs are configured to not publish them anymore. | ||
* <p> | ||
* If not removed, they are checked during the product assembly and because | ||
* they continue to keep an old value (if a IU was modified for example to | ||
* (re)sign it) this step fails to complete due to checksum mismatch. | ||
* | ||
* See https://github.com/eclipse-tycho/tycho/issues/2875 | ||
*/ | ||
public class P2RepositoryFixArtifactsMetadataOldChecksumsTest extends AbstractTychoIntegrationTest { | ||
|
||
@Test | ||
public void testRemoveOldChecksumsNotRecalculated() throws Exception { | ||
Verifier verifier = getVerifier("/p2Repository.fixArtifactsMetadata.oldChecksums", false); | ||
verifier.executeGoals(asList("verify")); | ||
verifier.verifyErrorFreeLog(); | ||
|
||
Path repositoryPath = Path.of(verifier.getBasedir(), "target/repository"); | ||
Path artifactPath = repositoryPath.resolve("artifacts.xml.xz"); | ||
assertTrue(artifactPath.toFile().isFile()); | ||
|
||
Xpp3Dom dom; | ||
try (XZInputStream stream = new XZInputStream(Files.newInputStream(artifactPath))) { | ||
dom = Xpp3DomBuilder.build(stream, StandardCharsets.UTF_8.displayName()); | ||
} catch (IOException | XmlPullParserException e) { | ||
fail(e.getMessage()); | ||
throw e; | ||
} | ||
|
||
Map<String, String> artifactProperties = getArtifactProperties(dom, "org.slf4j.api"); | ||
|
||
String[] checksumsThatMustNotBePresent = {"download.md5", "download.checksum.md5"}; | ||
for(String checksumKey : checksumsThatMustNotBePresent) { | ||
String checksumValue = artifactProperties.get(checksumKey); | ||
|
||
assertNull("Property '" + checksumKey + "' is present in artifacts metadata", checksumValue); | ||
} | ||
} | ||
|
||
private Map<String, String> getArtifactProperties(Xpp3Dom element, String artifactId) { | ||
return Arrays.stream(element.getChild("artifacts").getChildren()) | ||
.filter(it -> artifactId.equals(it.getAttribute("id"))) | ||
.flatMap(it -> Arrays.stream(it.getChild("properties").getChildren())) | ||
.collect(Collectors.toMap(it -> it.getAttribute("name"), it -> it.getAttribute("value"))); | ||
} | ||
|
||
} |