test_opengauss.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import time
  2. from core.rag.datasource.vdb.opengauss.opengauss import OpenGauss, OpenGaussConfig
  3. from tests.integration_tests.vdb.test_vector_store import (
  4. AbstractVectorTest,
  5. get_example_text,
  6. setup_mock_redis,
  7. )
  8. class OpenGaussTest(AbstractVectorTest):
  9. def __init__(self):
  10. super().__init__()
  11. max_retries = 5
  12. retry_delay = 20
  13. retry_count = 0
  14. while retry_count < max_retries:
  15. try:
  16. config = OpenGaussConfig(
  17. host="localhost",
  18. port=6600,
  19. user="postgres",
  20. password="Dify@123",
  21. database="dify",
  22. min_connection=1,
  23. max_connection=5,
  24. )
  25. break
  26. except psycopg2.OperationalError as e:
  27. retry_count += 1
  28. if retry_count < max_retries:
  29. time.sleep(retry_delay)
  30. self.vector = OpenGauss(
  31. collection_name=self.collection_name,
  32. config=config,
  33. )
  34. def test_opengauss(setup_mock_redis):
  35. OpenGaussTest().run_all_tests()