def test_elastic_commit(self):
        """Test the auto_commit_interval attribute."""
        docc = {'_id': '3', 'name': 'Waldo'}
        
        # Disable 1s refresh in elasticsearch
        # https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
        disable_refresh_body = {"index" : {"refresh_interval" : "-1"}}
        self.elastic_conn.indices.put_settings(index="test",body=disable_refresh_body)

        # test cases:
        # -1 = no autocommit
        # 0 = commit immediately
        # x > 0 = commit within x seconds
        for autocommit_interval in [None, 0, 1, 2]:
            docman = DocManager(elastic_pair,auto_commit_interval=autocommit_interval)
            docman.upsert(docc, *TESTARGS)
            if autocommit_interval is None:
                docman.commit()
            else:
                # Allow just a little extra time
                time.sleep(autocommit_interval + 1)
            results = list(self._search())
            self.assertEqual(len(results), 1,
                             "should commit document with "
                             "auto_commit_interval = %s" % str(
                                 autocommit_interval))
            self.assertEqual(results[0]["name"], "Waldo")
            docman.stop()
            self._remove()
            retry_until_ok(self.elastic_conn.indices.refresh, index="")
        enable_refresh_body = {"index" : {"refresh_interval" : "1s"}}
        self.elastic_conn.indices.put_settings(index="test",body=enable_refresh_body)
 def test_elastic_commit(self):
     """Test the auto_commit_interval attribute."""
     docc = {'_id': '3', 'name': 'Waldo'}
     docman = DocManager(elastic_pair)
     # test cases:
     # -1 = no autocommit
     # 0 = commit immediately
     # x > 0 = commit within x seconds
     for autocommit_interval in [None, 0, 1, 2]:
         docman.auto_commit_interval = autocommit_interval
         docman.upsert(docc, *TESTARGS)
         if autocommit_interval is None:
             docman.commit()
         else:
             # Allow just a little extra time
             time.sleep(autocommit_interval + 1)
         results = list(self._search())
         self.assertEqual(
             len(results), 1, "should commit document with "
             "auto_commit_interval = %s" % str(autocommit_interval))
         self.assertEqual(results[0]["name"], "Waldo")
         self._remove()
     docman.stop()
 def test_elastic_commit(self):
     """Test the auto_commit_interval attribute."""
     docc = {'_id': '3', 'name': 'Waldo'}
     docman = DocManager(elastic_pair)
     # test cases:
     # -1 = no autocommit
     # 0 = commit immediately
     # x > 0 = commit within x seconds
     for autocommit_interval in [None, 0, 1, 2]:
         docman.auto_commit_interval = autocommit_interval
         docman.upsert(docc, *TESTARGS)
         if autocommit_interval is None:
             docman.commit()
         else:
             # Allow just a little extra time
             time.sleep(autocommit_interval + 1)
         results = list(self._search())
         self.assertEqual(len(results), 1,
                          "should commit document with "
                          "auto_commit_interval = %s" % str(
                              autocommit_interval))
         self.assertEqual(results[0]["name"], "Waldo")
         self._remove()
     docman.stop()