If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

[traceback] IntegrationTestIndexCleaner creates an existing index

RESOLVED FIXED

Status

Socorro
General
RESOLVED FIXED
27 days ago
13 days ago

People

(Reporter: willkg, Assigned: willkg)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

This test fails in the docker-based local dev environment if you've processed some crashes and then go to run the test suite:

Traceback:

"""
 socorro/unittest/external/es/test_index_cleaner.py::IntegrationTestIndexCleaner::test_delete_old_indices 
Traceback (most recent call last):
  File "/app/socorro/unittest/external/es/test_index_cleaner.py", line 74, in test_delete_old_indices
    self.index_client.create(now_index, {})
  File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 73, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/indices.py", line 107, in create
    params=params, body=body)
  File "/usr/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 318, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/usr/local/lib/python2.7/site-packages/elasticsearch/connection/http_requests.py", line 89, in perform_request
    self._raise_error(response.status_code, raw_data)
  File "/usr/local/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 124, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
RequestError: TransportError(400, u'index_already_exists_exception', u'index [socorro201734/MDBeGxh6QUC4t8Km6UZ2Zg] already exists')
"""

I think what's going on is that it's trying to create a real index, but that already exists since you were processing crashes already.

That probably means that one or more tests are munging Elasticsearch indexes and hosing any processing you might have done. We probably want all the tests to use a prefix for indexes created during running the tests.
I'll fix this next week. It's kind of irritating, but I can work around it for now by wiping out the elasticsearch container and related volumes.

$ docker-compose down elasticsearch
$ docker-compose rm -fvs elasticsearch
Assignee: nobody → willkg
Status: NEW → ASSIGNED
I trust you can fix it but one idea that comes to mind is to name the indexes with a prefix like Django does with the database when you run `./manage.py test`. 

Then you can keep your indexes intact in ES inside Docker when you start and stop it.
(In reply to Peter Bengtsson [:peterbe] from comment #2)
> I trust you can fix it but one idea that comes to mind is to name the
> indexes with a prefix like Django does with the database when you run
> `./manage.py test`. 
> 
> Then you can keep your indexes intact in ES inside Docker when you start and
> stop it.

Silly me. I read the bug description wrong. This is already an idea.
Blocks: 1387104
I can reproduce the issue like this:

1. Run the processor and process a crash. That creates the Elasticsearch indexes.

2. Get list of indices and aliases:

   $ curl localhost:9200/_aliases
   {"socorro201735":{"aliases":{}}}

   You might get different output depending on when you run it.

3. Run `make dockertest`. Because there's an index, the test_delete_old_indices will fail.

Comment 5

13 days ago
Commit pushed to master at https://github.com/mozilla-services/socorro

https://github.com/mozilla-services/socorro/commit/e1cca93f34d3df0a89e092a8cb0000ff8ae9c7de
fixes bug 1393286 - fix IntegrationTestIndexCleaner tests (#3961)

If indices existed already, then these tests will fail. That's problematic
because it also means that it's stomping on non-test data. This adds a test_
prefix so that it's only looking at test_ things and not stomping on things it
shouldn't be.

Updated

13 days ago
Status: ASSIGNED → RESOLVED
Last Resolved: 13 days ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.