diff mbox series

[ovs-dev,1/2] tests: Fix tests/check_acl_log.py outputs.

Message ID 166066159813.359290.18223474536611411513.stgit@dceara.remote.csb
State Accepted
Headers show
Series [ovs-dev,1/2] tests: Fix tests/check_acl_log.py outputs. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Dumitru Ceara Aug. 16, 2022, 2:53 p.m. UTC
This commit also fixes some output issues due to truncated lines
within f-strings or acl log lines that include trailing whitespace
in check_acl_log.py.  It also implicitly fixes the flake8 reported
issue:
  tests/check_acl_log.py:94:80: E501 line too long (80 > 79 characters)

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
---
V2:
- Addressed Ilya's comments.
- Fixed formatting for all f-string generated output.
- Removed trailing whitespace from logs.
---
 tests/check_acl_log.py |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Mark Michelson Aug. 19, 2022, 1:17 p.m. UTC | #1
Thanks for fixing my janky code, Dumitru :)

Acked-by: Mark Michelson <mmichels@redhat.com>

On 8/16/22 10:53, Dumitru Ceara wrote:
> This commit also fixes some output issues due to truncated lines
> within f-strings or acl log lines that include trailing whitespace
> in check_acl_log.py.  It also implicitly fixes the flake8 reported
> issue:
>    tests/check_acl_log.py:94:80: E501 line too long (80 > 79 characters)
> 
> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
> ---
> V2:
> - Addressed Ilya's comments.
> - Fixed formatting for all f-string generated output.
> - Removed trailing whitespace from logs.
> ---
>   tests/check_acl_log.py |   16 +++++++++-------
>   1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/check_acl_log.py b/tests/check_acl_log.py
> index 1dd9630c0..0c1968b2e 100644
> --- a/tests/check_acl_log.py
> +++ b/tests/check_acl_log.py
> @@ -37,13 +37,14 @@ def parse_acl_log(line):
>   
>   def get_acl_log(entry_num=1):
>       with open("ovn-controller.log", "r") as controller_log:
> -        acl_logs = [line for line in controller_log if "acl_log" in line]
> +        acl_logs = [line.rstrip() for line in controller_log
> +                    if "acl_log" in line]
>           try:
>               return acl_logs[entry_num - 1]
>           except IndexError:
>               print(
> -                f"There were not {entry_num} acl_log entries, \
> -                only {len(acl_logs)}"
> +                f"There were not {entry_num} acl_log entries, "
> +                f"only {len(acl_logs)}"
>               )
>               exit(1)
>   
> @@ -91,14 +92,15 @@ def main():
>           try:
>               if parsed_log[key] != val:
>                   print(
> -                    f"Expected log {key}={val} but got {key}={parsed_log[key]} \
> -                    in:\n\t'{acl_log}"
> +                    f"Expected log {key}={val} but got "
> +                    f"{key}={parsed_log[key]} "
> +                    f"in:\n\t'{acl_log}'"
>                   )
>                   exit(1)
>           except KeyError:
>               print(
> -                f"Expected log {key}={val} but {key} does not exist \
> -                in:\n\t'{acl_log}'"
> +                f"Expected log {key}={val} but {key} does not exist in:\n"
> +                f"\t'{acl_log}'"
>               )
>               exit(1)
>   
>
Dumitru Ceara Sept. 9, 2022, 7:15 a.m. UTC | #2
On 8/19/22 15:17, Mark Michelson wrote:
> Thanks for fixing my janky code, Dumitru :)
> 
> Acked-by: Mark Michelson <mmichels@redhat.com>
> 

Thanks Mark for the review!

Any chance we can get this merged to main and all stable branches down
to 22.03 LTS?  It's not a feature, it's just a minor change to the test
tools and it unblocks compilation with more recent versions of flake8.

Regards,
Dumitru

> On 8/16/22 10:53, Dumitru Ceara wrote:
>> This commit also fixes some output issues due to truncated lines
>> within f-strings or acl log lines that include trailing whitespace
>> in check_acl_log.py.  It also implicitly fixes the flake8 reported
>> issue:
>>    tests/check_acl_log.py:94:80: E501 line too long (80 > 79 characters)
>>
>> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
>> ---
>> V2:
>> - Addressed Ilya's comments.
>> - Fixed formatting for all f-string generated output.
>> - Removed trailing whitespace from logs.
>> ---
>>   tests/check_acl_log.py |   16 +++++++++-------
>>   1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/tests/check_acl_log.py b/tests/check_acl_log.py
>> index 1dd9630c0..0c1968b2e 100644
>> --- a/tests/check_acl_log.py
>> +++ b/tests/check_acl_log.py
>> @@ -37,13 +37,14 @@ def parse_acl_log(line):
>>     def get_acl_log(entry_num=1):
>>       with open("ovn-controller.log", "r") as controller_log:
>> -        acl_logs = [line for line in controller_log if "acl_log" in
>> line]
>> +        acl_logs = [line.rstrip() for line in controller_log
>> +                    if "acl_log" in line]
>>           try:
>>               return acl_logs[entry_num - 1]
>>           except IndexError:
>>               print(
>> -                f"There were not {entry_num} acl_log entries, \
>> -                only {len(acl_logs)}"
>> +                f"There were not {entry_num} acl_log entries, "
>> +                f"only {len(acl_logs)}"
>>               )
>>               exit(1)
>>   @@ -91,14 +92,15 @@ def main():
>>           try:
>>               if parsed_log[key] != val:
>>                   print(
>> -                    f"Expected log {key}={val} but got
>> {key}={parsed_log[key]} \
>> -                    in:\n\t'{acl_log}"
>> +                    f"Expected log {key}={val} but got "
>> +                    f"{key}={parsed_log[key]} "
>> +                    f"in:\n\t'{acl_log}'"
>>                   )
>>                   exit(1)
>>           except KeyError:
>>               print(
>> -                f"Expected log {key}={val} but {key} does not exist \
>> -                in:\n\t'{acl_log}'"
>> +                f"Expected log {key}={val} but {key} does not exist
>> in:\n"
>> +                f"\t'{acl_log}'"
>>               )
>>               exit(1)
>>  
>
Mark Michelson Sept. 16, 2022, 1:21 p.m. UTC | #3
On 9/9/22 03:15, Dumitru Ceara wrote:
> On 8/19/22 15:17, Mark Michelson wrote:
>> Thanks for fixing my janky code, Dumitru :)
>>
>> Acked-by: Mark Michelson <mmichels@redhat.com>
>>
> 
> Thanks Mark for the review!
> 
> Any chance we can get this merged to main and all stable branches down
> to 22.03 LTS?  It's not a feature, it's just a minor change to the test
> tools and it unblocks compilation with more recent versions of flake8.
> 
> Regards,
> Dumitru
> 

I merged this to main, branch-22.09, branch-22.06, and branch-22.03.

>> On 8/16/22 10:53, Dumitru Ceara wrote:
>>> This commit also fixes some output issues due to truncated lines
>>> within f-strings or acl log lines that include trailing whitespace
>>> in check_acl_log.py.  It also implicitly fixes the flake8 reported
>>> issue:
>>>     tests/check_acl_log.py:94:80: E501 line too long (80 > 79 characters)
>>>
>>> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
>>> ---
>>> V2:
>>> - Addressed Ilya's comments.
>>> - Fixed formatting for all f-string generated output.
>>> - Removed trailing whitespace from logs.
>>> ---
>>>    tests/check_acl_log.py |   16 +++++++++-------
>>>    1 file changed, 9 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/tests/check_acl_log.py b/tests/check_acl_log.py
>>> index 1dd9630c0..0c1968b2e 100644
>>> --- a/tests/check_acl_log.py
>>> +++ b/tests/check_acl_log.py
>>> @@ -37,13 +37,14 @@ def parse_acl_log(line):
>>>      def get_acl_log(entry_num=1):
>>>        with open("ovn-controller.log", "r") as controller_log:
>>> -        acl_logs = [line for line in controller_log if "acl_log" in
>>> line]
>>> +        acl_logs = [line.rstrip() for line in controller_log
>>> +                    if "acl_log" in line]
>>>            try:
>>>                return acl_logs[entry_num - 1]
>>>            except IndexError:
>>>                print(
>>> -                f"There were not {entry_num} acl_log entries, \
>>> -                only {len(acl_logs)}"
>>> +                f"There were not {entry_num} acl_log entries, "
>>> +                f"only {len(acl_logs)}"
>>>                )
>>>                exit(1)
>>>    @@ -91,14 +92,15 @@ def main():
>>>            try:
>>>                if parsed_log[key] != val:
>>>                    print(
>>> -                    f"Expected log {key}={val} but got
>>> {key}={parsed_log[key]} \
>>> -                    in:\n\t'{acl_log}"
>>> +                    f"Expected log {key}={val} but got "
>>> +                    f"{key}={parsed_log[key]} "
>>> +                    f"in:\n\t'{acl_log}'"
>>>                    )
>>>                    exit(1)
>>>            except KeyError:
>>>                print(
>>> -                f"Expected log {key}={val} but {key} does not exist \
>>> -                in:\n\t'{acl_log}'"
>>> +                f"Expected log {key}={val} but {key} does not exist
>>> in:\n"
>>> +                f"\t'{acl_log}'"
>>>                )
>>>                exit(1)
>>>   
>>
>
diff mbox series

Patch

diff --git a/tests/check_acl_log.py b/tests/check_acl_log.py
index 1dd9630c0..0c1968b2e 100644
--- a/tests/check_acl_log.py
+++ b/tests/check_acl_log.py
@@ -37,13 +37,14 @@  def parse_acl_log(line):
 
 def get_acl_log(entry_num=1):
     with open("ovn-controller.log", "r") as controller_log:
-        acl_logs = [line for line in controller_log if "acl_log" in line]
+        acl_logs = [line.rstrip() for line in controller_log
+                    if "acl_log" in line]
         try:
             return acl_logs[entry_num - 1]
         except IndexError:
             print(
-                f"There were not {entry_num} acl_log entries, \
-                only {len(acl_logs)}"
+                f"There were not {entry_num} acl_log entries, "
+                f"only {len(acl_logs)}"
             )
             exit(1)
 
@@ -91,14 +92,15 @@  def main():
         try:
             if parsed_log[key] != val:
                 print(
-                    f"Expected log {key}={val} but got {key}={parsed_log[key]} \
-                    in:\n\t'{acl_log}"
+                    f"Expected log {key}={val} but got "
+                    f"{key}={parsed_log[key]} "
+                    f"in:\n\t'{acl_log}'"
                 )
                 exit(1)
         except KeyError:
             print(
-                f"Expected log {key}={val} but {key} does not exist \
-                in:\n\t'{acl_log}'"
+                f"Expected log {key}={val} but {key} does not exist in:\n"
+                f"\t'{acl_log}'"
             )
             exit(1)