Skip to content

Commit

Permalink
Moved helm binaries to src/bin, adjusted tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sschnabe committed Nov 30, 2023
1 parent c2587cc commit b6bd0d7
Show file tree
Hide file tree
Showing 26 changed files with 38 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<!-- we have flaky tests with caching of Authenticator.setDefault() -->
<surefire.rerunFailingTestsCount>3</surefire.rerunFailingTestsCount>

<invoker.debug>true</invoker.debug>
<invoker.debug>false</invoker.debug>
<invoker.parallelThreads>0.5C</invoker.parallelThreads>
<invoker.settingsFile>${project.basedir}/src/it/settings.xml</invoker.settingsFile>

Expand Down
Binary file added src/bin/aarch64/helm
Binary file not shown.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/it/dependency-with-overwrite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<helmExtraRepos>
<helmExtraRepo>
<name>kokuwaio</name>
Expand Down
2 changes: 1 addition & 1 deletion src/it/extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<helmExtraRepos>
<helmExtraRepo>
<name>kokuwaio</name>
Expand Down
2 changes: 1 addition & 1 deletion src/it/init-with-debug/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<helmExtraRepos>
<helmExtraRepo>
<name>kokuwaio-with-credentials</name>
Expand Down
2 changes: 1 addition & 1 deletion src/it/init-with-helm-from-directory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<addDefaultRepo>false</addDefaultRepo>
<chartDirectory>${project.basedir}/src/main/helm</chartDirectory>
<chartVersion>1.0.0</chartVersion>
Expand Down
3 changes: 2 additions & 1 deletion src/it/init-with-helm-from-directory/postbuild.bsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// verify that configured helm was used

System.out.println(basedir);
return org.codehaus.plexus.util.FileUtils
.fileRead(basedir + "/build.log")
.contains("Using local HELM binary [" + basedir + "/../helm]")
.contains("Using local HELM binary [" + basedir + "/../../../src/bin/amd64/helm]")
2 changes: 1 addition & 1 deletion src/it/init-without-k8s-warning/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<addDefaultRepo>false</addDefaultRepo>
<chartDirectory>${project.basedir}/src/main/helm</chartDirectory>
<chartVersion>1.0.0</chartVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/it/lint-with-dependency/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<helmExtraRepos>
<helmExtraRepo>
<name>kokuwaio</name>
Expand Down
2 changes: 1 addition & 1 deletion src/it/path with spaces/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<helmExtraRepos>
<helmExtraRepo>
<name>kokuwaio</name>
Expand Down
2 changes: 2 additions & 0 deletions src/it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<maven.compiler.source>@maven.compiler.source@</maven.compiler.source>
<maven.compiler.target>@maven.compiler.target@</maven.compiler.target>

<test.helmExecutableDirectory>${project.basedir}/../../../src/bin/amd64</test.helmExecutableDirectory>

<!-- ===================================================================== -->
<!-- ============================= Libaries ============================== -->
<!-- ===================================================================== -->
Expand Down
2 changes: 1 addition & 1 deletion src/it/push-with-auth-from-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<addDefaultRepo>false</addDefaultRepo>
<chartDirectory>${project.basedir}/src/main/helm</chartDirectory>
<chartVersion>1.0.0</chartVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/it/push-with-auth-from-pom/postbuild.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

return org.codehaus.plexus.util.FileUtils
.fileRead(basedir + "/build.log")
.contains(basedir + "/../helm registry login 127.0.0.1 --username auth-from-pom --password-stdin\n")
.contains(basedir + "/../../../src/bin/amd64/helm registry login 127.0.0.1 --username auth-from-pom --password-stdin\n")
2 changes: 1 addition & 1 deletion src/it/push-with-auth-from-settings/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<addDefaultRepo>false</addDefaultRepo>
<chartDirectory>${project.basedir}/src/main/helm</chartDirectory>
<chartVersion>1.0.0</chartVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/it/push-with-auth-from-settings/postbuild.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

return org.codehaus.plexus.util.FileUtils
.fileRead(basedir + "/build.log")
.contains(basedir + "/../helm registry login 127.0.0.1 --username auth-from-settings --password-stdin\n")
.contains(basedir + "/../../../src/bin/amd64/helm registry login 127.0.0.1 --username auth-from-settings --password-stdin\n")
2 changes: 1 addition & 1 deletion src/it/push-without-auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<addDefaultRepo>false</addDefaultRepo>
<chartDirectory>${project.basedir}/src/main/helm</chartDirectory>
<chartVersion>1.0.0</chartVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/it/push-without-auth/postbuild.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

return org.codehaus.plexus.util.FileUtils
.fileRead(basedir + "/build.log")
.contains(basedir + "/../helm push " + basedir + "/target/helm/repo/app-1.0.0.tgz oci://127.0.0.1\n")
.contains(basedir + "/../../../src/bin/amd64/helm push " + basedir + "/target/helm/repo/app-1.0.0.tgz oci://127.0.0.1\n")
2 changes: 1 addition & 1 deletion src/it/template-with-additional-arguments/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<configuration>
<autoDetectLocalHelmBinary>false</autoDetectLocalHelmBinary>
<useLocalHelmBinary>true</useLocalHelmBinary>
<helmExecutableDirectory>${project.basedir}/..</helmExecutableDirectory>
<helmExecutableDirectory>${test.helmExecutableDirectory}</helmExecutableDirectory>
<addDefaultRepo>false</addDefaultRepo>
<chartDirectory>${project.basedir}/src/main/helm</chartDirectory>
<chartVersion>1.0.0</chartVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/kokuwa/maven/helm/AbstractHelmMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Path getHelmExecutablePath() throws MojoExecutionException {
if (useLocalHelmBinary && autoDetectLocalHelmBinary) {
optional = Stream.of(System.getenv("PATH").split(Pattern.quote(File.pathSeparator))).map(Paths::get);
if (helmExecutableDirectory != null) {
// if defined, search also in helm executable directory (eg. used for fallback binary download)
// if defined, search also in helm executable directory (e.g. used for fallback binary download)
optional = Stream.concat(optional, Stream.of(helmExecutableDirectory.toPath()));
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/kokuwa/maven/helm/AbstractMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static Server getServer(String id, String username, String password) {
}

static Path copyPackagedHelmChartToOutputdirectory(AbstractHelmMojo mojo) {
Path source = Paths.get("src/test/resources/app-0.1.0.tgz");
Path source = Paths.get("src/test/resources/__files/app-0.1.0.tgz");
Path target = mojo.getOutputDirectory().resolve("app-0.1.0.tgz");
assertDoesNotThrow(() -> Files.createDirectories(target.getParent()));
assertDoesNotThrow(() -> Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING));
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/io/kokuwa/maven/helm/HelmMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.junit.jupiter.api.condition.EnabledIf;
import org.junit.jupiter.api.condition.OS;

import io.kokuwa.maven.helm.junit.MojoExtension;
import io.kokuwa.maven.helm.pojo.K8SCluster;
import io.kokuwa.maven.helm.pojo.ValueOverride;

Expand All @@ -37,8 +38,8 @@ class Executable {
void fixed(LintMojo mojo) {
mojo.setUseLocalHelmBinary(true);
mojo.setAutoDetectLocalHelmBinary(false);
mojo.setHelmExecutableDirectory(new File("src/it"));
Path expected = Paths.get("src/it").resolve(HELM).toAbsolutePath();
mojo.setHelmExecutableDirectory(MojoExtension.determineHelmExecutableDirectory().toFile());
Path expected = MojoExtension.determineHelmExecutableDirectory().resolve(HELM);
Path actual = assertDoesNotThrow(() -> mojo.getHelmExecutablePath());
assertEquals(expected, actual);
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/io/kokuwa/maven/helm/InitMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.github.tomakehurst.wiremock.matching.RequestPatternBuilder;
import com.github.tomakehurst.wiremock.verification.LoggedRequest;

import io.kokuwa.maven.helm.junit.MojoExtension;
import io.kokuwa.maven.helm.pojo.HelmRepository;
import io.kokuwa.maven.helm.pojo.RepoType;

Expand Down Expand Up @@ -103,7 +104,7 @@ void localHelm(InitMojo mojo) {
mojo.setUseLocalHelmBinary(true);
mojo.setFallbackBinaryDownload(false);
mojo.setHelmVersion(null);
mojo.setHelmExecutableDirectory(new File("src/it"));
mojo.setHelmExecutableDirectory(MojoExtension.determineHelmExecutableDirectory().toFile());
assertHelm(mojo, "version", "repo add stable " + InitMojo.STABLE_HELM_REPO);
}

Expand Down
13 changes: 12 additions & 1 deletion src/test/java/io/kokuwa/maven/helm/junit/MojoExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.io.File;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -112,12 +114,21 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte
// preconfigure

mojo.setChartDirectory(new File("src/test/resources/simple")); // set some sane defaults for tests
mojo.setHelmExecutableDirectory(new File("src/it")); // avoid download helm
mojo.setHelmExecutableDirectory(determineHelmExecutableDirectory().toFile()); // avoid download helm
mojo.setHelmVersion("3.12.0"); // avoid github api

return mojo;
} catch (ReflectiveOperationException e) {
throw new ParameterResolutionException("Failed to setup mockito.", e);
}
}

/**
* Determines which helm executable to use based on the machine's architecture.
*
* @return location of appropriate helm executable
*/
public static Path determineHelmExecutableDirectory() {
return Paths.get("src/bin/" + System.getProperty("os.arch")).toAbsolutePath();
}
}
File renamed without changes.

0 comments on commit b6bd0d7

Please sign in to comment.