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

Add tests for extension workflow #2843

Merged
merged 140 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 138 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
da72c37
Update version to dummy 1.0.0.0'
maddieford Nov 8, 2022
59dbd22
Revert version change
maddieford Nov 8, 2022
633a826
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Nov 21, 2022
14a743f
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Dec 8, 2022
54ea0f3
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Jan 10, 2023
e79c4c5
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Feb 8, 2023
498b612
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Feb 14, 2023
1e269f4
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Mar 13, 2023
7b49e76
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Mar 24, 2023
0a426cc
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Apr 6, 2023
17fbf6a
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Apr 7, 2023
995cbb9
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Apr 13, 2023
eaadc83
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Apr 24, 2023
fb03e07
Merge remote-tracking branch 'upstream/develop' into develop
maddieford Apr 27, 2023
6a8e0d6
Merge remote-tracking branch 'upstream/develop' into develop
maddieford May 19, 2023
8e62c05
Basic structure
maddieford May 19, 2023
9999aef
Test must run in SCUS for test ext
maddieford May 19, 2023
9d6cb62
Add GuestAgentDCRTest Extension id
maddieford May 22, 2023
e7c010c
Test stucture
maddieford May 22, 2023
193662b
Update test file name
maddieford May 22, 2023
bf7fc04
test no location
maddieford May 22, 2023
f7f7a54
Test location as southcentralus
maddieford May 22, 2023
5aad0ac
Assert ext is installed
maddieford May 22, 2023
acd4ae5
Try changing version for dcr test ext
maddieford May 22, 2023
1fc51a1
Update expected message in instance view
maddieford May 22, 2023
7b43af7
try changing message to string
maddieford May 22, 2023
11b73e0
Limit images for ext workflow
maddieford May 22, 2023
d8c1d21
Merge in virtual_machine_client changes
maddieford May 23, 2023
6cf987a
Update classes after refactor
maddieford Jun 2, 2023
4b56360
Update class name
maddieford Jun 2, 2023
bda8708
Refactor tests
maddieford Jun 2, 2023
2ba6238
Rename extension_install to extension_workflow
maddieford Jun 5, 2023
79cae43
Assert ext status
maddieford Jun 5, 2023
40f98a6
Assert operation sequence is expected
maddieford Jun 5, 2023
8aef67d
Remove logger reference
maddieford Jun 5, 2023
d4c9a99
Pass ssh client
maddieford Jun 5, 2023
2f3731c
Update ssh
maddieford Jun 5, 2023
788584c
Add permission to run script
maddieford Jun 5, 2023
8de7846
Correct permissions
maddieford Jun 5, 2023
0a4d328
Add execute permissions for helper script
maddieford Jun 5, 2023
83d3c8e
Make scripts executable
maddieford Jun 5, 2023
2788d53
Change args to string
maddieford Jun 5, 2023
4f8a31b
Add required parameter
maddieford Jun 5, 2023
a329a46
Add shebang for retart_agent
maddieford Jun 5, 2023
d440058
Fix arg format
maddieford Jun 5, 2023
dcde7ea
Use restart utility
maddieford Jun 5, 2023
b8c2605
Run restart with sudo
maddieford Jun 5, 2023
ec7bed6
Add enable scenario
maddieford Jun 5, 2023
cde74ad
Attempt to remove start_time
maddieford Jun 5, 2023
4b44b7e
Only assert enable
maddieford Jun 5, 2023
104a623
Add delete scenario
maddieford Jun 5, 2023
1f4bd31
Fix uninstall scenario
maddieford Jun 5, 2023
a318adc
Add extension update scenario
maddieford Jun 5, 2023
81eca75
Run assert scenario on update scenario
maddieford Jun 5, 2023
976cbb4
Fix reference to ext
maddieford Jun 5, 2023
9637ea3
Format args as str instead of arr
maddieford Jun 5, 2023
df94a37
Update test args
maddieford Jun 5, 2023
1950555
Add test case for update without install
maddieford Jun 5, 2023
ed51360
Fix delete
maddieford Jun 5, 2023
5604d3c
Keep changes
maddieford Jun 6, 2023
b4951c8
Merge branch 'develop' of github.com:Azure/WALinuxAgent into develop
maddieford Jun 6, 2023
54184e7
Save changes
maddieford Jun 6, 2023
7dac115
Add special chars test case
maddieford Jun 6, 2023
84946b3
Fix dcr_ext issue{
maddieford Jun 6, 2023
e5dcd98
Add validate no lag scenario
maddieford Jun 6, 2023
f97197e
Fix testguid reference
maddieford Jun 6, 2023
f46afae
Add additional log statements for debugging
maddieford Jun 11, 2023
8ff742d
Fix message to check before encoding
maddieford Jun 11, 2023
6d388f8
Encode setting name
maddieford Jun 11, 2023
b929556
Correctly check data
maddieford Jun 12, 2023
b0d1e22
Make check data executable
maddieford Jun 12, 2023
d3d71f9
Fix command args for special char test
maddieford Jun 12, 2023
deef228
Fix no lag time
maddieford Jun 12, 2023
fe2f2c2
Fix ssh client reference
maddieford Jun 12, 2023
482f3fe
Try message instead of text
maddieford Jun 12, 2023
8bda6b5
Remove unused method
maddieford Jun 12, 2023
75cf5a0
Start clean up
maddieford Jun 12, 2023
2b0ed08
Continue code cleanup
maddieford Jun 12, 2023
48949e0
Fix pylint errors
maddieford Jun 12, 2023
3ba0f05
Fix pylint errors
maddieford Jun 12, 2023
c14125a
Start refactor
maddieford Jun 13, 2023
0380130
Debug agent lag
maddieford Jun 13, 2023
ef9291a
Update lag logging
maddieford Jun 13, 2023
30a1740
Fix assert_that for lag
maddieford Jun 13, 2023
dbecb19
Remove typo
maddieford Jun 13, 2023
8343df1
Add readme for extension_workflow scenario
maddieford Jun 14, 2023
5dce3dd
Reformat comment
maddieford Jun 14, 2023
8c5bd6d
Improve logging
maddieford Jun 14, 2023
d3c06b4
Refactor assert scenario
maddieford Jun 14, 2023
c34aa27
Remove unused constants
maddieford Jun 14, 2023
b9c9ada
Remove unusued parameter in assert scenario
maddieford Jun 14, 2023
7f208f9
Add logging
maddieford Jun 14, 2023
5466804
Improve logging
maddieford Jun 14, 2023
8e6a672
Improve logging
maddieford Jun 14, 2023
2a88fd0
Fix soft assertions issue
maddieford Jun 14, 2023
fb49cfc
Remove todo for delete polling
maddieford Jun 14, 2023
dd46d51
Remove unnecessary new line
maddieford Jun 14, 2023
947134b
removed unnecessary function
maddieford Jun 14, 2023
0d16066
Make special chars log more readable
maddieford Jun 14, 2023
356f9a9
remove unnecessary log
maddieford Jun 14, 2023
d081330
Add version to add or update log
maddieford Jun 14, 2023
bdd4934
Remove unnecessary assert instance view
maddieford Jun 14, 2023
2e0303e
Add empty log line
maddieford Jun 14, 2023
cf7d6ca
Add update back to restart args to debug
maddieford Jun 14, 2023
2613d40
Add update back to restart args to debug
maddieford Jun 14, 2023
2a1c260
Merge changes from develop
maddieford Jun 14, 2023
bc842b1
Merge branch 'develop' into ext-workflow
maddieford Jun 14, 2023
746689d
Remove unused init
maddieford Jun 14, 2023
9db7ce4
Merge branch 'ext-workflow' of github.com:maddieford/WALinuxAgent int…
maddieford Jun 14, 2023
9735035
Merge branch 'develop' into ext-workflow
maddieford Jun 14, 2023
ed6e900
Merge branch 'develop' into ext-workflow
maddieford Jun 23, 2023
ebd1e03
Merge branch 'develop' into ext-workflow
maddieford Jun 29, 2023
b3dabdb
Remove test_suites from pipeline yml
maddieford Jun 29, 2023
0abeec2
Update location in test suite yml
maddieford Jun 29, 2023
59c9456
Add comment for location restriction
maddieford Jun 29, 2023
627be4a
Remove unused init and fix comments
maddieford Jun 29, 2023
9f9ecea
Improve method header
maddieford Jun 29, 2023
666fac5
Rename scripts
maddieford Jun 29, 2023
e643fc1
Remove print_function
maddieford Jun 29, 2023
ab487b7
Rename is_data_in_waagent_log
maddieford Jun 29, 2023
96f9a3e
Add comments describing assert operation sequence script
maddieford Jul 3, 2023
30f9f6b
Merge branch 'develop' into ext-workflow
maddieford Jul 3, 2023
08f473b
add comments to scripts and type annotate assert operation sequence
maddieford Jul 3, 2023
f845bd5
Add GuestAgentDcrExtension source code to repo
maddieford Jul 3, 2023
5aeee72
Fix typing.dict error
maddieford Jul 3, 2023
60b04d4
Fix typing issue
maddieford Jul 3, 2023
eef24e8
Remove outdated comment
maddieford Jul 3, 2023
5b48168
Add comments to extension_workflow.py
maddieford Jul 3, 2023
6adbf50
rename scripts to match test suite name
maddieford Jul 3, 2023
17764c1
Ignore pylint warnings on test ext
maddieford Jul 3, 2023
549b8ef
Update pylint rc to ignore tests_e2e/GuestAgentDcrTestExtension
maddieford Jul 3, 2023
56e0edb
Update pylint rc to ignore tests_e2e/GuestAgentDcrTestExtension
maddieford Jul 3, 2023
86a0212
disable all errors/warnings dcr test ext
maddieford Jul 3, 2023
2aa1cc3
disable all errors/warnings dcr test ext
maddieford Jul 3, 2023
40a25f4
Run workflow on debian
maddieford Jul 3, 2023
bf4cf31
Revert to dcr config distros
maddieford Jul 3, 2023
9010e01
Move enable increment to beginning of function
maddieford Jul 3, 2023
22a8b81
Fix gs completed regex
maddieford Jul 3, 2023
dbee33e
Remove unnessary files from dcr test ext dir
maddieford Jul 3, 2023
40b112c
Merge branch 'develop' into ext-workflow
maddieford Jul 6, 2023
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
71 changes: 71 additions & 0 deletions tests_e2e/GuestAgentDcrTestExtension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Byte-compiled / optimized / DLL files
maddieford marked this conversation as resolved.
Show resolved Hide resolved
__pycache__/
*.py[cod]

# Virtualenv
py3env/

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyCharm
.idea/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

waagentc
*.pyproj
*.sln
*.suo

waagentc
bin/waagent2.0c

# rope project
.ropeproject/
123 changes: 123 additions & 0 deletions tests_e2e/GuestAgentDcrTestExtension/GuestAgentDcrTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env python
# pylint: disable=all
from __future__ import print_function

from Utils.WAAgentUtil import waagent
import Utils.HandlerUtil as Util
import sys
import re
import traceback
import os
import datetime

ExtensionShortName = "GADcrTestExt"
OperationFileName = "operations-{0}.log"


def install():
operation = "install"
status = "success"
msg = "Installed successfully"

hutil = parse_context(operation)
hutil.log("Start to install.")
hutil.log(msg)
hutil.do_exit(0, operation, status, '0', msg)


def enable():
# Global Variables definition
operation = "enable"
status = "success"
msg = "Enabled successfully."

# Operations.append(operation)
hutil = parse_context(operation)
hutil.log("Start to enable.")
public_settings = hutil.get_public_settings()
name = public_settings.get("name")
if name:
name = "Name: {0}".format(name)
hutil.log(name)
msg = "{0} {1}".format(msg, name)
print(name)
else:
hutil.error("The name in public settings is not provided.")
# msg = msg % ','.join(Operations)
hutil.log(msg)
hutil.do_exit(0, operation, status, '0', msg)


def disable():
operation = "disable"
status = "success"
msg = "Disabled successfully."

# Operations.append(operation)
hutil = parse_context(operation)
hutil.log("Start to disable.")
# msg % ','.join(Operations)
hutil.log(msg)
hutil.do_exit(0, operation, status, '0', msg)


def uninstall():
operation = "uninstall"
status = "success"
msg = "Uninstalled successfully."

# Operations.append(operation)
hutil = parse_context(operation)
hutil.log("Start to uninstall.")
# msg % ','.join(Operations)
hutil.log(msg)
hutil.do_exit(0, operation, status, '0', msg)


def update():
operation = "update"
status = "success"
msg = "Updated successfully."

# Operations.append(operation)
hutil = parse_context(operation)
hutil.log("Start to update.")
# msg % ','.join(Operations)
hutil.log(msg)
hutil.do_exit(0, operation, status, '0', msg)


def parse_context(operation):
hutil = Util.HandlerUtility(waagent.Log, waagent.Error)
hutil.do_parse_context(operation)
op_log = os.path.join(hutil.get_log_dir(), OperationFileName.format(hutil.get_extension_version()))
with open(op_log, 'a+') as oplog_handler:
oplog_handler.write("Date:{0}; Operation:{1}; SeqNo:{2}\n"
.format(datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ"),
operation, hutil.get_seq_no()))
return hutil


def main():
waagent.LoggerInit('/var/log/waagent.log', '/dev/stdout')
waagent.Log("%s started to handle." % (ExtensionShortName))

try:
for a in sys.argv[1:]:
if re.match("^([-/]*)(disable)", a):
disable()
elif re.match("^([-/]*)(uninstall)", a):
uninstall()
elif re.match("^([-/]*)(install)", a):
install()
elif re.match("^([-/]*)(enable)", a):
enable()
elif re.match("^([-/]*)(update)", a):
update()
except Exception as e:
err_msg = "Failed with error: {0}, {1}".format(e, traceback.format_exc())
waagent.Error(err_msg)


if __name__ == '__main__':
main()
14 changes: 14 additions & 0 deletions tests_e2e/GuestAgentDcrTestExtension/HandlerManifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[{
"name": "GuestAgentDcrTestExtension",
"version": 1.0,
"handlerManifest": {
"installCommand": "./GuestAgentDcrTest.py --install",
"uninstallCommand": "./GuestAgentDcrTest.py --uninstall",
"updateCommand": "./GuestAgentDcrTest.py --update",
"enableCommand": "./GuestAgentDcrTest.py --enable",
"disableCommand": "./GuestAgentDcrTest.py --disable",
"updateMode": "UpdateWithoutInstall",
"rebootAfterInstall": false,
"reportHeartbeat": false
}
}]
Loading
Loading