-
Notifications
You must be signed in to change notification settings - Fork 916
Add version compatibility test #6197
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
Open
RanVaknin
wants to merge
7
commits into
master
Choose a base branch
from
rvaknin/add-version-compatibility-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or 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
1ea5897
to
8093298
Compare
8093298
to
f90abc1
Compare
|
RanVaknin
commented
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think generating a fixture test for a code generated test might be overkill, but for better readability here is what this generated test would look like for SQS:
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.sqs;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.util.VersionInfo;
import software.amazon.awssdk.services.sqs.internal.ServiceVersionInfo;
@Generated("software.amazon.awssdk:codegen")
public class VersionCompatibilityTest {
@Test
public void checkCompatibility() {
String coreVersion = VersionInfo.SDK_VERSION;
String serviceVersion = ServiceVersionInfo.VERSION;
Assertions
.assertThat(isVersionCompatible(coreVersion, serviceVersion))
.withFailMessage("Core version %s must be equal to or newer than service version %s", coreVersion, serviceVersion)
.isTrue();
}
private boolean isVersionCompatible(String coreVersion, String serviceVersion) {
String normalizedCore = coreVersion.replace("-SNAPSHOT", "");
String normalizedService = serviceVersion.replace("-SNAPSHOT", "");
String[] coreParts = normalizedCore.split("\\.");
String[] serviceParts = normalizedService.split("\\.");
int coreMajor = Integer.parseInt(coreParts[0]);
int serviceMajor = Integer.parseInt(serviceParts[0]);
if (coreMajor != serviceMajor) {
return coreMajor >= serviceMajor;
}
int coreMinor = Integer.parseInt(coreParts[1]);
int serviceMinor = Integer.parseInt(serviceParts[1]);
if (coreMinor != serviceMinor) {
return coreMinor >= serviceMinor;
}
int corePatch = Integer.parseInt(coreParts[2]);
int servicePatch = Integer.parseInt(serviceParts[2]);
return corePatch >= servicePatch;
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Generating build time testing for internal consumers that might consume mixed versions of sdk-core and services.
The PR has two main additions:
ServiceVersionInfo.VERSION
.sdk-core
and the service version.