Skip to content

Commit

Permalink
Fix supplier tests for aarch64 (#1586)
Browse files Browse the repository at this point in the history
Because TemplateRenderer.arch defaults to the arch of the system
invoking the tests, when invoked on an aarch64 system, the various
Car instances would throw exceptions 1 because they were
missing the architecture specific build commands added in
elastic/rally-teams#75

This commit fixes the existing tests to default to x86_64,
and adds two new aarch64 tests.
  • Loading branch information
b-deam authored Sep 28, 2022
1 parent ddad4b4 commit 4fbf147
Showing 1 changed file with 39 additions and 3 deletions.
42 changes: 39 additions & 3 deletions tests/mechanic/supplier_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,23 @@ def test_build(self):
variables={"clean_command": "./gradlew clean", "system.build_command": "./gradlew assemble"},
)
builder = mock.create_autospec(supplier.Builder)
renderer = supplier.TemplateRenderer(version="abc")
renderer = supplier.TemplateRenderer(version="abc", arch="x86_64")
es = supplier.ElasticsearchSourceSupplier(
revision="abc", es_src_dir="/src", remote_url="", car=car, builder=builder, template_renderer=renderer
)
es.prepare()

builder.build.assert_called_once_with(["./gradlew clean", "./gradlew assemble"])

def test_build_arm(self):
car = team.Car(
"default",
root_path=None,
config_paths=[],
variables={"clean_command": "./gradlew clean", "system.build_command.arch": "./gradlew assemble"},
)
builder = mock.create_autospec(supplier.Builder)
renderer = supplier.TemplateRenderer(version="abc", arch="aarch64")
es = supplier.ElasticsearchSourceSupplier(
revision="abc", es_src_dir="/src", remote_url="", car=car, builder=builder, template_renderer=renderer
)
Expand All @@ -668,7 +684,7 @@ def test_raises_error_on_missing_car_variable(self):
# system.build_command is not defined
},
)
renderer = supplier.TemplateRenderer(version="abc")
renderer = supplier.TemplateRenderer(version="abc", arch="x86_64")
builder = mock.create_autospec(supplier.Builder)
es = supplier.ElasticsearchSourceSupplier(
revision="abc", es_src_dir="/src", remote_url="", car=car, builder=builder, template_renderer=renderer
Expand All @@ -690,7 +706,27 @@ def test_add_elasticsearch_binary(self):
"system.artifact_path_pattern": "distribution/archives/tar/build/distributions/*.tar.gz",
},
)
renderer = supplier.TemplateRenderer(version="abc")
renderer = supplier.TemplateRenderer(version="abc", arch="x86_64")
es = supplier.ElasticsearchSourceSupplier(
revision="abc", es_src_dir="/src", remote_url="", car=car, builder=None, template_renderer=renderer
)
binaries = {}
es.add(binaries=binaries)
assert binaries == {"elasticsearch": "elasticsearch.tar.gz"}

@mock.patch("glob.glob", lambda p: ["elasticsearch.tar.gz"])
def test_add_elasticsearch_binary_arm(self):
car = team.Car(
"default",
root_path=None,
config_paths=[],
variables={
"clean_command": "./gradlew clean",
"system.build_command.arch": "./gradlew assemble",
"system.artifact_path_pattern.arch": "distribution/archives/tar/build/distributions/*.tar.gz",
},
)
renderer = supplier.TemplateRenderer(version="abc", arch="aarch64")
es = supplier.ElasticsearchSourceSupplier(
revision="abc", es_src_dir="/src", remote_url="", car=car, builder=None, template_renderer=renderer
)
Expand Down

0 comments on commit 4fbf147

Please sign in to comment.