generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Implement FEATURE_BUNDLE_1 RFC 0004 #204
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
23 changes: 23 additions & 0 deletions
23
test/openjd/cli/templates/feature_bundle_1_amount_minmax.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 Amount Min Max | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| parameterDefinitions: | ||
| - name: CpuMin | ||
| type: INT | ||
| default: 1 | ||
| - name: CpuMax | ||
| type: INT | ||
| default: 4 | ||
| steps: | ||
| - name: TestStep | ||
| hostRequirements: | ||
| amounts: | ||
| - name: amount.worker.vcpu | ||
| min: "{{Param.CpuMin}}" | ||
| max: "{{Param.CpuMax}}" | ||
| script: | ||
| actions: | ||
| onRun: | ||
| command: bash | ||
| args: ["-c", "echo 'Amount min/max works!'"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 Bash Syntax Sugar | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: BashStep | ||
| bash: | ||
| script: | | ||
| echo "Hello from Bash!" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 Cmd Syntax Sugar | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: CmdStep | ||
| cmd: | ||
| script: | | ||
| echo Hello from Cmd! |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 EndOfLine AUTO | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: EOLStep | ||
| script: | ||
| embeddedFiles: | ||
| - name: TestFile | ||
| type: TEXT | ||
| filename: test_eol.txt | ||
| data: "line1\nline2\nline3" | ||
| endOfLine: AUTO | ||
| actions: | ||
| onRun: | ||
| command: bash | ||
| args: ["-c", "cat '{{Task.File.TestFile}}' | xxd"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 EndOfLine CRLF | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: EOLStep | ||
| script: | ||
| embeddedFiles: | ||
| - name: TestFile | ||
| type: TEXT | ||
| filename: test_eol.txt | ||
| data: "line1\nline2\nline3" | ||
| endOfLine: CRLF | ||
| actions: | ||
| onRun: | ||
| command: bash | ||
| args: ["-c", "cat '{{Task.File.TestFile}}' | xxd"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 EndOfLine LF | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: EOLStep | ||
| script: | ||
| embeddedFiles: | ||
| - name: TestFile | ||
| type: TEXT | ||
| filename: test_eol.txt | ||
| data: "line1\nline2\nline3" | ||
| endOfLine: LF | ||
| actions: | ||
| onRun: | ||
| command: bash | ||
| args: ["-c", "cat '{{Task.File.TestFile}}' | xxd"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 Extended Step Name | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: ThisIsAVeryLongStepNameThatExceedsTheSixtyFourCharacterLimitButIsAllowedWithFeatureBundle1Extension | ||
| script: | ||
| actions: | ||
| onRun: | ||
| command: bash | ||
| args: ["-c", "echo 'Long step name works!'"] |
18 changes: 18 additions & 0 deletions
18
test/openjd/cli/templates/feature_bundle_1_notify_period.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 Notify Period | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| parameterDefinitions: | ||
| - name: NotifyPeriod | ||
| type: INT | ||
| default: 2 | ||
| steps: | ||
| - name: TestStep | ||
| script: | ||
| actions: | ||
| onRun: | ||
| command: bash | ||
| args: ["-c", "echo 'Notify period works!'"] | ||
| cancelation: | ||
| mode: NOTIFY_THEN_TERMINATE | ||
| notifyPeriodInSeconds: "{{Param.NotifyPeriod}}" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 PowerShell Syntax Sugar | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: PowerShellStep | ||
| powershell: | ||
| script: | | ||
| Write-Host "Hello from PowerShell!" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 Python Syntax Sugar | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| steps: | ||
| - name: PythonStep | ||
| python: | ||
| script: | | ||
| print("Hello from Python!") |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| specificationVersion: jobtemplate-2023-09 | ||
| name: FB1 Format String Timeout | ||
| extensions: | ||
| - FEATURE_BUNDLE_1 | ||
| parameterDefinitions: | ||
| - name: Timeout | ||
| type: INT | ||
| default: 5 | ||
| steps: | ||
| - name: TimeoutStep | ||
| script: | ||
| actions: | ||
| onRun: | ||
| command: bash | ||
| args: ["-c", "echo Running with timeout {{Param.Timeout}}s; sleep 1"] | ||
| timeout: "{{Param.Timeout}}" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
|
|
||
| """Tests for FEATURE_BUNDLE_1 extension support in the CLI.""" | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from . import run_openjd_cli_main | ||
|
|
||
| TEMPLATES_DIR = Path(__file__).parent / "templates" | ||
|
|
||
|
|
||
| class TestFeatureBundle1: | ||
| """Tests for FEATURE_BUNDLE_1 extension features.""" | ||
|
|
||
| def test_python_syntax_sugar(self, capsys) -> None: | ||
| """Test that Python syntax sugar works.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_python.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Hello from Python!" in outerr.out | ||
|
|
||
| def test_bash_syntax_sugar(self, capsys) -> None: | ||
| """Test that Bash syntax sugar works.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_bash.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Hello from Bash!" in outerr.out | ||
|
|
||
| @pytest.mark.skipif(os.name != "nt", reason="PowerShell only available on Windows") | ||
| def test_powershell_syntax_sugar(self, capsys) -> None: | ||
| """Test that PowerShell syntax sugar works.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_powershell.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Hello from PowerShell!" in outerr.out | ||
|
|
||
| @pytest.mark.skipif(os.name != "nt", reason="cmd only available on Windows") | ||
| def test_cmd_syntax_sugar(self, capsys) -> None: | ||
| """Test that cmd syntax sugar works.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_cmd.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Hello from Cmd!" in outerr.out | ||
|
|
||
| def test_format_string_timeout(self, capsys) -> None: | ||
| """Test that format string timeout is resolved.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_timeout.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Running with timeout 5s" in outerr.out | ||
|
|
||
| def test_format_string_amount_minmax(self, capsys) -> None: | ||
| """Test that format string min/max in AmountRequirement is resolved.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_amount_minmax.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Amount min/max works!" in outerr.out | ||
|
|
||
| def test_format_string_notify_period(self, capsys) -> None: | ||
| """Test that format string notifyPeriodInSeconds is resolved.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_notify_period.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Notify period works!" in outerr.out | ||
|
|
||
| def test_extended_step_name(self, capsys) -> None: | ||
| """Test that extended step names (>64 chars) work with extension.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_long_name.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| assert "Long step name works!" in outerr.out | ||
|
|
||
| def test_end_of_line_lf(self, capsys) -> None: | ||
| """Test that endOfLine: LF produces LF-only line endings.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_eol_lf.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| # xxd output: 0a is LF, no 0d (CR) present | ||
| assert "310a 6c69 6e65 320a 6c69" in outerr.out # line1<LF>line2<LF>line | ||
|
|
||
| def test_end_of_line_crlf(self, capsys) -> None: | ||
| """Test that endOfLine: CRLF produces CRLF line endings.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_eol_crlf.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| # xxd output: 0d0a is CRLF | ||
| assert "310d 0a6c 696e 6532 0d0a" in outerr.out # line1<CRLF>line2<CRLF> | ||
|
|
||
| def test_end_of_line_auto(self, capsys) -> None: | ||
| """Test that endOfLine: AUTO produces platform-native line endings.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_eol_auto.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["run", str(template)], expected_exit_code=0) | ||
| if os.name == "nt": | ||
| assert "310d 0a6c 696e 6532 0d0a" in outerr.out # CRLF on Windows | ||
| else: | ||
| assert "310a 6c69 6e65 320a 6c69" in outerr.out # LF on POSIX | ||
|
|
||
| def test_check_validates_extension(self, capsys) -> None: | ||
| """Test that check command validates templates with extension.""" | ||
| template = TEMPLATES_DIR / "feature_bundle_1_python.yaml" | ||
| outerr = run_openjd_cli_main(capsys, args=["check", str(template)], expected_exit_code=0) | ||
| assert "passes validation checks" in outerr.out | ||
Oops, something went wrong.
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.
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.
This works, but I think it feels more "correct" to have the test ensure the task actually times out, so we know for sure OpenJD is using the parametrized
timeoutproperty to set the task timeout.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.
It's a nice idea, but it would also make the tests slower. This may be something to test in openjd-sessions instead?