Files
o3de/AutomatedTesting/Levels/AWS/Metrics/Script/Metrics.lua
T
amzn-hdoke 04f6c7b90f Enable AWSI Automation Tests (#1330)
* Add AWS AutomatedTesting levels

* Update AWSCoreConfiguration to use default profile

* Update lambda name

* Add cdk update command before tests run

* Update global cdk version before runnign tests.

* Add npm update command

* More cdk changes

* More cdk changes

* Shortening project names for cdk

* increase timeout for AWSTests

* Add comments

* Set AWSTests to periodic test suite

* Update logic to re install cdk and deploy bootstrap

* change version to list to catch version mismatch

* Move AWS fixtures to module directory scope

* Fixing issues with cdk utils

* Add cdk setup to be called on cdk fixture function
2021-06-18 12:39:02 -07:00

80 lines
2.8 KiB
Lua

----------------------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
local metrics = {
}
function metrics:OnActivate()
self.tickTime = 0
self.numSubmittedMetricsEvents = 0
self.tickBusHandler = TickBus.Connect(self,self.entityId)
self.metricsNotificationHandler = AWSMetricsNotificationBus.Connect(self, self.entityId)
LyShineLua.ShowMouseCursor(true)
end
function metrics:OnSendMetricsSuccess(requestId)
Debug.Log("Metrics is sent successfully.")
end
function metrics:OnSendMetricsFailure(requestId, errorMessage)
Debug.Log("Failed to send metrics.")
end
function metrics:OnDeactivate()
AWSMetricsRequestBus.Broadcast.FlushMetrics()
Debug.Log("Stop generating new test events and flushed the buffered metrics.")
self.tickBusHandler:Disconnect()
self.metricsNotificationHandler:Disconnect()
end
function metrics:OnTick(deltaTime, timePoint)
self.tickTime = self.tickTime + deltaTime
if self.tickTime > 2.0 then
defaultAttribute = AWSMetrics_MetricsAttribute()
defaultAttribute:SetName("event_name")
defaultAttribute:SetStrValue("login")
customAttribute = AWSMetrics_MetricsAttribute()
customAttribute:SetName("custom_attribute")
customAttribute:SetStrValue("value")
attributeList = AWSMetrics_AttributesSubmissionList()
attributeList.attributes:push_back(defaultAttribute)
attributeList.attributes:push_back(customAttribute)
if self.numSubmittedMetricsEvents % 2 == 0 then
if AWSMetricsRequestBus.Broadcast.SubmitMetrics(attributeList.attributes, 0, "lua", false) then
Debug.Log("Submitted metrics without buffer.")
else
Debug.Log("Failed to Submit metrics without buffer.")
end
else
if AWSMetricsRequestBus.Broadcast.SubmitMetrics(attributeList.attributes, 0, "lua", true) then
Debug.Log("Submitted metrics with buffer.")
else
Debug.Log("Failed to Submit metrics with buffer.")
end
end
self.numSubmittedMetricsEvents = self.numSubmittedMetricsEvents + 1
self.tickTime = 0
end
end
return metrics