Re: [PATCH] Cover get_json_table_plan() with tests

Поиск
Список
Период
Сортировка
Искать

Re: [PATCH] Cover get_json_table_plan() with tests

От:
"Jonathan Gonzalez V." <jonathan.abdiel@gmail.com>
Дата:
Вложения:

Hello!

>> Could you please clarify which lines of get_json_table_plan() this
>> will cover which are not currently covered by patch v2?
>
> What are the old and new coverage numbers before and after the fact,
> and where are the zones impacted?  I am seeing a mention to
> "improvements", but zero fact explaining things.  This is mostly to
> get a feeling of the gain vs the runtime involved.

Yes, I'm sorry I forgot to include the numbers and the facts, my bad!

So the v2 to is missing the following lines

12779: castNode(JsonTablePathScan, j->lplan)->child);
12785: castNode(JsonTablePathScan, j->rplan)->child);

Which will be covered by my suggestion, these are marked as not tested
in a 2 branch in the coverage.

The current coverage for the function get_json_table_plan() without the
v2 is:

get_json_table_plan (line 12752)	called 3 times, returned 3 times 54.0%

With the v2:

get_json_table_plan (line 12752)	called 11 times, returned 11 times 95.0%

Applying my suggestion

get_json_table_plan (line 12752)	called 38 times, returned 38 times 100.0%


Those are the full numbers for that function.

Regards!
--
Jonathan Gonzalez V.
EDB
https://www.enterprisedb.com


Re: [PATCH] Cover get_json_table_plan() with tests

От:
Aleksander Alekseev <aleksander@tigerdata.com>
Дата:
Hi Michael,

> What are the old and new coverage numbers before and after the fact,
> and where are the zones impacted?  I am seeing a mention to
> "improvements", but zero fact explaining things.

I used the command:

```
time -p sh -c 'git clean -df && (rm -r build || true) && meson setup
--buildtype debug -Db_coverage=true -Dcassert=true
-Dinjection_points=true -Dtap_tests=enabled -Dldap=disabled
-Dicu=disabled -DPG_TEST_EXTRA="kerberos ldap libpq_encryption
load_balance oauth regress_dump_restore ssl wal_consistency_checking
xid_wraparound" -Dprefix=/home/eax/pginstall build && ninja -C build
&& meson test -C build && ninja -C build coverage-html && open
build/meson-logs/coveragereport/src/backend/utils/adt/ruleutils.c.gcov.html'
```

My lcov version is 1.16. Here are before and after:

https://gist.github.com/afiskon/526f847d5e4ad786ca43bb63c2081bdf

Jonathan,

> The current coverage for the function get_json_table_plan() without the
> v2 is:
>
> get_json_table_plan (line 12752)        called 3 times, returned 3 times 54.0%
>
> With the v2:
>
> get_json_table_plan (line 12752)        called 11 times, returned 11 times 95.0%
>
> Applying my suggestion
>
> get_json_table_plan (line 12752)        called 38 times, returned 38 times 100.0%

OK, I got your idea. Also I missed the fact that with the recent
updates in the `master` branch ~50% of the function is already
executed. This was not the case when I submitted v1.

I don't think that we should be that pedantic to cover `||
castNode(JsonTablePathScan, j->lplan)->child)`. We can't reach 100%
coverage anyway because in this case we should consider the number of
states which grows as fast as pow(2, N) where N is the number of bits
in the state. This is not the goal. The goal is to catch the moment
when changes in the code break something. Which can't be done if the
code never executes. This is the gain vs the runtime involved, as
Michael put it.

So what I actually need to do is *remove* part which executes `if
(IsA(plan, JsonTablePathScan))` branch since now it is executed
without the patch. I will submit an updated version.

--
Best regards,
Aleksander Alekseev


Re: [PATCH] Cover get_json_table_plan() with tests

От:
Aleksander Alekseev <aleksander@tigerdata.com>
Дата:
Вложения:
Hi,

> I've reviewed the new version and now the coverage with this version is
> 92%, the version 2 was 95%, probably this is because the test doesn't
> cover the "UNION" case.
>
> I still wonder why you don't want to cover the 100% if it's just a small
> changes in the test, but for now, this does third version it does
> increase the coverage by 42%.

There is a line of code:

```
j->cross ? " CROSS " : " UNION "
```

The difference in coverage you are referring to is that in one case we
cover both if-else branches while in another only one of them. In my
opinion there is little practical value in covering both of them.
Executing one line of the source code at least once is enough,
regardless of what number `lcov` reports. This is always a compromise
between the coverage, the ease of maintaining it and the speed of our
tests on the buildfarm.

If anyone else believes that we should do 92% -> 95% here I will
submit the corrected patch though.

-- 
Best regards,
Aleksander Alekseev


Re: [PATCH] Cover get_json_table_plan() with tests

От:
Aleksander Alekseev <aleksander@tigerdata.com>
Дата:
Вложения:
Hi Shihao,

> Small fix: add a third path and use both sibling joins in the plan --
> PLAN (p OUTER ((p1 UNION p2) CROSS p3)). Now UNION is added so
> region coverage goes to 100% (line stays 100%). Patch attached, test
> passes.
>
> Also, given there is no other comments, move to wait for committer

Thanks for the input. The patch needed a rebase, here is v5.

It looks like you removed the previous reviewer from the commit
message and summarized only your changes, not the changes in the
entire commit. Please don't do this. In any doubt, better leave the
commit message as is. I corrected this in v5.

-- 
Best regards,
Aleksander Alekseev

Re: [PATCH] Cover get_json_table_plan() with tests

От:
shihao zhong <zhong950419@gmail.com>
Дата:
> It looks like you removed the previous reviewer  from the commit
> message and summarized only your changes, not the changes in the
>entire commit.

My bad. I must fat finger the commit message earlier 
FAQ