loopbackio / loopback-connector-elastic-search

Strongloop Loopback connector for Elasticsearch
MIT License
79 stars 56 forks source link

Test for findByIds fails #6

Open pulkitsinghal opened 9 years ago

pulkitsinghal commented 9 years ago

I've temporarily commented out the part of the test which fails.

The original test case was available at: https://github.com/strongloop/loopback-datasource-juggler/blob/master/test/basic-querying.test.js

I simply copied and repurposed it here: https://github.com/strongloop-community/loopback-connector-elastic-search/blob/master/test/02.basic-querying.test.js

In order to reproduce the problem:

  1. un-comment the following lines:
names.should.eql( // NOTE: order doesn't add up, is 2.ii.iii broken?
    [createdUsers[2].name, createdUsers[1].name, createdUsers[0].name]);
  1. comment-out the following lines:

    names.should.include(createdUsers[2].name);
    names.should.include(createdUsers[1].name);
    names.should.include(createdUsers[0].name);
pulkitsinghal commented 9 years ago

After you follow the steps above to reproduce the problem: You will see a failure like the following in logs when you run DEBUG=loopback:connector:* mocha:

loopback:connector:elasticsearch ESConnector.prototype.all +0ms model User result [
  {
    "seq": 1,
    "name": "a",
    "vip": true
  },
  {
    "seq": 2,
    "name": "b"
  },
  {
    "seq": 3,
    "name": "c"
  }
]
Possibly unhandled AssertionError: expected [ 'a', 'b', 'c' ] to deeply equal [ 'c', 'b', 'a' ]
    at /Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/test/02.basic-querying.test.js:160:38
    at /Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/node_modules/loopback-datasource-juggler/lib/dao.js:721:5
    at allCb (/Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/node_modules/loopback-datasource-juggler/lib/dao.js:1210:7)
    at /Users/pulkitsinghal/dev/shoppinpal/loopback-connector-elasticsearch/lib/esConnector.js:705:17
    ...
pulkitsinghal commented 9 years ago

@raymondfeng - Is the core code unable to sort when the id is represented by something other than id? Like seq in this example? If so, would you mind opening an issues in the appropriate repository and leaving a reference to it here as well.

pulkitsinghal commented 8 years ago
  1. find code that tries to add sort order and tell it not to do so because findByIds isn't meant to work like that
  2. can get clues from how mongo connector tracks the calling method name to accomplish the same thing