lczub / TestLink-API-Python-client

A Python client to use the TestLink API
104 stars 63 forks source link

when i use listKeywordsForTC() or getTestCaseKeywords() encounter this error #153

Closed yifei325325 closed 2 years ago

yifei325325 commented 2 years ago

Hi Lczub, @lczub Sorry to trouble you, when i invoke the listKeywordsForTC() or getTestCaseKeywords() i encounter this error .

i notice that you have filed a issue that recommend use getTestCaseKeywords() instead of listKeywordsForTC(), https://github.com/lczub/TestLink-API-Python-client/issues/45#issue-54101588 when we use the TL V1.9.19 , my script is work fine. but when we downgrade the TL to V1.9.18, the issue is showing.

the demo script like is:


class TestLinkManager(TestlinkAPIClient):

    def __init__(self, server_url=TESTLINK.get('url'), devKey=TESTLINK.get('key'), **kwargs):
        super().__init__(server_url, devKey, **kwargs)
        self.helper = DBHelper()
        self.project_name = TESTLINK.get('project')
        self.project = self.getTestProjectByName(self.project_name)
        self.project_id = self.project.get('id')
        self.test_plan_id = self.getTestPlanByName(self.project_name,TESTLINK.get("test_plan_name"))[0].get('id')
        self.top_suite = self.getFirstLevelTestSuitesForTestProject(self.project_id)

tm = TestLinkManager()
tm.listKeywordsForTC("auto-1") 

Traceback (most recent call last):
  File "C:\Users\kenny\.virtualenvs\commandserver-pZ4dU4Xi\lib\site-packages\testlink\testlinkapigeneric.py", line 2057, in _callServer
    response = getattr(self.server.tl, methodNameAPI)(argsAPI)
  File "d:\python\python38\lib\xmlrpc\client.py", line 1109, in __call__
    return self.__send(self.__name, args)
  File "d:\python\python38\lib\xmlrpc\client.py", line 1450, in __request
    response = self.__transport.request(
  File "d:\python\python38\lib\xmlrpc\client.py", line 1153, in request
    return self.single_request(host, handler, request_body, verbose)
  File "d:\python\python38\lib\xmlrpc\client.py", line 1183, in single_request
    raise ProtocolError(
xmlrpc.client.ProtocolError: <ProtocolError for 192.168.3.5/testlink/lib/api/xmlrpc/v1/xmlrpc.php: 500 Internal Server Error>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2021.1\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:/PycharmProjects/commandserver/utils/testlinkManager.py", line 418, in <module>
    tm.getTestCaseKeywords(testcaseid=10205)
  File "C:\Users\kenny\.virtualenvs\commandserver-pZ4dU4Xi\lib\site-packages\testlink\testlinkdecorators.py", line 140, in wrapperReplaceTLResponseError
    response = methodAPI(self, *argsPositional, **argsOptional)
  File "C:\Users\kenny\.virtualenvs\commandserver-pZ4dU4Xi\lib\site-packages\testlink\testlinkdecorators.py", line 112, in wrapperAddDevKey
    return methodAPI(self, *argsPositional, **argsOptional)
  File "C:\Users\kenny\.virtualenvs\commandserver-pZ4dU4Xi\lib\site-packages\testlink\testlinkdecorators.py", line 99, in wrapperWithArgs
    return self.callServerWithPosArgs(methodAPI.__name__,
  File "C:\Users\kenny\.virtualenvs\commandserver-pZ4dU4Xi\lib\site-packages\testlink\testlinkapigeneric.py", line 1582, in callServerWithPosArgs
    response = self._callServer(methodNameAPI, argsOptional)
  File "C:\Users\kenny\.virtualenvs\commandserver-pZ4dU4Xi\lib\site-packages\testlink\testlinkapigeneric.py", line 2061, in _callServer
    raise testlinkerrors.TLConnectionError(new_msg)
testlink.testlinkerrors.TLConnectionError: problems connecting the TestLink Server http://192.168.3.5/testlink/lib/api/xmlrpc/v1/xmlrpc.php
<ProtocolError for 192.168.3.5/testlink/lib/api/xmlrpc/v1/xmlrpc.php: 500 Internal Server Error>

It would really help me out if you could reply

lczub commented 2 years ago

Hello Kenny,

the returned error msg 500 Internal Server Error is a hint, that the TL server itself was running into a php error, often a failing internal sql query. You should inspect your TL server logs for further details.

Why have you downgraded from 1.9.19 to 1.9.18?

Regards Luiko

yifei325325 commented 2 years ago

Hi Luiko, Thanks for your reply. we analyzed the TL server logs but did not find any information useful. There is a bug in 1.9.19, when I try to export testcased to MS word format. that 's why I downgraded to 1.9.18. The error log like this:

#0  database->exec_query( /* Class:requirement_mgr - Method: getActiveForTCVersion */  SELECT REQ.id,REQ.id AS req_id,REQ.req_doc_id,NHREQ.name AS title, RCOV.is_active, NHRS.name AS req_spec_title,RCOV.testcase_id, REQV.id AS req_version_id, REQV.version  FROM requirements REQ  JOIN req_specs RSPEC  ON REQ.srs_id = RSPEC.id  JOIN req_coverage RCOV  ON RCOV.req_id = REQ.id  JOIN nodes_hierarchy NHRS  ON NHRS.id=RSPEC.id  JOIN nodes_hierarchy NHREQ  ON NHREQ.id=REQ.id  JOIN req_versions REQV  ON RCOV.req_version_id=REQV.id  WHERE RCOV.tcversion_id IN () AND RCOV.is_active=1 , -1, -1) called at [/var/www/html/testlink19/lib/functions/database.class.php:759]
#1  database->get_recordset( /* Class:requirement_mgr - Method: getActiveForTCVersion */  SELECT REQ.id,REQ.id AS req_id,REQ.req_doc_id,NHREQ.name AS title, RCOV.is_active, NHRS.name AS req_spec_title,RCOV.testcase_id, REQV.id AS req_version_id, REQV.version  FROM requirements REQ  JOIN req_specs RSPEC  ON REQ.srs_id = RSPEC.id  JOIN req_coverage RCOV  ON RCOV.req_id = REQ.id  JOIN nodes_hierarchy NHRS  ON NHRS.id=RSPEC.id  JOIN nodes_hierarchy NHREQ  ON NHREQ.id=REQ.id  JOIN req_versions REQV  ON RCOV.req_version_id=REQV.id  WHERE RCOV.tcversion_id IN () AND RCOV.is_active=1 ) called at [/var/www/html/testlink19/lib/functions/requirement_mgr.class.php:4604]
#2  requirement_mgr->getActiveForTCVersion() called at [/var/www/html/testlink19/lib/functions/print.inc.php:1444]
#3  renderTestCaseForPrinting(database Object ([db] => ADODB_mysqli Object ([databaseType] => mysqli,[dataProvider] => mysql,[hasInsertID] => 1,[hasAffectedRows] => 1,[metaTablesSQL] => SELECT
            TABLE_NAME,
            CASE WHEN TABLE_TYPE = 'VIEW' THEN 'V' ELSE 'T' END
        FROM INFORMATION_SCHEMA.TABLES
        WHERE TABLE_SCHEMA=,[metaColumnsSQL] => SHOW COLUMNS FROM `%s`,[fmtTimeStamp] => 'Y-m-d H:i:s',[hasLimit] => 1,[hasMoveFirst] => 1,[hasGenID] => 1,[isoDates] => 1,[sysDate] => CURDATE(),[sysTimeStamp] => NOW(),[hasTransactions] => 1,[forceNewConnect] => 1,[poorAffectedRows] => 1,[clientFlags] => 0,[substr] => substring,[port] => 3306,[socket] => ,[_bindInputArray] => ,[nameQuote] => `,[optionFlags] => Array ([0] => Array ([0] => 5,[1] => 0)),[arrayClass] => ADORecordSet_array_mysqli,[multiQuery] => ,[_genIDSQL] => update %s set id=LAST_INSERT_ID(id+1);,[_genSeqSQL] => create table if not exists %s (id int not null),[_genSeqCountSQL] => select count(*) from %s,[_genSeq2SQL] => insert into %s values (%s),[_dropSeqSQL] => drop table if exists %s,[database] => testlink19,[host] => localhost,[user] => testlink,[password] => not stored,[debug] => ,[maxblobsize] => 262144,[concat_operator] => +,[length] => length,[random] => rand(),[upperCase] => upper,[fmtDate] => 'Y-m-d',[true] => 1,[false] => 0,[replaceQuote] => \',[charSet] => ,[metaDatabasesSQL] => ,[uniqueOrderBy] => ,[emptyDate] =>  ,[emptyTimeStamp] =>  ,[lastInsID] => ,[hasTop] => ,[readOnly] => ,[genID] => 0,[raiseErrorFn] => ,[cacheSecs] => 3600,[memCache] => ,[memCacheHost] => ,[memCachePort] => 11211,[memCacheCompress] => ,[sysUTimeStamp] => ,[noNullStrings] => ,[numCacheHits] => 0,[numCacheMisses] => 0,[pageExecuteCountRows] => 1,[uniqueSort] => ,[leftOuter] => ,[rightOuter] => ,[ansiOuter] => ,[autoRollback] => ,[fnExecute] => ,[fnCacheExecute] => ,[blobEncodeType] => ,[rsPrefix] => ADORecordSet_,[autoCommit] => 1,[transOff] => 0,[transCnt] => 0,[fetchMode] => 2,[null2null] => null,[bulkBind] => ,[_oldRaiseFn] => ,[_transOK] => ,[_connectionID] => mysqli Object ([affected_rows] => ,[client_info] => ,[client_version] => ,[connect_errno] => ,[connect_error] => ,[errno] => ,[error] => ,[error_list] => ,[field_count] => ,[host_info] => ,[info] => ,[insert_id] => ,[server_info] => ,[server_version] => ,[stat] => ,[sqlstate] => ,[protocol_version] => ,[thread_id] => ,[warning_count] => ),[_errorMsg] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND RCOV.is_active=1' at line 1,[_errorCode] => ,[_queryID] => 1,[_isPersistentConnection] => ,[_evalAll] => ,[_affected] => ,[_logsql] => ,[_transmode] => ,[*connectionParameters] => Array (),[databaseName] => testlink19),[queries_array] => Array (),[is_connected] => 1,[nQuery] => 0,[overallDuration] => 0,[dbType] => mysqli,[databaselogEnabled] => 0,[databaselogQueries] => 0), Array ([parent_id] => 24453,[id] => 24454,[name] => ChromeOS/Chrome native screen mirroring,[childNodes] => ,[node_table] => testcases,[node_type_id] => 3,[node_order] => 1), Array ([toc] => 1,[headerNumbering] => 1,[header] => 1,[summary] => 1,[body] => 1,[author] => 1,[keyword] => 1,[cfields] => 1,[requirement] => 1,[req_spec_scope] => 1,[req_spec_author] => 1,[req_spec_overwritten_count_reqs] => 1,[req_spec_type] => 1,[req_spec_cf] => 1,[req_scope] => 1,[req_author] => 1,[req_status] => 1,[req_type] => 1,[req_cf] => 1,[req_relations] => 1,[req_linked_tcs] => 1,[req_coverage] => 1,[displayVersion] => 1,[execResultsByCFOnExecCombination] => 1,[notes] => 1,[step_exec_notes] => ,[passfail] => ,[step_exec_status] => ,[build_cfields] => 1,[metrics] => 1,[docType] => testspec,[tocCode] => 

Fortunately we upgraded to 1.9.20 DEV and everthing looks good. So we plan to use this version . Anyway Thank you and your team so much!