-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding common params into all the events if not present & other changes
1. Added "in" support for TelemetryEvent for easier code check. Also added complementary tests for the same. 2. Updated the tests in test_monitor to reflect newer sysinfo fields added. 3. Added comments to describe the decisions behind the field decisions.
- Loading branch information
Showing
7 changed files
with
184 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,49 @@ | ||
# Copyright 2019 Microsoft Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# Requires Python 2.6+ and Openssl 1.0+ | ||
# | ||
from azurelinuxagent.common.telemetryevent import TelemetryEvent, TelemetryEventParam | ||
from tests.tools import AgentTestCase | ||
|
||
|
||
def get_test_event(name="DummyExtension", op="Unknown", is_success=True, duration=0, version="foo", evt_type="", is_internal=False, | ||
message="DummyMessage", eventId=1): | ||
event = TelemetryEvent(eventId, "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX") | ||
event.parameters.append(TelemetryEventParam('Name', name)) | ||
event.parameters.append(TelemetryEventParam('Version', str(version))) | ||
event.parameters.append(TelemetryEventParam('IsInternal', is_internal)) | ||
event.parameters.append(TelemetryEventParam('Operation', op)) | ||
event.parameters.append(TelemetryEventParam('OperationSuccess', is_success)) | ||
event.parameters.append(TelemetryEventParam('Message', message)) | ||
event.parameters.append(TelemetryEventParam('Duration', duration)) | ||
event.parameters.append(TelemetryEventParam('ExtensionType', evt_type)) | ||
return event | ||
|
||
|
||
class TestTelemetryEvent(AgentTestCase): | ||
def test_contains_works_for_TelemetryEvent(self): | ||
test_event = get_test_event(message="Dummy Event") | ||
|
||
self.assertTrue('Name' in test_event) | ||
self.assertTrue('Version' in test_event) | ||
self.assertTrue('IsInternal' in test_event) | ||
self.assertTrue('Operation' in test_event) | ||
self.assertTrue('OperationSuccess' in test_event) | ||
self.assertTrue('Message' in test_event) | ||
self.assertTrue('Duration' in test_event) | ||
self.assertTrue('ExtensionType' in test_event) | ||
|
||
self.assertFalse('GAVersion' in test_event) | ||
self.assertFalse('ContainerId' in test_event) |
This file contains 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,26 @@ | ||
<Data> | ||
<Provider id="69B669B9-4AF8-4C50-BDC4-6006FA76E975"/> | ||
<Event id="1"/> | ||
<Param Name="OperationSuccess" Value="True" T="mt:bool"/> | ||
<Param Name="Processors" Value="0" T="mt:uint64"/> | ||
<Param Name="OpcodeName" Value="10101010" T="mt:wstr"/> | ||
<Param Name="Version" Value="1.4.1.0" T="mt:wstr"/> | ||
<Param Name="RoleName" Value="" T="mt:wstr"/> | ||
<Param Name="IsInternal" Value="False" T="mt:bool"/> | ||
<Param Name="RAM" Value="0" T="mt:uint64"/> | ||
<Param Name="ExecutionMode" Value="IAAS" T="mt:wstr"/> | ||
<Param Name="RoleInstanceName" Value="" T="mt:wstr"/> | ||
<Param Name="Name" Value="CustomScript" T="mt:wstr"/> | ||
<Param Name="Message" Value="(01302)Script is finished. ---stdout--- hello ---errout--- " | ||
T="mt:wstr"/> | ||
<Param Name="OSVersion" Value="" T="mt:wstr"/> | ||
<Param Name="Operation" Value="RunScript" T="mt:wstr"/> | ||
<Param Name="GAVersion" Value="WALinuxAgent-2.2.44" T="mt:wstr"/> | ||
<Param Name="TenantName" Value="" T="mt:wstr"/> | ||
<Param Name="Duration" Value="0" T="mt:uint64"/> | ||
<Param Name="ExtensionType" Value="" T="mt:wstr"/> | ||
<Param Name="EventTid" Value="140240309798656" T="mt:uint64"/> | ||
<Param Name="EventPid" Value="108573" T="mt:uint64"/> | ||
<Param Name="TaskName" Value="MonitorHandler" T="mt:wstr"/> | ||
<Param Name="KeywordName" Value="" T="mt:wstr"/> | ||
</Data> |
This file contains 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 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