-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add fix for empty url * fix and test maven upload handler * fix and test maven upload handler * fix makefile typo
- Loading branch information
1 parent
49a79ea
commit 4f6c9eb
Showing
20 changed files
with
309 additions
and
73 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
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
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
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
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,123 @@ | ||
package add_test | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
. "github.com/open-component-model/ocm/cmds/ocm/testhelper" | ||
"github.com/open-component-model/ocm/pkg/contexts/ocm" | ||
"github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/localblob" | ||
mavenacc "github.com/open-component-model/ocm/pkg/contexts/ocm/accessmethods/maven" | ||
"github.com/open-component-model/ocm/pkg/maven" | ||
. "github.com/open-component-model/ocm/pkg/testutils" | ||
"strings" | ||
"time" | ||
|
||
"github.com/open-component-model/ocm/pkg/contexts/ocm/repositories/ctf" | ||
"github.com/open-component-model/ocm/pkg/maven/maventest" | ||
) | ||
|
||
const ( | ||
MAVEN_CENTRAL_ADDRESS = "repo.maven.apache.org:443" | ||
MAVEN_CENTRAL = "https://repo.maven.apache.org/maven2/" | ||
MAVEN_GROUP_ID = "maven" | ||
MAVEN_ARTIFACT_ID = "maven" | ||
MAVEN_VERSION = "1.1" | ||
) | ||
|
||
const ARCH = "/tmp/ctf" | ||
const DEST_ARCH = "/tmp/ctf-dest" | ||
const VERSION = "1.0.0" | ||
const COMPONENT = "ocm.software/demo/test" | ||
const OUT = "/tmp/res" | ||
|
||
var _ = Describe("Test Environment", func() { | ||
var env *TestEnv | ||
|
||
BeforeEach(func() { | ||
env = NewTestEnv(TestData(), maventest.TestData("/maven/testdata")) | ||
}) | ||
|
||
AfterEach(func() { | ||
env.Cleanup() | ||
}) | ||
|
||
It("upload maven package from localblob during transfer", func() { | ||
coords := maven.NewCoordinates(maventest.GROUP_ID, maventest.ARTIFACT_ID, maventest.VERSION) | ||
Expect(env.Execute("add", "cv", "-fc", "--file", ARCH, "testdata/components.yaml")).To(Succeed()) | ||
Expect(env.DirExists(ARCH)).To(BeTrue()) | ||
repo := Must(ctf.Open(env, ctf.ACC_READONLY, ARCH, 0, env)) | ||
defer Close(repo) | ||
cv := Must(repo.LookupComponentVersion(COMPONENT, VERSION)) | ||
defer Close(cv) | ||
Expect(len(cv.GetDescriptor().Resources)).To(Equal(1)) | ||
acc := Must(env.OCMContext().AccessSpecForSpec(cv.GetDescriptor().Resources[0].Access)) | ||
Expect(acc.IsLocal(env.OCMContext())).To(BeTrue()) | ||
Expect(acc.(*localblob.AccessSpec).ReferenceName).To(Equal(strings.Join([]string{maventest.GROUP_ID, maventest.ARTIFACT_ID, maventest.VERSION}, ":"))) | ||
|
||
Expect(env.Execute("transfer", "ctf", ARCH, DEST_ARCH, "--uploader", "ocm/mavenArtifact=file://localhost/mavenrepo")).To(Succeed()) | ||
Expect(env.DirExists(DEST_ARCH)).To(BeTrue()) | ||
Expect(env.DirExists("/mavenrepo/" + coords.GavPath())).To(BeTrue()) | ||
mavenrepo := maven.NewFileRepository("/mavenrepo", env.FileSystem()) | ||
Expect(mavenrepo.GavFiles(coords, nil)).To(YAMLEqual(` | ||
sdk-modules-bom-5.7.0-random-content.json: 5 | ||
sdk-modules-bom-5.7.0-random-content.txt: 5 | ||
sdk-modules-bom-5.7.0-sources.jar: 5 | ||
sdk-modules-bom-5.7.0.jar: 5 | ||
sdk-modules-bom-5.7.0.pom: 5`)) | ||
}) | ||
|
||
It("upload maven package from localblob during component composition", func() { | ||
coords := maven.NewCoordinates(maventest.GROUP_ID, maventest.ARTIFACT_ID, maventest.VERSION) | ||
Expect(env.Execute("add", "cv", "-fc", "--file", ARCH, "testdata/components.yaml", "--uploader", "ocm/mavenArtifact=file://localhost/mavenrepo")).To(Succeed()) | ||
Expect(env.DirExists(ARCH)).To(BeTrue()) | ||
repo := Must(ctf.Open(env, ctf.ACC_READONLY, ARCH, 0, env)) | ||
defer Close(repo) | ||
cv := Must(repo.LookupComponentVersion(COMPONENT, VERSION)) | ||
defer Close(cv) | ||
Expect(len(cv.GetDescriptor().Resources)).To(Equal(1)) | ||
acc := Must(env.OCMContext().AccessSpecForSpec(cv.GetDescriptor().Resources[0].Access)) | ||
Expect(acc.IsLocal(env.OCMContext())).To(BeFalse()) | ||
Expect(acc.GetKind()).To(Equal(mavenacc.Type)) | ||
Expect(acc.(*mavenacc.AccessSpec).GAV()).To(Equal(strings.Join([]string{maventest.GROUP_ID, maventest.ARTIFACT_ID, maventest.VERSION}, ":"))) | ||
|
||
Expect(env.DirExists("/mavenrepo/" + coords.GavPath())).To(BeTrue()) | ||
mavenrepo := maven.NewFileRepository("/mavenrepo", env.FileSystem()) | ||
Expect(mavenrepo.GavFiles(coords, nil)).To(YAMLEqual(` | ||
sdk-modules-bom-5.7.0-random-content.json: 5 | ||
sdk-modules-bom-5.7.0-random-content.txt: 5 | ||
sdk-modules-bom-5.7.0-sources.jar: 5 | ||
sdk-modules-bom-5.7.0.jar: 5 | ||
sdk-modules-bom-5.7.0.pom: 5`)) | ||
}) | ||
|
||
Context("maven http repository", func() { | ||
if PingTCPServer(MAVEN_CENTRAL_ADDRESS, time.Second) == nil { | ||
var coords *maven.Coordinates | ||
BeforeEach(func() { | ||
coords = maven.NewCoordinates(MAVEN_GROUP_ID, MAVEN_ARTIFACT_ID, MAVEN_VERSION) | ||
}) | ||
It("upload maven package from access method", func() { | ||
Expect(env.Execute("add", "cv", "-fc", "--file", ARCH, "testdata/components2.yaml")).To(Succeed()) | ||
Expect(env.DirExists(ARCH)).To(BeTrue()) | ||
repo := Must(ctf.Open(env, ctf.ACC_READONLY, ARCH, 0, env)) | ||
defer Close(repo) | ||
cv := Must(repo.LookupComponentVersion(COMPONENT, VERSION)) | ||
defer Close(cv) | ||
Expect(len(cv.GetDescriptor().Resources)).To(Equal(1)) | ||
acc := Must(env.OCMContext().AccessSpecForSpec(cv.GetDescriptor().Resources[0].Access)) | ||
Expect(acc.IsLocal(env.OCMContext())).To(BeFalse()) | ||
Expect(acc.(ocm.HintProvider).GetReferenceHint(cv)).To(Equal(coords.GAV())) | ||
|
||
Expect(env.Execute("transfer", "ctf", ARCH, DEST_ARCH, "--copy-resources", "--uploader", "ocm/mavenArtifact=file://localhost/mavenrepo")).To(Succeed()) | ||
Expect(env.DirExists(DEST_ARCH)).To(BeTrue()) | ||
Expect(env.DirExists("/mavenrepo/" + coords.GavPath())).To(BeTrue()) | ||
mavenrepo := maven.NewFileRepository("/mavenrepo", env.FileSystem()) | ||
Expect(mavenrepo.GavFiles(coords, nil)).To(YAMLEqual(` | ||
maven-1.1-RC1.javadoc.javadoc.jar: 5 | ||
maven-1.1-sources.jar: 5 | ||
maven-1.1.jar: 5 | ||
maven-1.1.pom: 5`)) | ||
}) | ||
} | ||
}) | ||
}) |
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,13 @@ | ||
package add_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestConfig(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "OCM add components") | ||
} |
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 @@ | ||
components: | ||
- name: ocm.software/demo/test | ||
version: 1.0.0 | ||
provider: | ||
name: ocm.software | ||
resources: | ||
- name: mavenartifact | ||
type: mavenArtifact | ||
input: | ||
type: maven | ||
path: /maven/testdata/.m2/repository | ||
groupId: "com.sap.cloud.sdk" | ||
artifactId: "sdk-modules-bom" | ||
version: "5.7.0" |
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,15 @@ | ||
components: | ||
- name: ocm.software/demo/test | ||
version: 1.0.0 | ||
provider: | ||
name: ocm.software | ||
resources: | ||
- name: mavenartifact | ||
type: mavenArtifact | ||
version: "1.1" | ||
access: | ||
type: maven | ||
repoUrl: "https://repo.maven.apache.org/maven2/" | ||
groupId: "maven" | ||
artifactId: "maven" | ||
version: "1.1" |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.