Skip to content
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

Sync timestamp #6575

Merged
merged 8 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion samcli/lib/sync/sync_flow_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
from concurrent.futures import Future, ThreadPoolExecutor
from dataclasses import dataclass
from datetime import datetime
from queue import Queue
from threading import RLock
from typing import Callable, List, Optional, Set
Expand Down Expand Up @@ -311,8 +312,12 @@ def _handle_result(
sync_flow_result: SyncFlowResult = future.result()
for dependent_sync_flow in sync_flow_result.dependent_sync_flows:
self.add_sync_flow(dependent_sync_flow)
message = (
f"{datetime.now().strftime('%d/%b/%Y:%H:%M:%S')}: "
f"Finished syncing {sync_flow_result.sync_flow.log_name}."
)
LOG.info(
self._color.color_log(msg=f"Finished syncing {sync_flow_result.sync_flow.log_name}.", color="green"),
self._color.color_log(msg=message, color="green"),
extra=dict(markup=True),
)
return True
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/sync/test_sync_adl.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_sync_watch_code(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Layer HelloWorldFunction",
"Finished syncing Layer HelloWorldFunction",
timeout=60,
)
lambda_response = json.loads(self._get_lambda_response(lambda_functions[0]))
Expand All @@ -142,7 +142,7 @@ def test_sync_watch_code(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Layer HelloWorldFunction",
"Finished syncing Layer HelloWorldFunction",
timeout=60,
)
self._confirm_lambda_error(lambda_functions[0])
Expand All @@ -154,7 +154,7 @@ def test_sync_watch_code(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
timeout=60,
)

Expand Down
43 changes: 20 additions & 23 deletions tests/integration/sync/test_sync_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_sync_watch_code(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
timeout=45,
)
layer_contents = self.get_dependency_layer_contents_from_arn(self.stack_resources, "python", 2)
Expand All @@ -235,7 +235,7 @@ def test_sync_watch_code(self):
self.test_data_path.joinpath("code", "before", "function", "app.py"),
)
read_until_string(
self.watch_process, "\x1b[32mFinished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=30
self.watch_process, "Finished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=30
)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
for lambda_function in lambda_functions:
Expand All @@ -250,7 +250,7 @@ def test_sync_watch_code(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
timeout=30,
)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
Expand All @@ -264,7 +264,7 @@ def test_sync_watch_code(self):
self.test_data_path.joinpath("code", "after", "apigateway", "definition.json"),
self.test_data_path.joinpath("code", "before", "apigateway", "definition.json"),
)
read_until_string(self.watch_process, "\x1b[32mFinished syncing RestApi HelloWorldApi.\x1b[0m\n", timeout=20)
read_until_string(self.watch_process, "Finished syncing RestApi HelloWorldApi.\x1b[0m\n", timeout=20)
time.sleep(API_SLEEP)
rest_api = self.stack_resources.get(AWS_APIGATEWAY_RESTAPI)[0]
self.assertEqual(self._get_api_message(rest_api), '{"message": "hello 2"}')
Expand All @@ -274,9 +274,7 @@ def test_sync_watch_code(self):
self.test_data_path.joinpath("code", "after", "statemachine", "function.asl.json"),
self.test_data_path.joinpath("code", "before", "statemachine", "function.asl.json"),
)
read_until_string(
self.watch_process, "\x1b[32mFinished syncing StepFunctions HelloStepFunction.\x1b[0m\n", timeout=20
)
read_until_string(self.watch_process, "Finished syncing StepFunctions HelloStepFunction.\x1b[0m\n", timeout=20)
state_machine = self.stack_resources.get(AWS_STEPFUNCTIONS_STATEMACHINE)[0]
time.sleep(SFN_SLEEP)
self.assertEqual(self._get_sfn_response(state_machine), '"World 2"')
Expand Down Expand Up @@ -326,8 +324,7 @@ def test_sync_watch_code_nested_stack(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync "
"LocalNestedChildStack/HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync " "LocalNestedChildStack/HelloWorldFunction.\x1b[0m\n",
timeout=45,
)
layer_contents = self.get_dependency_layer_contents_from_arn(self.stack_resources, "python", 2)
Expand All @@ -340,7 +337,7 @@ def test_sync_watch_code_nested_stack(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Lambda Function LocalNestedChildStack/HelloWorldFunction.\x1b[0m\n",
"Finished syncing Lambda Function LocalNestedChildStack/HelloWorldFunction.\x1b[0m\n",
timeout=30,
)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
Expand All @@ -356,7 +353,7 @@ def test_sync_watch_code_nested_stack(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync LocalNestedChildStack/HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync LocalNestedChildStack/HelloWorldFunction.\x1b[0m\n",
timeout=30,
)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
Expand All @@ -372,7 +369,7 @@ def test_sync_watch_code_nested_stack(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing RestApi LocalNestedChildStack/HelloWorldApi.\x1b[0m\n",
"Finished syncing RestApi LocalNestedChildStack/HelloWorldApi.\x1b[0m\n",
timeout=20,
)
time.sleep(API_SLEEP)
Expand All @@ -386,7 +383,7 @@ def test_sync_watch_code_nested_stack(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing StepFunctions LocalNestedChildStack/HelloStepFunction.\x1b[0m\n",
"Finished syncing StepFunctions LocalNestedChildStack/HelloStepFunction.\x1b[0m\n",
timeout=20,
)
state_machine = self.stack_resources.get(AWS_STEPFUNCTIONS_STATEMACHINE)[0]
Expand All @@ -413,7 +410,7 @@ def test_sync_watch_code(self):
self.test_data_path.joinpath("code", "before", "esbuild_function", "app.ts"),
)
read_until_string(
self.watch_process, "\x1b[32mFinished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=30
self.watch_process, "Finished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=30
)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
for lambda_function in lambda_functions:
Expand Down Expand Up @@ -473,7 +470,7 @@ def test_sync_watch_code(self):
self.test_data_path.joinpath("code", "before", "function", "requirements.txt"),
)
read_until_string(
self.watch_process, "\x1b[32mFinished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=45
self.watch_process, "Finished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=45
)

lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
Expand Down Expand Up @@ -521,7 +518,7 @@ def test_sync_watch_code(self):
tags="integ=true clarity=yes foo_bar=baz",
)
self.watch_process = start_persistent_process(sync_command_list, cwd=self.test_data_path)
read_until_string(self.watch_process, "\x1b[32mSync watch started.\x1b[0m\n", timeout=30)
read_until_string(self.watch_process, "Sync watch started.\x1b[0m\n", timeout=30)

self.stack_resources = self._get_stacks(self.stack_name)

Expand All @@ -535,7 +532,7 @@ def test_sync_watch_code(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
timeout=45,
)
layer_contents = self.get_dependency_layer_contents_from_arn(self.stack_resources, "python", 2)
Expand All @@ -547,7 +544,7 @@ def test_sync_watch_code(self):
self.test_data_path.joinpath("code", "before", "function", "app.py"),
)
read_until_string(
self.watch_process, "\x1b[32mFinished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=30
self.watch_process, "Finished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=30
)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
for lambda_function in lambda_functions:
Expand All @@ -562,7 +559,7 @@ def test_sync_watch_code(self):
)
read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
timeout=30,
)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
Expand Down Expand Up @@ -679,7 +676,7 @@ def test_sync_watch_auto_skip_infra(self):
self.watch_process = start_persistent_process(sync_command_list, cwd=self.test_dir)

read_until_string(
self.watch_process, "\x1b[32mFinished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=100
self.watch_process, "Finished syncing Lambda Function HelloWorldFunction.\x1b[0m\n", timeout=100
)

kill_process(self.watch_process)
Expand Down Expand Up @@ -714,7 +711,7 @@ def test_sync_watch_auto_skip_infra(self):

read_until_string(
self.watch_process,
"\x1b[32mFinished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
"Finished syncing Function Layer Reference Sync HelloWorldFunction.\x1b[0m\n",
timeout=100,
)

Expand Down Expand Up @@ -749,7 +746,7 @@ def test_sync_watch_auto_skip_infra(self):

read_until_string(
self.watch_process,
"\x1b[32mFinished syncing RestApi HelloWorldApi.\x1b[0m\n",
"Finished syncing RestApi HelloWorldApi.\x1b[0m\n",
timeout=100,
)
time.sleep(API_SLEEP)
Expand Down Expand Up @@ -781,7 +778,7 @@ def test_sync_watch_auto_skip_infra(self):

read_until_string(
self.watch_process,
"\x1b[32mFinished syncing StepFunctions HelloStepFunction.\x1b[0m\n",
"Finished syncing StepFunctions HelloStepFunction.\x1b[0m\n",
timeout=100,
)
time.sleep(SFN_SLEEP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Resources:
Properties:
CodeUri: makefile_function_create_new_file/
Handler: main.handler
Runtime: python3.7
Runtime: python3.11
Layers:
- !Ref HelloWorldLayer
Metadata:
Expand All @@ -22,6 +22,6 @@ Resources:
Properties:
ContentUri: makefile_layer_create_new_file/
CompatibleRuntimes:
- python3.7
- python3.11
Metadata:
BuildMethod: makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Resources:
Properties:
CodeUri: function/
Handler: app.lambda_handler
Runtime: python3.7
Runtime: python3.11
Layers:
- Ref: HelloWorldLayer
Tracing: Active
Expand All @@ -32,7 +32,7 @@ Resources:
Properties:
CodeUri: function/
Handler: app.lambda_handler
Runtime: python3.7
Runtime: python3.11
Layers:
- Ref: HelloWorldLayerWithoutBuildMethod
Tracing: Active
Expand All @@ -42,7 +42,7 @@ Resources:
Properties:
CodeUri: function/
Handler: app.lambda_handler
Runtime: python3.7
Runtime: python3.11
Layers:
- Ref: HelloWorldPreBuiltZipLayer
Tracing: Active
Expand All @@ -54,9 +54,9 @@ Resources:
Description: Hello World Layer
ContentUri: layer/
CompatibleRuntimes:
- python3.7
- python3.11
Metadata:
BuildMethod: python3.7
BuildMethod: python3.11

HelloWorldLayerWithoutBuildMethod:
Type: AWS::Serverless::LayerVersion
Expand All @@ -65,7 +65,7 @@ Resources:
Description: Hello World Layer without BuildMethod
ContentUri: layer_without_build_method/
CompatibleRuntimes:
- python3.7
- python3.11

HelloWorldPreBuiltZipLayer:
Type: AWS::Serverless::LayerVersion
Expand All @@ -74,7 +74,7 @@ Resources:
Description: Hello World Layer which is pre-built as ZIP file
ContentUri: layer_zip/layer.zip
CompatibleRuntimes:
- python3.7
- python3.11

HelloStepFunction:
Type: AWS::Serverless::StateMachine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Resources:
Properties:
CodeUri: function/
Handler: app.lambda_handler
Runtime: python3.7
Runtime: python3.11
Layers:
- Ref: HelloWorldLayer
Tracing: Active
Expand All @@ -28,6 +28,6 @@ Resources:
Description: Hello World Layer
ContentUri: layer/
CompatibleRuntimes:
- python3.7
- python3.11
Metadata:
BuildMethod: python3.7
BuildMethod: python3.11
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Resources:
Properties:
CodeUri: python_function_no_deps/
Handler: app.lambda_handler
Runtime: python3.7
Runtime: python3.11
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Resources:
Properties:
CodeUri: function/
Handler: app.lambda_handler
Runtime: python3.7
Runtime: python3.11
Layers:
- Ref: HelloWorldLayer
Tracing: Active
Expand All @@ -40,9 +40,9 @@ Resources:
Description: Hello World Layer
ContentUri: layer/
CompatibleRuntimes:
- python3.7
- python3.11
Metadata:
BuildMethod: python3.7
BuildMethod: python3.11

HelloStepFunction:
Type: AWS::Serverless::StateMachine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@
"CompatibleRuntimes": [
"python3.7",
"python3.8",
"python3.9"
"python3.9",
"python3.11"
]
},
"Metadata": {
"aws:cdk:path": "CDKV1SupportDemoStack/CountriesLibLayer/Resource",
"aws:asset:path": "before/asset.b998895901bf33127f2c9dce715854f8b35aa73fb7eb5245ba9721580bbe6948",
"aws:asset:is-bundled": false,
"aws:asset:property": "Content",
"BuildMethod": "python3.7"
"BuildMethod": "python3.11"
}
},
"RandomCitiesFunctionServiceRole4EFB1CF5": {
Expand Down Expand Up @@ -142,7 +143,7 @@
"Ref": "CountriesLibLayer259A7AF1"
}
],
"Runtime": "python3.7"
"Runtime": "python3.11"
},
"DependsOn": [
"RandomCitiesFunctionServiceRole4EFB1CF5"
Expand Down
Loading
Loading