From 94b20989f8ac08db5f8c6e8ea4bddebcb48ffd2f Mon Sep 17 00:00:00 2001 From: yahavi Date: Sun, 20 Oct 2024 09:00:56 +0300 Subject: [PATCH] Fix tests --- .github/workflows/accessTests.yml | 7 +- .github/workflows/artifactoryTests.yml | 2 +- artifactory_test.go | 108 ------------------------- utils/tests/utils.go | 2 +- 4 files changed, 8 insertions(+), 111 deletions(-) diff --git a/.github/workflows/accessTests.yml b/.github/workflows/accessTests.yml index c4e863b4d..26d2eac7f 100644 --- a/.github/workflows/accessTests.yml +++ b/.github/workflows/accessTests.yml @@ -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 diff --git a/.github/workflows/artifactoryTests.yml b/.github/workflows/artifactoryTests.yml index 304ffebb9..eb8327db2 100644 --- a/.github/workflows/artifactoryTests.yml +++ b/.github/workflows/artifactoryTests.yml @@ -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 diff --git a/artifactory_test.go b/artifactory_test.go index 4269dcc85..9ab9cd2b1 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -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, "") diff --git a/utils/tests/utils.go b/utils/tests/utils.go index 91f3cdd6b..5babf5a10 100644 --- a/utils/tests/utils.go +++ b/utils/tests/utils.go @@ -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")