Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh committed Dec 11, 2023
1 parent e660196 commit c5315cb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 9 deletions.
18 changes: 9 additions & 9 deletions manifests/2.12.0/opensearch-2.12.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ components:
checks:
- gradle:properties:version
- gradle:dependencies:opensearch.version: opensearch-ml-plugin
- name: neural-search
repository: https://github.com/opensearch-project/neural-search.git
ref: 2.x
platforms:
- linux
- windows
checks:
- gradle:properties:version
- gradle:dependencies:opensearch.version
# - name: neural-search

Check warning on line 53 in manifests/2.12.0/opensearch-2.12.0.yml

View workflow job for this annotation

GitHub Actions / yaml-lint

53:1 [comments-indentation] comment not indented like content
# repository: https://github.com/opensearch-project/neural-search.git
# ref: 2.x
# platforms:
# - linux
# - windows
# checks:
# - gradle:properties:version
# - gradle:dependencies:opensearch.version
- name: flow-framework
repository: https://github.com/opensearch-project/flow-framework.git
ref: 2.x
Expand Down
57 changes: 57 additions & 0 deletions tests/tests_build_workflow/test_build_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ def __mock(self, snapshot: bool = True) -> BuildRecorder:
)
)

def __mock_with_manifest(self, snapshot: bool = True) -> BuildRecorder:
build_manifest_path = os.path.join("tests", "tests_build_workflow", "data", "opensearch-build-tar-2.12.0.yml")
build_manifest_data = BuildManifest.from_path(build_manifest_path).__to_dict__()
return BuildRecorder(
BuildTarget(
build_id="1",
output_dir="output_dir",
name="OpenSearch",
version="1.3.0",
platform="linux",
architecture="x64",
snapshot=snapshot,
),
build_manifest_data
)

def __mock_distribution(self, snapshot: bool = True) -> BuildRecorder:
return BuildRecorder(
BuildTarget(
Expand Down Expand Up @@ -229,3 +245,44 @@ def test_record_artifact_check_plugin_version_properties_snapshot(self, mock_plu
mock_plugin_check.assert_called()
mock_copyfile.assert_called()
mock_makedirs.assert_called()

@patch("shutil.copyfile")
@patch("os.makedirs")
def test_append_component_with_existing_manifest(self, mock_makedirs: Mock, mock_copyfile: Mock) -> None:
mock = self.__mock_with_manifest(snapshot=False)

self.assertEqual(mock.build_manifest.components_hash.get("job-scheduler").get("commit_id"), "aaf09b0211df15dd74ff2756f2590c360b03486b")
self.assertEqual(mock.build_manifest.components_hash.get("geospatial").get("commit_id"), "8776900f2f26312b4d3a08e4343f3e3f7bdde536")
self.assertEqual(mock.build_manifest.components_hash.get("geospatial").get("repository"), "https://github.com/opensearch-project/geospatial.git")
self.assertEqual(mock.build_manifest.components_hash.get("security").get("commit_id"), "e3c8902dea26fd20f56a6f144042b2623f652e3e")
self.assertEqual(mock.build_manifest.components_hash.get("security").get("version"), "2.12.0.0")

mock.record_component(
"job-scheduler",
MagicMock(
url="https://github.com/opensearch-project/job-scheduler.git",
ref="2.12",
sha="mockcommitid",
),
)

self.assertEqual(mock.build_manifest.components_hash.get("job-scheduler").get("commit_id"), "mockcommitid")
self.assertEqual(mock.build_manifest.components_hash.get("job-scheduler").get("ref"), "2.12")
self.assertEqual(mock.build_manifest.components_hash.get("job-scheduler").get("repository"), "https://github.com/opensearch-project/job-scheduler.git")
self.assertEqual(mock.build_manifest.components_hash.get("geospatial").get("commit_id"), "8776900f2f26312b4d3a08e4343f3e3f7bdde536")
self.assertEqual(mock.build_manifest.components_hash.get("security").get("commit_id"), "e3c8902dea26fd20f56a6f144042b2623f652e3e")
#
# recorder.record_component(
# "common-utils",
# MagicMock(
# url="https://github.com/opensearch-project/common-utils",
# ref="main",
# sha="3913d7097934cbfe1fdcf919347f22a597d00b76",
# ),
# )
#
# recorder.record_artifact("common-utils", "files", os.path.join("..", "file1.jar"), __file__)
#
# output_dir = os.path.join("output_dir", "..")
# mock_makedirs.assert_called_with(output_dir, exist_ok=True)
# mock_copyfile.assert_called_with(__file__, os.path.join(output_dir, "file1.jar"))

0 comments on commit c5315cb

Please sign in to comment.