Skip to content

Commit

Permalink
Lifecycle integration tests.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Nov 27, 2024
1 parent bf9add4 commit 571aa9e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
6 changes: 5 additions & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ test_opensearchpy/test_connection.py::TestRequestsConnection::test_no_http_compr
test_opensearchpy/test_async/test_connection.py::TestAIOHttpConnection::test_no_http_compression PASSED [100%]
```

Note that integration tests require docker to be installed and running, and downloads quite a bit of data from over the internet and hence take few minutes to complete.
```
./.ci/run-tests false 2.16.0 test_indices_lifecycle
```

Note that integration tests require docker to be installed and running, and downloads quite a bit of data from the internet and hence take few minutes to complete.

## Linter

Expand Down
43 changes: 43 additions & 0 deletions test_opensearchpy/test_server/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,49 @@


class TestUnicode(OpenSearchTestCase):
def test_indices_lifecycle_english(self) -> None:
index_name = "movies"

index_create_result = self.client.indices.create(index=index_name)
self.assertTrue(index_create_result['acknowledged'])
self.assertEqual(index_name, index_create_result['index'])

document = {'name': 'Solaris', 'director': 'Andrei Tartakovsky', 'year': '2011'}
id = 'solaris@2011'
doc_insert_result = self.client.index(index=index_name, body=document, id=id, refresh=True)
self.assertEqual('created', doc_insert_result['result'])
self.assertEqual(index_name, doc_insert_result['_index'])
self.assertEqual(id, doc_insert_result['_id'])

doc_delete_result = self.client.delete(index=index_name, id=id)
self.assertEqual('deleted', doc_delete_result['result'])
self.assertEqual(index_name, doc_delete_result['_index'])
self.assertEqual(id, doc_delete_result['_id'])

index_delete_result = self.client.indices.delete(index=index_name)
self.assertTrue(index_delete_result['acknowledged'])

def test_indices_lifecycle_russian(self) -> None:
index_name = "кино"
index_create_result = self.client.indices.create(index=index_name)
self.assertTrue(index_create_result['acknowledged'])
self.assertEqual(index_name, index_create_result['index'])

document = {'название': 'Солярис', 'автор': 'Андрей Тарковский', 'год': '2011'}
id = 'соларис@2011'
doc_insert_result = self.client.index(index=index_name, body=document, id=id, refresh=True)
self.assertEqual('created', doc_insert_result['result'])
self.assertEqual(index_name, doc_insert_result['_index'])
self.assertEqual(id, doc_insert_result['_id'])

doc_delete_result = self.client.delete(index=index_name, id=id)
self.assertEqual('deleted', doc_delete_result['result'])
self.assertEqual(index_name, doc_delete_result['_index'])
self.assertEqual(id, doc_delete_result['_id'])

index_delete_result = self.client.indices.delete(index=index_name)
self.assertTrue(index_delete_result['acknowledged'])

def test_indices_analyze(self) -> None:
self.client.indices.analyze(body='{"text": "привет"}')

Expand Down

0 comments on commit 571aa9e

Please sign in to comment.