Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
narrieta@microsoft committed Jan 4, 2025
1 parent 4af8a34 commit 7203db7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion azurelinuxagent/ga/cgroupconfigurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def _get_current_cpu_quota(unit_name):

# Calculate CPU percentage
cpu_percentage = (cpu_quota_us / 1000000) * 100
return "{:g}%".format(cpu_percentage) # :g Removes trailing zeros after decimal point
return "{0:g}%".format(cpu_percentage) # :g Removes trailing zeros after decimal point
except Exception as e:
log_cgroup_warning("Error parsing current CPUQuotaPerSecUSec: {0}".format(ustr(e)))
return "unknown"
Expand Down
2 changes: 1 addition & 1 deletion tests/data/ext/sample_ext-1.3.0/python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
python=$(command -v python 2> /dev/null)

if [ -z "$PYTHON" ]; then
if [ -z "$python" ]; then
python=$(command -v python3)
fi

Expand Down
6 changes: 3 additions & 3 deletions tests/ga/test_cgroupapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def mock_popen(command, *args, **kwargs):
shell=True,
timeout=300,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=output_file,
stderr=output_file)

Expand All @@ -317,7 +317,7 @@ def test_start_extension_cgroups_v1_command_should_execute_the_command_in_a_cgro
shell=False,
timeout=300,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

Expand All @@ -344,7 +344,7 @@ def test_start_extension_cgroups_v1_command_should_use_systemd_to_execute_the_co
timeout=300,
shell=True,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

Expand Down
20 changes: 10 additions & 10 deletions tests/ga/test_cgroupconfigurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def test_start_extension_command_should_not_use_systemd_when_cgroups_are_not_ena
timeout=300,
shell=False,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

Expand All @@ -374,7 +374,7 @@ def test_start_extension_command_should_use_systemd_run_when_cgroups_v1_are_enab
timeout=300,
shell=False,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

Expand All @@ -395,7 +395,7 @@ def test_start_extension_command_should_start_tracking_the_extension_cgroups(sel
timeout=300,
shell=False,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

Expand Down Expand Up @@ -426,7 +426,7 @@ def mock_popen(command_arg, *args, **kwargs):
timeout=300,
shell=False,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

Expand All @@ -446,7 +446,7 @@ def test_start_extension_command_should_not_use_systemd_when_cgroup_v2_enabled(s
timeout=300,
shell=False,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

Expand Down Expand Up @@ -480,7 +480,7 @@ def test_start_extension_command_should_disable_cgroups_and_invoke_the_command_d
timeout=300,
shell=True,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=output_file,
stderr=output_file)

Expand Down Expand Up @@ -526,7 +526,7 @@ def test_start_extension_command_should_disable_cgroups_and_invoke_the_command_d
timeout=300,
shell=True,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=stdout,
stderr=stderr)

Expand Down Expand Up @@ -571,7 +571,7 @@ def mock_popen(command, *args, **kwargs):
timeout=300,
shell=True,
cwd=self.tmp_dir,
env={},
env={}.update(os.environ),
stdout=stdout,
stderr=stderr)

Expand Down Expand Up @@ -856,7 +856,7 @@ def mock_popen(command, *args, **kwargs):
# For the agent's processes, we use the current process and its parent (in the actual agent these would be the daemon and the extension
# handler), and the commands started by the agent.
#
# For other processes, we use process 1, a process that already completed, and an extension. Note that extensions are started using
# For other processes, we use a process that already completed, and an extension process. Note that extensions are started using
# systemd-run and the process for that commands belongs to the agent's cgroup but the processes for the extension should be in a
# different cgroup
#
Expand All @@ -868,7 +868,7 @@ def get_completed_process():
return completed

agent_processes = [os.getppid(), os.getpid()] + agent_command_processes + [start_extension.systemd_run_pid]
other_processes = [1, get_completed_process()] + extension_processes
other_processes = [get_completed_process()] + extension_processes

with patch("azurelinuxagent.ga.cgroupapi.CgroupV1.get_processes", return_value=agent_processes + other_processes):
with self.assertRaises(CGroupsException) as context_manager:
Expand Down
5 changes: 3 additions & 2 deletions tests/python_eol/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ RUN \
sed -i 's/mesg n || true/tty -s \&\& mesg n/' ~/.profile && \
:

# TODO: Some unit tests have a dependency on Python 3; this needs to be fixed, but installing Python 3 is a workaround for now.
#
# TODO: Some unit tests create helper scripts that use 'python3' as shebang; we should probably port them to Bash, but installing Python 3 as a workaround for now.
#
RUN \
if [[ "${PYTHON_VERSION}" == "2.6" ]]; then \
apt-get update && \
apt-get -y install python3; \
fi

Expand Down

0 comments on commit 7203db7

Please sign in to comment.