#250 new test cases are not automatically created in resultsdb, crashes instead
Closed: Fixed None Opened 8 years ago by kparal.

I tried to run upgradepath with my own resultsdb, this happened:

[libtaskotron:runner.py:114] 2015-06-23 11:30:55 DEBUG   Executing directive: resultsdb
[libtaskotron:resultsdb_directive.py:194] 2015-06-23 11:30:55 DEBUG   TAP output parsed OK.
[libtaskotron:resultsdb_directive.py:221] 2015-06-23 11:30:56 INFO    Posting 54 results to ResultsDB...
[resultsdb_api:resultsdb_api.py:55] 2015-06-23 11:30:56 WARNING Received HTTP failure status code 404 for request: http://127.0.0.1:5002/api/v1.0/testcases/upgradepath
[libtaskotron:logger.py:98] 2015-06-23 11:30:56 CRITICAL Traceback (most recent call last):
  File "/home/kparal/devel/taskotron/env_taskotron/bin/runtask", line 9, in <module>
    load_entry_point('libtaskotron==0.3.14', 'console_scripts', 'runtask')()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/runner.py", line 261, in main
    task_runner.run()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/runner.py", line 61, in run
    self.do_actions()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/runner.py", line 145, in do_actions
    self.do_single_action(action)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/runner.py", line 123, in do_single_action
    self.envdata)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/directives/resultsdb_directive.py", line 224, in process
    self.ensure_testcase_exists(checkname)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/directives/resultsdb_directive.py", line 123, in ensure_testcase_exists
    raise e
ResultsDBapiException: u'Testcase not found (HTTP 404)'

This is our current code in resultsdb_directive:
```lang=python
def ensure_testcase_exists(self, name):
""" Make sure that the testcase exists in resultsdb, otherwise create
the testcase using a dummy url as a reference

    :param str name: name of the testcase to check for
    """

    if name in self._ensured_testcases:
        return

    try:
        self.resultsdb.get_testcase(name)
        self._ensured_testcases.append(name)
        return
    except resultsdb_api.ResultsDBapiException, e:
        if e.message != 'Testcase not found':
            raise e

    # since the testcase doesn't exist, create it with a dummy value for url
    # it can be updated later when it's not blocking results reporting
    dummyurl = 'http://faketestcasesRus.com/%s' % name
    self.resultsdb.create_testcase(name, dummyurl)
    self._ensured_testcases.append(name)

```

It checks for Testcase not found in the message, but the message changed to Testcase not found (HTTP 404). I think that shows why we should not rely on matching string content. There should be a specific exception type for this, or at least it should have a custom attribute.

Please introduce a specific exception type in resultsdb_api, then adjust resultsdb_directive. Make a new resultsdb_api release, then require this version in libtaskotron.


This ticket had assigned some Differential requests:
D431
D432

Metadata Update from @kparal:
- Issue tagged with: easyfix

6 years ago

Login to comment on this ticket.

Metadata