Debugging EIF connector source code

Document created by JohnStreeter Employee on Feb 5, 2018Last modified by JohnStreeter Employee on Feb 5, 2018
Version 2Show Document
  • View in full screen mode

If you wish to experiment with the EIF source code, either for debugging or adding enhancements, here’s how it can be done. For this example, I will use the Quality Center connector, version 2.8.8 and an MS-DOS command window.

 

Some background:

When the connector executable is invoked, it will extract itself into a new temporary folder which will contain an entire Ruby environment and all the connector source code. This is why we are able to run the connector on a PC which does not have Ruby installed. Once the connector is finished, it will remove this temporary folder, thus wiping out its tracks. The task described below basically captures a copy of that temporary folder while the connect is running.

 

  1. Install the QC connector on a PC (your client).

 

  1. Create a configuration file which will purposely cause an error (a stack trace). I used the following (fail.xml) as it will fail login to CA Agile Central:

<config>
<RallyConnection>
<Url>rally1.rallydev.com</Url>
<WorkspaceName>foo</WorkspaceName>
<Projects>
<Project>foo</Project>
</Projects>
<User>foo@foo.com</User>
<Password>encoded-f-o-o-=-</Password>
<ArtifactType>UserStory</ArtifactType>
<ExternalIDField>Foo</ExternalIDField>
</RallyConnection>

<QCConnection>
<Url>vmwin2008qc11.f4tech.com:8080</Url>
<Domain>DEFAULT</Domain>
<Project>JPproject11</Project>
<User>jpqc</User>
<Password>encoded-x-x-x-x-b-H-l-k-Z-X-x-=-</Password>
<ArtifactType>REQ</ArtifactType>
<IDField>RQ_REQ_ID</IDField>
<ExternalIDField>foo</ExternalIDField>
</QCConnection>

<ConnectorRunner>
<Preview>True</Preview>
<LogLevel>Debug</LogLevel>
<Services>COPY_QC_TO_RALLY</Services>
</ConnectorRunner>
</config>

 

  1. Invoke the connector with the configuration file using the following command. The last argument (10) tells the connector to run every ten minutes and it is this delay that allows us to easily capture a copy of this elusive temporary directory.

set qc="C:\Program Files (x86)\RallyConnectorforQualityCenter\rally2_qc_connector.exe"
%qc%  fail.xml  10

 

  1. In the log file, there should be some stack trace information like this:

….
INFO : RallyConnection.connect - Connecting to CA Agile Central at https://rally1.rallydev.com/slm as user foo@foo.com
DEBUG : RallyConnection.rescue in connect - CA Agile Central::NotAuthenticatedError: Invalid Username or Password.
ERROR : RallyConnection.rescue in connect - Could not connect to CA Agile Central at https://rally1.rallydev.com/slm ...
ERROR : RallyConnection.initialize - Invalid Username or Password.
ERROR : ConnectorRunner.exception - Message Invalid Username or Password.
ERROR : ConnectorRunner.exception - Stack Trace
ERROR : ConnectorRunner.block in exception -
C:/Users/jpkole/AppData/Local/Temp/ocrE96F.tmp/lib/ruby/gems/1.9.1/gems/rally_rest_api-1.0.5/lib/rally_rest_api/rest_builder.rb:165:in `check_for_errors'
….
 
  1. The reason for forcing a stack trace is to get the full path to the temporary directory where the connector expands into. In the above example, the temporary directory is this part of the path:

C:/Users/jpkole/AppData/Local/Temp/ocrE96F.tmp

 

  1. Our goal is to get a copy of that directory, while the connector is running, since the directory will be deleted once the connector exits. Also, that directory is (usually) protected and invisible, therefore you cannot just step down into it using the Windows Explorer. You can, however cut-n-paste this string: “C:\Users\jpkole\Local Settings\Temp” into the Windows Explorer address box and it will open the directory. Once there, we can make a copy of the “ocrE96F.tmp” directory (FYI: the “ocr” is from “OCRA (One-Click Ruby Application)”; more information here: https://www.ruby-toolbox.com/categories/packaging_to_executables) .

 

  1. The copying of this directory should show about 941 files for a total size of 17mb (at least it did for version 2.8.8 of the QC connector).

 

  1. Now we have the total structure of the QC connector at our fingertips. We can move our copy of the directory to wherever we want. For this example I’ll put it at “C:\Users\jpkole\JPKoleQC\QC-2.8.8”.  Once done, we can invoke this private copy of the connector (instead of the officially installed one) via these MS-DOS commands:

set myruby="C:\Users\jpkole\JPKoleQC\QC-2.8.8\bin\ruby.exe"
set mycntr="C:\Users\jpkole\JPKoleQC\QC-2.8.8\src\rally2_qc_connector.rb"
%myruby%  %mycntr%  fail.xml  -1

 

  1. Now we can start modifying the source and testing our changes.  For this example, we will make a simple change: there is a Ruby file in the connector source tree called “rally_connection.rb”, and it is responsible for making a connection to CA Agile Central, and before doing so it prints the following message into the log file:

Connecting to CA Agile Central at https://rally1.rallydev.com/slm as user foo@foo.com

 

If we edit the source file, which can be found in this directory:

C:\Users\jpkole\JPKoleQC\QC-2.8.8\lib\ruby\gems\1.9.1\gems\yeti-2.8.8\lib\yeti\

 

We should see that line 100 of the file looks like this:

 98  ….
 99  def connect(integration_headers = {})
100      RallyLogger.info(self, "Connecting to CA Agile Central at #{@url} as user #{@user}")
101      custom_headers = get_custom_headers(integration_headers)
102  ….

 

And for this experiment, let’s modify it to look like this (add the string “JP’s”):

98  ….
 99  def connect(integration_headers = {})
100      RallyLogger.info(self, "Connecting to JP's CA Agile Central at #{@url} as user #{@user}")
101      custom_headers = get_custom_headers(integration_headers)
102  ….
 
  1. Now when we invoke our copy of the connector, we should see the following in the log file:

….
INFO : RallyConnection.connect - Connecting to JP's CA Agile Central at https://rally1.rallydev.com/slm as user foo@foo.com
DEBUG : RallyConnection.rescue in connect - CA Agile Central::NotAuthenticatedError: Invalid Username or Password.
ERROR : RallyConnection.rescue in connect - Could not connect to CA Agile Central at https://rally1.rallydev.com/slm ….
ERROR : RallyConnection.initialize - Invalid Username or Password.
ERROR : ConnectorRunner.exception - Message Invalid Username or Password.
ERROR : ConnectorRunner.exception - Stack Trace
….

 

  1. And that’s it... you’re now well on your way to becoming dangerous.  If you happen to make some cool code changes or bug fixes, please consider getting the Integration folks (or me) to commit them to the source tree as permanent changes.


[the end]

Attachments

    Outcomes