Skip to content

Commit

Permalink
Merge branch 'develop' into parser
Browse files Browse the repository at this point in the history
  • Loading branch information
narrieta authored Oct 25, 2024
2 parents 5e7f479 + 7cbde8b commit 2616790
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 76 deletions.
2 changes: 1 addition & 1 deletion tests_e2e/test_suites/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ images:
AzureUSGovernment: []
rhel_94: "RedHat RHEL 9_4 latest"
rocky_9:
urn: "erockyenterprisesoftwarefoundationinc1653071250513 rockylinux-9 rockylinux-9 latest"
urn: "resf rockylinux-x86_64 9-base latest"
locations:
AzureChinaCloud: []
AzureUSGovernment: []
Expand Down
54 changes: 28 additions & 26 deletions tests_e2e/tests/agent_ext_workflow/extension_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,25 @@ def run(self):
log.info("")
log.info("*******Verifying the extension update with install scenario*******")

# Record the time we start the test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Version 1.2.0 of the test extension has the same functionalities as 1.1.5 with
# "updateMode": "UpdateWithInstall" in HandlerManifest.json to test update case
new_version_update_mode_with_install = "1.2.0"
old_version = "1.1.5"

# Create DcrTestExtension with version 1.1 and 1.2
# Install test extension v1.1.5 on the VM and assert instance view before updating the start_time, since
# the previous test case removed v1.1.5 from the VM.
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Record the time we start the update with install scenario test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Create DcrTestExtension with version 1.2
dcr_test_ext_id_1_2 = VmExtensionIdentifier(
VmExtensionIds.GuestAgentDcrTestExtension.publisher,
VmExtensionIds.GuestAgentDcrTestExtension.type,
Expand All @@ -323,15 +333,6 @@ def run(self):
dcr_test_ext_id_1_2,
resource_name="GuestAgentDcrTestExt"
)
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)

# Install test extension v1.1.5 on the VM and assert instance view
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Update extension object & version to new version
dcr_ext.update_ext_version(dcr_test_ext_client_1_2, new_version_update_mode_with_install)
Expand Down Expand Up @@ -371,14 +372,24 @@ def run(self):
log.info("")
log.info("*******Verifying the extension update without install scenario*******")

# Record the time we start the test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Version 1.3.0 of the test extension has the same functionalities as 1.1.5 with
# "updateMode": "UpdateWithoutInstall" in HandlerManifest.json to test update case
new_version_update_mode_without_install = "1.3.0"

# Create DcrTestExtension with version 1.1 and 1.3
# Install test extension v1.1.5 on the VM and assert instance view before updating the start_time, since
# the previous test case removed v1.1.5 from the VM.
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Record the time we start the update without scenario test
start_time = self._ssh_client.run_command("date '+%Y-%m-%dT%TZ'").rstrip()

# Create DcrTestExtension with version 1.3
dcr_test_ext_id_1_3 = VmExtensionIdentifier(
VmExtensionIds.GuestAgentDcrTestExtension.publisher,
VmExtensionIds.GuestAgentDcrTestExtension.type,
Expand All @@ -388,15 +399,6 @@ def run(self):
dcr_test_ext_id_1_3,
resource_name="GuestAgentDcrTestExt"
)
dcr_ext = ExtensionWorkflow.GuestAgentDcrTestExtension(
extension=dcr_test_ext_client,
ssh_client=self._ssh_client,
version=old_version
)

# Install test extension v1.1.5 on the VM and assert instance view
dcr_ext.modify_ext_settings_and_enable()
dcr_ext.assert_instance_view()

# Update extension object & version to new version
dcr_ext.update_ext_version(dcr_test_ext_client_1_3, new_version_update_mode_without_install)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ def parse_ops_log(ops_version: str, input_ops: List[str], start_time: str):

ops = []
with open(ops_file_name, 'r') as ops_log:
# we get the last len(input_ops) from the log file and ensure they match with the input_ops
# Example of a line in the log file - `Date:2019-07-30T21:54:03Z; Operation:install; SeqNo:0`
content = ops_log.readlines()[-len(input_ops):]
content = ops_log.readlines()
for op_log in content:
data = op_log.split(DELIMITER)
date = datetime.strptime(data[0].split("Date:")[1], "%Y-%m-%dT%H:%M:%SZ")
Expand All @@ -72,6 +71,13 @@ def parse_ops_log(ops_version: str, input_ops: List[str], start_time: str):
continue

ops.append({'date': date, 'op': op, 'seq_no': seq_no})

# Only parse the expected number of operations after the test case starts. There may be additional
# operations on the extension if the agent processes a goal state with additional extensions added by policy
# or otherwise (ConfigurationforLinux, for example)
if len(ops) == len(input_ops):
break

return ops


Expand Down
82 changes: 35 additions & 47 deletions tests_e2e/tests/scripts/agent_persist_firewall-access_wireserver
Original file line number Diff line number Diff line change
Expand Up @@ -29,65 +29,53 @@ echo "$(date --utc +%FT%T.%3NZ): Running as user: $USER"

function check_online
{
ping 8.8.8.8 -c 1 -i .2 -t 30 > /dev/null 2>&1 && echo 0 || echo 1
}

function ping_localhost
{
ping 127.0.0.1 -c 1 -i .2 -t 30 > /dev/null 2>&1 && echo 0 || echo 1
}

function socket_connection
{
python3 /home/"$TEST_USER"/bin/agent_persist_firewall-check_connectivity.py 2>&1 && echo 0 || echo 1
}

# Check more, sleep less
MAX_CHECKS=10
# Initial starting value for checks
CHECKS=0
IS_ONLINE=$(check_online)

echo "Checking network connectivity..."
echo "Running ping to 8.8.8.8 option"
# Loop while we're not online.
while [ "$IS_ONLINE" -eq 1 ]; do

CHECKS=$((CHECKS + 1))
if [ $CHECKS -gt $MAX_CHECKS ]; then
break
fi

echo "$(date --utc +%FT%T.%3NZ): Network still not accessible"
# We're offline. Sleep for a bit, then check again
sleep 1;
IS_ONLINE=$(check_online)

done
echo "Checking network connectivity..."

echo "Running ping to 8.8.8.8 option"
checks=0
while true; do
if ping 8.8.8.8 -c 1 -i .2 -t 30; then
echo "Network is accessible"
return 0
fi
checks=$((checks + 1))
if [ $checks -gt 10 ]; then
break
fi

echo "$(date --utc +%FT%T.%3NZ): Network still not accessible"
# We're offline. Sleep for a bit, then check again
sleep 1;
done

echo "Checking other options to see if network is accessible..."

# logging other options output to compare and evaluate which option is more stable when ping to 8.8.8.8 failed
if [ "$IS_ONLINE" -eq 1 ]; then
echo "Checking other options to see if network is accessible"
echo "Running ping to localhost option"
PING_LOCAL=$(ping_localhost)
if [ "$PING_LOCAL" -eq 1 ]; then
echo "Ping to localhost failed"
else
if ping 127.0.0.1 -c 1 -i .2 -t 30; then
echo "Ping to localhost succeeded"
return 0
fi
echo "Ping to localhost failed"

echo "Running socket connection to wireserver:53 option"
IS_ONLINE=$(socket_connection)
fi
if [ "$IS_ONLINE" -eq 1 ]; then
if python3 /home/"$TEST_USER"/bin/agent_persist_firewall-check_connectivity.py; then
echo "Socket connection succeeded"
return 0
fi
echo "Socket connection failed"

echo "Unable to connect to network, giving up"
return 1
}

if ! check_online; then
# We will never be able to get online. Kill script.
echo "Unable to connect to network, exiting now"
echo "ExitCode: 1"
exit 1
fi

echo "Finally online, Time: $(date --utc +%FT%T.%3NZ)"
echo "Trying to contact Wireserver as $USER to see if accessible"

echo ""
echo "Firewall configuration before accessing Wireserver:"
if sudo which iptables > /dev/null ; then
Expand Down

0 comments on commit 2616790

Please sign in to comment.