-
Notifications
You must be signed in to change notification settings - Fork 372
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
Initial (bare-bones) implementation of the infrastructure for end-to-end tests #2691
Changes from all commits
9c72135
00aa11f
14be306
4e1da04
998e7a1
4c1ecc4
147e1fb
37f03a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
variables: | ||
- name: azureConnection | ||
value: 'AzLinux DCR Public (8e037ad4-618f-4466-8bc8-5099d41ac15b)' | ||
- name: subId | ||
value: '8e037ad4-618f-4466-8bc8-5099d41ac15b' | ||
- name: testsSourcesDirectory | ||
value: "$(Build.SourcesDirectory)/tests_e2e" | ||
|
||
trigger: | ||
- develop | ||
|
||
pr: none | ||
|
||
pool: | ||
vmImage: ubuntu-latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this pool for orchestrator vms? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is the pool of Azure Pipelines VMs where we run the orchestrator (singular, now we have only 1 orchestrator) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean you plan to keep only 1 for all scenarios or at this point we have one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1 at this point. the actual number will depend on how we organize the test runs and how much we can take advantage of LISA's capabilities. |
||
|
||
stages: | ||
- stage: "Execute" | ||
jobs: | ||
- template: 'templates/execute-tests.yml' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: azure | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the interface with LISA is under the 'lisa' subdirectory (it will be moved one level up in a future PR). This YML file is the entry point to LISA. |
||
extension: | ||
- "../testsuites" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the directory all of the LISA tests need to be in? Or will LISA look for tests in the entire /lisa directory There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The LISA runbook points to the test location
|
||
variable: | ||
- name: location | ||
value: "westus2" | ||
- name: subscription_id | ||
value: "" | ||
- name: resource_group_name | ||
value: "" | ||
# | ||
# Set the vm_name to run on an existing VM | ||
# | ||
- name: vm_name | ||
value: "" | ||
- name: marketplace_image | ||
value: "Canonical UbuntuServer 18.04-LTS latest" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like this is not in urn format. Is this how we suppose to define images? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll define a combinator to pass multiple distros. The LISA documentation has some info on how to do that, but we can always work with them if we need more info or features. |
||
- name: vhd | ||
value: "" | ||
- name: vm_size | ||
value: "" | ||
# | ||
# Turn off deploy to run on an existing VM | ||
# | ||
- name: deploy | ||
value: true | ||
- name: keep_environment | ||
value: "no" | ||
- name: wait_delete | ||
value: false | ||
- name: user | ||
value: "waagent" | ||
- name: identity_file | ||
value: "" | ||
is_secret: true | ||
- name: admin_password | ||
value: "" | ||
is_secret: true | ||
- name: proxy_host | ||
value: "" | ||
- name: proxy_user | ||
value: "" | ||
- name: proxy_identity_file | ||
value: "" | ||
is_secret: true | ||
notifier: | ||
- type: html | ||
- type: env_stats | ||
platform: | ||
- type: azure | ||
admin_username: $(user) | ||
admin_private_key_file: $(identity_file) | ||
admin_password: $(admin_password) | ||
keep_environment: $(keep_environment) | ||
azure: | ||
resource_group_name: $(resource_group_name) | ||
deploy: $(deploy) | ||
subscription_id: $(subscription_id) | ||
wait_delete: $(wait_delete) | ||
requirement: | ||
core_count: | ||
min: 2 | ||
azure: | ||
marketplace: "$(marketplace_image)" | ||
vhd: $(vhd) | ||
location: $(location) | ||
name: $(vm_name) | ||
vm_size: $(vm_size) | ||
|
||
testcase: | ||
- criteria: | ||
area: bvt | ||
|
||
# | ||
# Set to do SSH proxy jumps | ||
# | ||
#dev: | ||
# mock_tcp_ping: True | ||
# jump_boxes: | ||
# - private_key_file: $(proxy_identity_file) | ||
# address: $(proxy_host) | ||
# username: $(proxy_user) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skeleton for the current scenarios\agent-bvt\01_check_waagent_version.py test in DCR |
||
|
||
from __future__ import print_function | ||
|
||
import subprocess | ||
import sys | ||
|
||
|
||
def main(): | ||
print("Executing waagent --version") | ||
|
||
pipe = subprocess.Popen(['waagent', '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout_lines = list(map(lambda s: s.decode('utf-8'), pipe.stdout.readlines())) | ||
exit_code = pipe.wait() | ||
|
||
for line in stdout_lines: | ||
print(line) | ||
|
||
return exit_code | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import argparse | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skeleton for the current scenarios\agent-bvt\06_customscript_20.py test in DCR |
||
import os | ||
import uuid | ||
import sys | ||
|
||
from tests_e2e.scenario_utils.extensions.CustomScriptExtension import CustomScriptExtension | ||
|
||
|
||
def main(subscription_id, resource_group_name, vm_name): | ||
os.environ["VMNAME"] = vm_name | ||
os.environ['RGNAME'] = resource_group_name | ||
os.environ["SUBID"] = subscription_id | ||
os.environ["SCENARIONAME"] = "BVT" | ||
os.environ["LOCATION"] = "westus2" | ||
os.environ["ADMINUSERNAME"] = "somebody" | ||
os.environ["BUILD_SOURCESDIRECTORY"] = "/somewhere" | ||
|
||
cse = CustomScriptExtension(extension_name="testCSE") | ||
|
||
ext_props = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we rewrite here? it already there in add_cse() function in Customerscript extension. Can we reuse that to run it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add_cse() does more than I need for this prototype (slowing the execution down), and, in any case, we will need to do a major rewrite of the BaseExtensionTest class we brought from DCR. In my oipinion the abstraction it presents is not appropriate and, more importantly, it handles errors poorly and does not output enough diagnostic info to debug failures. |
||
cse.get_ext_props(settings={'commandToExecute': f"echo \'Hello World! {uuid.uuid4()} \'"}), | ||
cse.get_ext_props(settings={'commandToExecute': "echo \'Hello again\'"}) | ||
] | ||
|
||
cse.run(ext_props=ext_props) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed all of the logging from cse.run is being logged as lisa.stderr. Why is lisa capturing these as stderr instead of stdout? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The output is coming from BaseExtensionTestClass (in the scenatio_utils directory). This code comes straight from the current DCR and will need a lot of improvements, for example writing to the log file instead of stdout/stderr. |
||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--subscription') | ||
parser.add_argument('--group') | ||
parser.add_argument('--vm') | ||
|
||
args = parser.parse_args() | ||
|
||
main(args.subscription, args.group, args.vm) | ||
|
||
except Exception as exception: | ||
print(str(exception)) | ||
sys.exit(1) | ||
|
||
sys.exit(0) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from assertpy import assert_that | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skeleton to define the 2 basic patterns for the end-to-end tests. Currently hardcoded to specific tests, but will be abstracted in future PRs. |
||
from pathlib import Path | ||
from tests_e2e.lisa.tests.agent_bvt import custom_script | ||
|
||
from lisa import ( | ||
CustomScriptBuilder, | ||
Logger, | ||
Node, | ||
simple_requirement, | ||
TestCaseMetadata, | ||
TestSuite, | ||
TestSuiteMetadata, | ||
) | ||
from lisa.sut_orchestrator.azure.common import get_node_context | ||
|
||
|
||
@TestSuiteMetadata( | ||
area="bvt", | ||
category="functional", | ||
description=""" | ||
A POC test suite for the waagent BVTs. | ||
""", | ||
requirement=simple_requirement(unsupported_os=[]), | ||
) | ||
class AgentBvt(TestSuite): | ||
@TestCaseMetadata(description="", priority=0) | ||
def check_agent_version(self, node: Node, log: Logger) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pattern 1: Execute a test remotely over SSH |
||
script_path = CustomScriptBuilder(Path(__file__).parent.parent.joinpath("tests", "agent_bvt"), ["check_agent_version.py"]) | ||
script = node.tools[script_path] | ||
result = script.run() | ||
log.info(result.stdout) | ||
log.error(result.stderr) | ||
assert_that(result.exit_code).is_equal_to(0) | ||
|
||
@TestCaseMetadata(description="", priority=0) | ||
def custom_script(self, node: Node) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pattern 2: Execute a test locally (local to the orchestrator) to trigger extensions on the remote test VM There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At what point is the remote test VM created? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LISA does that. In the output of the task you will see something similar to
|
||
node_context = get_node_context(node) | ||
subscription_id = node.features._platform.subscription_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently reaching into the internal "_platform" object to get the Subscription ID. This should be done by implementing a LISA feature that exposes subscription ID/resource group name/vm name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Once we are creating multiple test VMs with different images, how will LISA know which nodes this test should be ran with? Will that be specified in the runbook? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we will create a combinator to execute each test on each distro and add it to the runbook There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the node details that it's trying to fetch for the actual test vm not the orchestrator vm right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, the Node represents the VM created by LISA |
||
resource_group_name = node_context.resource_group_name | ||
vm_name = node_context.vm_name | ||
custom_script.main(subscription_id, resource_group_name, vm_name) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This is a list of pip packages that will be installed on both the orchestrator and the test VM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Requirements for the orchestrator/test VM. Comes directly from the 'dcr' POC, but should be splitted in 2 (one for orchestrator, one for test VM) |
||
# Only add the common packages here, for more specific modules, add them to the scenario itself | ||
azure-identity | ||
azure-keyvault-keys | ||
azure-mgmt-compute>=22.1.0 | ||
azure-mgmt-keyvault>=7.0.0 | ||
azure-mgmt-network>=16.0.0 | ||
azure-mgmt-resource>=15.0.0 | ||
cryptography | ||
distro | ||
junitparser | ||
msrestazure | ||
python-dotenv |
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.
Entry point for Azure Pipelines