★ wanayoo — archive 1999 https://github.com/utPLSQL/utPLSQL/issues/747Nouvelle recherche | Portail wanayoo
Skip to content
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

TeamCity reporter not properly working with cursor comparison #747

Closed
PabloTorresAnaya opened this issue Aug 3, 2018 · 7 comments
Closed

TeamCity reporter not properly working with cursor comparison #747

PabloTorresAnaya opened this issue Aug 3, 2018 · 7 comments
Labels
bug

Comments

@PabloTorresAnaya
Copy link

@PabloTorresAnaya PabloTorresAnaya commented Aug 3, 2018 •

Background:

Doing a cursor comparison like this one:

    PROCEDURE PRC_T_SAMPLE_4
    IS
        l_expected   v_ref_cursor;
        l_actual     v_ref_cursor;
    BEGIN
        OPEN l_expected FOR
            SELECT * FROM SAMPLE_TABLE WHERE filter=2; --about 20 columns and 50 rows

        OPEN l_actual FOR
            SELECT * FROM SAMPLE_TABLE WHERE filter=3; --about 20 columns and 50 rows

        ut.expect (l_expected).to_equal (l_actual);
    END;

If the test fail on the teamcity report we will have something like:
##teamcity[testFailed timestamp='2018-08-03T10:11:14.221+0200' details='Actual: |r ....... ' Name='name' ]

Inside the details the xml structure of the actual cursor and the expected cursor can be found.

Issue

Teamcity is no able to detect the testFailed. So teamcity report it as green (success) when it failed, it shall be red.

Posible problem

I opened the build log of team city and the line with all XML structure was infact in diferent lines with line breaks (every 4000 characters). So i think the problem is that the output line of the Teamcity reporter was to big and teamcity was not able to parse it.

Posible fix

Trim the details string to 2500 or 3000 characters so the ##teamcity is less than 4000.

@jgebal jgebal added the bug label Aug 3, 2018
@jgebal
Copy link
Member

@jgebal jgebal commented Aug 7, 2018

It must be a bug.
Will need to investigate to see if it's possible to produce report without trimming the text.
For now you can try using ut_junit_reporter with teamcity.
You will not get the real-time progress reporting with junit, but it should be accurate and comprehensive.

@PabloTorresAnaya
Copy link
Author

@PabloTorresAnaya PabloTorresAnaya commented Aug 9, 2018

Did some more investigation on that.
The actual problem is when the cursor report the actual and expected outputs do something like
Actual: refcursor [ count = 3 ] was expected to equal: refcursor [ count = 3 ]
And teamcity spects the [] to be scaped with |
I did the following and now it works like a charm:
On the UT_TEAMCITY_REPORTER_HELPER package:

 function test_failed(a_test_name varchar2, a_msg in varchar2 default null, a_details varchar2 default null, a_flow_id varchar2 default null, a_actual varchar2 default null, a_expected varchar2 default null) return varchar2 is
    l_props t_props;
  begin
    l_props('name') := a_test_name;
    l_props('message') := a_msg;
    l_props('details') := regexp_replace(a_details,'(\[)|(\])','|\1\2');
    l_props('flowId') := a_flow_id;

    if a_actual is not null and a_expected is not null then
      l_props('actual') := regexp_replace(a_actual,'(\[)|(\])','|\1\2');
      l_props('expected') := regexp_replace(a_expected,'(\[)|(\])','|\1\2');
    end if;

    return message('testFailed', l_props);
  end;

I think there is a better place to actualy scape the brakets but it was just trying stufs.

Can you give it a try?

@jgebal
Copy link
Member

@jgebal jgebal commented Aug 9, 2018

Great stuff. You did sll thr hard work of investigation.
We will have it fixed soon.
Thanks - really helpful

@jgebal
Copy link
Member

@jgebal jgebal commented Aug 10, 2018

@PabloTorresAnaya
I'd like to experiment a bit more with the reporter.
I didn't play around with TeamCity much, but looking at documentation, it seems possible to provide larger data as outcomes of test.
We need to escape all of the special characters.
https://confluence.jetbrains.com/display/TCD18/Build+Script+Interaction+with+TeamCity

I'll install TeamCity Docker image and see if I can get utPLSQL build running there.
https://hub.docker.com/r/jetbrains/teamcity-server/

jgebal added a commit that referenced this issue Aug 11, 2018
- the `[` and `]` were not escaped
- the `"` was escaped though not needed
- If total length of message inside the square brackets exceeds 4000 characters it's causing teamcity to report success for a test failed
Resolves #747
@PabloTorresAnaya
Copy link
Author

@PabloTorresAnaya PabloTorresAnaya commented Aug 13, 2018

yes, as I mention the not-escaped character were causing the issue in the end, the lenght was a dead-end clue.
Also, with the new version of the UTPLS the cursor only report the changes and not the full set.

From my point of view, escaping the "[" ,"]" characters should be suficient.

@jgebal
Copy link
Member

@jgebal jgebal commented Aug 13, 2018

I tested on Teamcity locally (docker) with local database.
I encountered 2 issues:

  • missing escape of |[ |]
  • text longer tnan 4000
    If you're saying that you don't have any issues eith lenght that sounds strange as I sae those. Might need to ask Teamcity for explanation if the behavior is inconsistent.
@PabloTorresAnaya
Copy link
Author

@PabloTorresAnaya PabloTorresAnaya commented Aug 13, 2018

Morning,
I dont have that issue (text onlger than 4000) because now the reporter only report the changes and the length droped to 2000 wich is totaly fine for team city.

If i have time i can try to reproduce the error but i think the issue still there.

So, I agree, there are 2 issues.

@jgebal jgebal closed this in #750 Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.