Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip downgrade test when only one snapshot version is available #3293

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
make teat work with only one snapshot version
It fixes TestStandaloneUpgradeToSpecificSnapshotBuild to work is there is only one snapshot build available.
  • Loading branch information
AndersonQ committed Aug 25, 2023
commit 8a19380b2373f2da04d5cd88cdf9e1806655ec4a
9 changes: 5 additions & 4 deletions pkg/testing/tools/artifacts_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
artifactsAPIV1VersionsEndpoint = "v1/versions/"
artifactsAPIV1VersionBuildsEndpoint = "v1/versions/%s/builds/"
artifactAPIV1BuildDetailsEndpoint = "v1/versions/%s/builds/%s"
//artifactAPIV1SearchVersionPackage = "v1/search/%s/%s"
// artifactAPIV1SearchVersionPackage = "v1/search/%s/%s"
)

var (
Expand Down Expand Up @@ -275,9 +275,10 @@ func GetLatestSnapshotVersion(ctx context.Context, log logger, aac *ArtifactAPIC
return nil, ErrSnapshotVersionsEmpty
}

// normally the output of the versions returned by artifact API is already sorted in ascending order,
// if we want to sort in descending order we could use
sort.Sort(sort.Reverse(sortedParsedVersions))
// normally the output of the versions returned by artifact API is already
// sorted in ascending order.If we want to sort in descending order we can
// use sort.Reverse.
sort.Sort(sortedParsedVersions)

var latestSnapshotVersion *version.ParsedSemVer
// fetch the latest SNAPSHOT build
Expand Down
11 changes: 6 additions & 5 deletions testing/integration/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ func TestStandaloneUpgradeToSpecificSnapshotBuild(t *testing.T) {
t.Skipf("Version %s is lower than min version %s", define.Version(), minVersion)
}

// prepare the agent fixture
agentFixture, err := define.NewFixture(t, define.Version())
require.NoError(t, err)

Expand All @@ -293,11 +292,13 @@ func TestStandaloneUpgradeToSpecificSnapshotBuild(t *testing.T) {
// get all the builds of the snapshot version (need to pass x.y.z-SNAPSHOT format)
builds, err := aac.GetBuildsForVersion(ctx, latestSnapshotVersion.VersionWithPrerelease())
require.NoError(t, err)
// TODO if we don't have at least 2 builds, select the next older snapshot build
require.Greater(t, len(builds.Builds), 1)

// take the penultimate build of the snapshot (the builds are ordered from most to least recent)
upgradeVersionString := builds.Builds[1]
upgradeVersionString := builds.Builds[0]
if len(builds.Builds) > 2 {
// if ther is more than 1 build, take the penultimate build of the
// snapshot (the builds are ordered from most to least recent)
upgradeVersionString = builds.Builds[1]
}

t.Logf("Targeting build %q of version %q", upgradeVersionString, latestSnapshotVersion)

Expand Down