Skip to content

add stable order for smoke tests + restoring client codegen #3265

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

Merged
merged 5 commits into from
Jan 24, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import software.amazon.smithy.codegen.core.Symbol;

import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.Map;
import java.util.List;
import java.util.stream.Collectors;

public final class CppImportContainer implements ImportContainer {

Expand Down Expand Up @@ -81,19 +84,26 @@ public void importSymbol(Symbol symbol, String alias) {
dynamicHeaders.add(containerHeaderMap.get(symbol.getName()));
}
}


private static List<String> setToSortedList(Set<String> set) {
return set.stream()
.sorted(Comparator.comparing(elem -> elem))
.collect(Collectors.toList());
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();

coreHeaders.forEach(
setToSortedList(coreHeaders).forEach(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead you could just use LinkedHashSet type to avoid an extra sort.

elem -> sb.append(String.format("#include <%s>\n",elem))
);

unitTestHeaders.forEach(
setToSortedList(unitTestHeaders).forEach(
elem -> sb.append(String.format("#include <%s>\n",elem))
);
dynamicHeaders.forEach(
setToSortedList(dynamicHeaders).forEach(
elem -> sb.append(String.format("#include <%s>\n",elem))
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import java.util.Comparator;

import software.amazon.smithy.build.PluginContext;
import software.amazon.smithy.aws.smoketests.model.AwsSmokeTestModel;
Expand Down Expand Up @@ -280,6 +281,7 @@ public Map<ServiceShape, List<SmokeTestData> > extractServiceSmokeTests()
filter(operationShape -> operationShape.getInput().isPresent()).
filter(operationShape -> operationShape.getTrait(SmokeTestsTrait.class).isPresent() ).
filter(operationShape -> operationToServiceMap.containsKey(operationShape.getId()) ).
sorted(Comparator.comparing(OperationShape::getId)).
forEach(operationShape -> {
SmokeTestsTrait smokeTestsTrait = operationShape.getTrait(SmokeTestsTrait.class).get();
//get serviceShape
Expand Down
8 changes: 6 additions & 2 deletions tools/scripts/run_code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,13 @@ def collect_available_models(models_dir: str, endpoint_rules_dir: str, legacy_ma
with open(models_dir + "/" + model_file_date[0], 'r') as json_file:
model = json.load(json_file)
#get service id. It has to exist, else continue
if ("metadata" in model and "serviceId" in model["metadata"]):
if ("metadata" in model and (("serviceId" in model["metadata"]) or ("serviceFullName" in model["metadata"])) ):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not according to python pep8 format

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will make it more pythonic

if key not in legacy_mapped_services:
key = model["metadata"]["serviceId"]
if "serviceId" in model["metadata"]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a python-style code.
smth like this

key = model["metadata"].get("serviceId", model["metadata"]["serviceFullName"])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[] usage is valid here because of key check. I can switch to .get() in this case which is indeed less verbose

key = model["metadata"]["serviceId"]
else:
key = model["metadata"]["serviceFullName"]

#convert into smithy case convention
key = key.lower().replace(' ', '-')

Expand Down
Loading