Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi committed Oct 21, 2024
1 parent 04bd24e commit 94b2098
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 111 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/accessTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ jobs:
- name: Setup Go with cache
uses: jfrog/.github/actions/install-go-with-cache@main

- name: Install local Artifactory
uses: jfrog/.github/actions/install-local-artifactory@main
with:
RTLIC: ${{ secrets.RTLIC }}

- name: Run Access tests
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.access --jfrog.url=${{ secrets.PLATFORM_URL }} --jfrog.adminToken=${{ secrets.PLATFORM_ADMIN_TOKEN }} --jfrog.user=${{ secrets.PLATFORM_USER }} --ci.runId=${{ runner.os }}-access
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.access --jfrog.adminToken=$JFROG_TESTS_LOCAL_ACCESS_TOKEN
2 changes: 1 addition & 1 deletion .github/workflows/artifactoryTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
RTLIC: ${{ secrets.RTLIC }}

- name: Run Artifactory tests
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.artifactory
run: go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.artifactory --jfrog.adminToken=$JFROG_TESTS_LOCAL_ACCESS_TOKEN
if: ${{ matrix.suite == 'artifactory' }}

- name: Run Artifactory projects tests
Expand Down
108 changes: 0 additions & 108 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3439,114 +3439,6 @@ func TestArtifactoryDownloadByBuildNoPatternUsingSimpleDownload(t *testing.T) {
cleanArtifactoryTest()
}

func TestArtifactoryDownloadByArchiveEntriesCli(t *testing.T) {
initArtifactoryTest(t, "")
uploadSpecFile, err := tests.CreateSpec(tests.ArchiveEntriesUpload)
assert.NoError(t, err)

// Upload archives
runRt(t, "upload", "--spec="+uploadSpecFile)

// Trigger archive indexing on the repo.
triggerArchiveIndexing(t)

// Create executor for running with retries
retryExecutor := createRetryExecutorForArchiveEntries(tests.GetBuildArchiveEntriesDownloadCli(),
[]string{"dl", tests.RtRepo1, "out/", "--archive-entries=(*)c1.in", "--flat=true"})

// Perform download by archive-entries only the archives containing c1.in, and validate results
assert.NoError(t, retryExecutor.Execute())

// Cleanup
cleanArtifactoryTest()
}

func triggerArchiveIndexing(t *testing.T) {
client, err := httpclient.ClientBuilder().Build()
assert.NoError(t, err)
resp, _, err := client.SendPost(serverDetails.ArtifactoryUrl+"api/archiveIndex/"+tests.RtRepo1, []byte{}, artHttpDetails, "")
if err != nil {
assert.NoError(t, err, "archive indexing failed")
return
}
assert.Equal(t, http.StatusAccepted, resp.StatusCode, "archive indexing failed")
// Indexing buffer
time.Sleep(3 * time.Second)
}

func TestArtifactoryDownloadByArchiveEntriesSpecificPathCli(t *testing.T) {
initArtifactoryTest(t, "")
uploadSpecFile, err := tests.CreateSpec(tests.ArchiveEntriesUpload)
assert.NoError(t, err)

// Upload archives
runRt(t, "upload", "--spec="+uploadSpecFile)

// Trigger archive indexing on the repo.
triggerArchiveIndexing(t)

// Create executor for running with retries
retryExecutor := createRetryExecutorForArchiveEntries(tests.GetBuildArchiveEntriesSpecificPathDownload(),
[]string{"dl", tests.RtRepo1, "out/", "--archive-entries=b/c/c1.in", "--flat=true"})

// Perform download by archive-entries only the archives containing c1.in, and validate results
assert.NoError(t, retryExecutor.Execute())

// Cleanup
cleanArtifactoryTest()
}

func TestArtifactoryDownloadByArchiveEntriesSpec(t *testing.T) {
initArtifactoryTest(t, "")
uploadSpecFile, err := tests.CreateSpec(tests.ArchiveEntriesUpload)
assert.NoError(t, err)
downloadSpecFile, err := tests.CreateSpec(tests.ArchiveEntriesDownload)
assert.NoError(t, err)

// Upload archives
runRt(t, "upload", "--spec="+uploadSpecFile)

// Trigger archive indexing on the repo.
triggerArchiveIndexing(t)

// Create executor for running with retries
retryExecutor := createRetryExecutorForArchiveEntries(tests.GetBuildArchiveEntriesDownloadSpec(),
[]string{"dl", "--spec=" + downloadSpecFile})

// Perform download by archive-entries only the archives containing d1.in, and validate results
assert.NoError(t, retryExecutor.Execute())

// Cleanup
cleanArtifactoryTest()
}

func createRetryExecutorForArchiveEntries(expected []string, args []string) *clientutils.RetryExecutor {
return &clientutils.RetryExecutor{
MaxRetries: 120,
// RetriesIntervalMilliSecs in milliseconds
RetriesIntervalMilliSecs: 1 * 1000,
ErrorMessage: "Waiting for Artifactory to index archives...",
ExecutionHandler: func() (bool, error) {
// Execute the requested cli command
err := artifactoryCli.Exec(args...)
if err != nil {
return true, err
}
err = validateDownloadByArchiveEntries(expected)
if err != nil {
return false, err
}
return false, nil
},
}
}

func validateDownloadByArchiveEntries(expected []string) error {
// Validate files are downloaded as expected
paths, _ := fileutils.ListFilesRecursiveWalkIntoDirSymlink(tests.Out, false)
return tests.ValidateListsIdentical(expected, paths)
}

func TestArtifactoryDownloadExcludeByCli(t *testing.T) {
initArtifactoryTest(t, "")

Expand Down
2 changes: 1 addition & 1 deletion utils/tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var (
)

func init() {
JfrogUrl = flag.String("jfrog.url", "http://localhost:8081/", "JFrog platform url")
JfrogUrl = flag.String("jfrog.url", "http://localhost:8082/", "JFrog platform url")
JfrogUser = flag.String("jfrog.user", "admin", "JFrog platform username")
JfrogPassword = flag.String("jfrog.password", "password", "JFrog platform password")
JfrogSshKeyPath = flag.String("jfrog.sshKeyPath", "", "Ssh key file path")
Expand Down

0 comments on commit 94b2098

Please sign in to comment.