You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2021/04/14 12:22:16 UTC

[camel-k] 01/02: chore(e2e): Rely on staging repository in Maven CA e2e tests

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 7dde4f7e7eaa42577a4f4b3824f059c6d5511bd0
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Wed Apr 14 12:01:45 2021 +0200

    chore(e2e): Rely on staging repository in Maven CA e2e tests
---
 e2e/common/build/maven_ca_secret_test.go | 40 +++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/e2e/common/build/maven_ca_secret_test.go b/e2e/common/build/maven_ca_secret_test.go
index 259592a..2ef9db1 100644
--- a/e2e/common/build/maven_ca_secret_test.go
+++ b/e2e/common/build/maven_ca_secret_test.go
@@ -33,6 +33,7 @@ import (
 	"math/big"
 	rand2 "math/rand"
 	"os"
+	"strings"
 	"testing"
 	"time"
 
@@ -50,6 +51,7 @@ import (
 
 	. "github.com/apache/camel-k/e2e/support"
 	v1 "github.com/apache/camel-k/pkg/apis/camel/v1"
+	"github.com/apache/camel-k/pkg/util/maven"
 )
 
 func TestMavenCASecret(t *testing.T) {
@@ -374,8 +376,26 @@ ProxyPreserveHost On
 			SubResource("exec").
 			Param("container", "nexus")
 
-		apacheSnapshots := "https://repository.apache.org/content/repositories/snapshots/"
-		repository := fmt.Sprintf(`{"name":"apache-snapshots","proxy":{"remoteUrl":"%s","contentMaxAge":1440,"metadataMaxAge":1440},"online":true,"maven":{"versionPolicy":"SNAPSHOT","layoutPolicy":"PERMISSIVE"},"negativeCache":{"enabled":false,"timeToLive":1440},"httpClient":{"autoBlock":false,"blocked":false},"storage":{"strictContentTypeValidation":true,"blobStoreName":"default"}}`, apacheSnapshots)
+		// Rely on the Camel K staging repository, that can either be Apache Staging,
+		// during releases preparation, or Apache Snapshots otherwise.
+		stagingRepositoryUrl := os.Getenv("KAMEL_INSTALL_MAVEN_REPOSITORIES")
+		if stagingRepositoryUrl == "" {
+			stagingRepositoryUrl = "https://repository.apache.org/content/repositories/snapshots/@id=apache-snapshots@snapshots@noreleases"
+		}
+		stagingRepository := maven.NewRepository(stagingRepositoryUrl)
+		if stagingRepository.ID == "" {
+			stagingRepository.ID = "staging"
+		}
+		versionPolicy := ""
+		if stagingRepository.Releases.Enabled && stagingRepository.Snapshots.Enabled {
+			versionPolicy = "MIXED"
+		} else if stagingRepository.Releases.Enabled {
+			versionPolicy = "RELEASE"
+		} else {
+			versionPolicy = "SNAPSHOT"
+		}
+
+		repository := fmt.Sprintf(`{"name":"%s","proxy":{"remoteUrl":"%s","contentMaxAge":1440,"metadataMaxAge":1440},"online":true,"maven":{"versionPolicy":"%s","layoutPolicy":"PERMISSIVE"},"negativeCache":{"enabled":false,"timeToLive":1440},"httpClient":{"autoBlock":false,"blocked":false},"storage":{"strictContentTypeValidation":true,"blobStoreName":"default"}}`, stagingRepository.ID, stagingRepository.URL, versionPolicy)
 
 		req.VersionedParams(&corev1.PodExecOptions{
 			Container: "nexus",
@@ -401,7 +421,7 @@ ProxyPreserveHost On
 		// Install Camel K with the Maven Central Nexus proxy and the corresponding Maven CA secret
 		Expect(Kamel("install", "-n", ns,
 			"--maven-repository", fmt.Sprintf(`https://%s/repository/maven-public/@id=central-internal@mirrorOf=central`, hostname),
-			"--maven-repository", fmt.Sprintf(`https://%s/repository/apache-snapshots/@id=apache-snapshots@snapshots@noreleases`, hostname),
+			"--maven-repository", fmt.Sprintf(`https://%s/repository/%s/%s`, hostname, stagingRepository.ID, strings.Join(getRepositoryAttributes(stagingRepository), "")),
 			"--maven-ca-secret", secret.Name+"/"+corev1.TLSCertKey,
 		).Execute()).To(Succeed())
 
@@ -428,3 +448,17 @@ ProxyPreserveHost On
 		Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
 	})
 }
+
+func getRepositoryAttributes(repository maven.Repository) []string {
+	var attributes []string
+	if repository.ID != "" {
+		attributes = append(attributes, "@id="+repository.ID)
+	}
+	if !repository.Releases.Enabled {
+		attributes = append(attributes, "@noreleases")
+	}
+	if repository.Snapshots.Enabled {
+		attributes = append(attributes, "@snapshots")
+	}
+	return attributes
+}