diff --git a/integration/conftest.py b/integration/conftest.py index 73a032f57..3c9240215 100644 --- a/integration/conftest.py +++ b/integration/conftest.py @@ -44,6 +44,33 @@ from weaviate.exceptions import UnexpectedStatusCodeError +_DEFAULT_HOST: str = os.environ.get("WV_TEST_HOST", "localhost") +_DEFAULT_VECTOR_HOST: str = os.environ.get("WV_TEST_VECTOR_HOST", "localhost") +_DEFAULT_CLUSTER_HOST: str = os.environ.get("WV_TEST_CLUSTER_HOST", "localhost") +_DEFAULT_RBAC_HOST: str = os.environ.get("WV_TEST_RBAC_HOST", "localhost") +_DEFAULT_BROKEN_HOST: str = os.environ.get("WV_TEST_BROKEN_HOST", "localhost") +_DEFAULT_PRIMARY_PORTS: Tuple[int, int] = ( + int(os.environ.get("WV_TEST_REST_PORT", "8080")), + int(os.environ.get("WV_TEST_GRPC_PORT", "50051")), +) +_DEFAULT_VECTOR_PORTS: Tuple[int, int] = ( + int(os.environ.get("WV_TEST_VECTOR_REST_PORT", "8086")), + int(os.environ.get("WV_TEST_VECTOR_GRPC_PORT", "50057")), +) +_DEFAULT_CLUSTER_PORTS: Tuple[int, int] = ( + int(os.environ.get("WV_TEST_CLUSTER_REST_PORT", "8087")), + int(os.environ.get("WV_TEST_CLUSTER_GRPC_PORT", "50058")), +) +_DEFAULT_RBAC_PORTS: Tuple[int, int] = ( + int(os.environ.get("WV_TEST_RBAC_REST_PORT", "8092")), + int(os.environ.get("WV_TEST_RBAC_GRPC_PORT", "50063")), +) +_DEFAULT_BROKEN_PORTS: Tuple[int, int] = ( + int(os.environ.get("WV_TEST_BROKEN_REST_PORT", "8888")), + int(os.environ.get("WV_TEST_BROKEN_GRPC_PORT", "55555")), +) + + class CollectionFactory(Protocol): """Typing for fixture.""" @@ -59,7 +86,7 @@ def __call__( multi_tenancy_config: Optional[_MultiTenancyConfigCreate] = None, generative_config: Optional[_GenerativeProvider] = None, headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, data_model_properties: Optional[Type[Properties]] = None, data_model_refs: Optional[Type[Properties]] = None, replication_config: Optional[_ReplicationConfigCreate] = None, @@ -81,7 +108,7 @@ class ClientFactory(Protocol): def __call__( self, headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, auth_credentials: Optional[weaviate.auth.AuthCredentials] = None, ) -> weaviate.WeaviateClient: """Typing for fixture.""" @@ -94,12 +121,13 @@ def client_factory() -> Generator[ClientFactory, None, None]: def _factory( headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, auth_credentials: Optional[weaviate.auth.AuthCredentials] = None, ) -> weaviate.WeaviateClient: nonlocal client_fixture if client_fixture is None: client_fixture = weaviate.connect_to_local( + host=_DEFAULT_HOST, headers=headers, grpc_port=ports[1], port=ports[0], @@ -134,7 +162,7 @@ def _factory( multi_tenancy_config: Optional[_MultiTenancyConfigCreate] = None, generative_config: Optional[_GenerativeProvider] = None, headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, data_model_properties: Optional[Type[Properties]] = None, data_model_refs: Optional[Type[Properties]] = None, replication_config: Optional[_ReplicationConfigCreate] = None, @@ -210,7 +238,7 @@ async def __call__( multi_tenancy_config: Optional[_MultiTenancyConfigCreate] = None, generative_config: Optional[_GenerativeProvider] = None, headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, data_model_properties: Optional[Type[Properties]] = None, data_model_refs: Optional[Type[Properties]] = None, replication_config: Optional[_ReplicationConfigCreate] = None, @@ -228,7 +256,7 @@ class AsyncClientFactory(Protocol): async def __call__( self, headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, ) -> weaviate.WeaviateAsyncClient: """Typing for fixture.""" ... @@ -240,11 +268,12 @@ async def async_client_factory() -> AsyncGenerator[AsyncClientFactory, None]: async def _factory( headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, ) -> weaviate.WeaviateAsyncClient: nonlocal client_fixture if client_fixture is None: client_fixture = weaviate.use_async_with_local( + host=_DEFAULT_HOST, headers=headers, grpc_port=ports[1], port=ports[0], @@ -278,7 +307,7 @@ async def _factory( multi_tenancy_config: Optional[_MultiTenancyConfigCreate] = None, generative_config: Optional[_GenerativeProvider] = None, headers: Optional[Dict[str, str]] = None, - ports: Tuple[int, int] = (8080, 50051), + ports: Tuple[int, int] = _DEFAULT_PRIMARY_PORTS, data_model_properties: Optional[Type[Properties]] = None, data_model_refs: Optional[Type[Properties]] = None, replication_config: Optional[_ReplicationConfigCreate] = None, @@ -369,7 +398,7 @@ def _factory( Property(name="extra", data_type=DataType.TEXT), ], generative_config=Configure.Generative.openai(), - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, headers={"X-OpenAI-Api-Key": api_key}, ) @@ -418,7 +447,7 @@ async def _factory( Property(name="extra", data_type=DataType.TEXT), ], generative_config=Configure.Generative.openai(), - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, headers={"X-OpenAI-Api-Key": api_key}, ) diff --git a/integration/test_auth.py b/integration/test_auth.py index dae8f863b..f989cf142 100644 --- a/integration/test_auth.py +++ b/integration/test_auth.py @@ -15,11 +15,15 @@ from weaviate.collections.classes.filters import Filter from weaviate.exceptions import AuthenticationFailedError, UnexpectedStatusCodeError -ANON_PORT = 8080 -OKTA_PORT_CC = 8082 -OKTA_PORT_USERS = 8083 -WCS_PORT = 8085 -WCS_PORT_GRPC = 50056 +ANON_PORT = int(os.environ.get("WV_TEST_REST_PORT", "8080")) +OKTA_PORT_CC = int(os.environ.get("WV_TEST_OIDC_OKTA_CC_PORT", "8082")) +OKTA_PORT_USERS = int(os.environ.get("WV_TEST_OIDC_OKTA_USERS_PORT", "8083")) +WCS_PORT = int(os.environ.get("WV_TEST_AUTH_REST_PORT", "8085")) +WCS_PORT_GRPC = int(os.environ.get("WV_TEST_AUTH_GRPC_PORT", "50056")) + +ANON_HOST = os.environ.get("WV_TEST_HOST", "localhost") +OIDC_HOST = os.environ.get("WV_TEST_OIDC_HOST", "localhost") +WCS_HOST = os.environ.get("WV_TEST_AUTH_HOST", "localhost") def is_auth_enabled(url: str) -> bool: @@ -29,28 +33,29 @@ def is_auth_enabled(url: str) -> bool: def test_no_auth_provided() -> None: """Test exception when trying to access a weaviate that requires authentication.""" - assert is_auth_enabled(f"localhost:{OKTA_PORT_CC}") + assert is_auth_enabled(f"{OIDC_HOST}:{OKTA_PORT_CC}") with pytest.raises(AuthenticationFailedError): - weaviate.connect_to_local(port=OKTA_PORT_CC) + weaviate.connect_to_local(host=OIDC_HOST, port=OKTA_PORT_CC) @pytest.mark.parametrize( - "name,env_variable_name,port,scope", + "name,env_variable_name,host,port,scope", [ - ("okta", "OKTA_CLIENT_SECRET", OKTA_PORT_CC, "some_scope"), + ("okta", "OKTA_CLIENT_SECRET", OIDC_HOST, OKTA_PORT_CC, "some_scope"), ], ) def test_authentication_client_credentials( - name: str, env_variable_name: str, port: int, scope: Optional[str] + name: str, env_variable_name: str, host: str, port: int, scope: Optional[str] ) -> None: """Test client credential flow with various providers.""" client_secret = os.environ.get(env_variable_name) if client_secret is None: pytest.skip(f"No {name} login data found.") - assert is_auth_enabled(f"localhost:{port}") + assert is_auth_enabled(f"{host}:{port}") with weaviate.connect_to_local( + host=host, port=port, auth_credentials=wvc.init.Auth.client_credentials(client_secret=client_secret, scope=scope), ) as client: @@ -58,12 +63,13 @@ def test_authentication_client_credentials( @pytest.mark.parametrize( - "name,user,env_variable_name,port,scope,warning", + "name,user,env_variable_name,host,port,scope,warning", [ ( # WCS keycloak times out too often "WCS", "oidc-test-user@weaviate.io", "WCS_DUMMY_CI_PW", + WCS_HOST, WCS_PORT, None, False, @@ -72,6 +78,7 @@ def test_authentication_client_credentials( "okta", "test@test.de", "OKTA_DUMMY_CI_PW", + OIDC_HOST, OKTA_PORT_USERS, "some_scope offline_access", False, @@ -80,6 +87,7 @@ def test_authentication_client_credentials( "okta - no refresh", "test@test.de", "OKTA_DUMMY_CI_PW", + OIDC_HOST, OKTA_PORT_USERS, "some_scope", True, @@ -91,12 +99,13 @@ def test_authentication_user_pw( name: str, user: str, env_variable_name: str, + host: str, port: int, scope: str, warning: bool, ) -> None: """Test authentication using Resource Owner Password Credentials Grant (User + PW).""" - assert is_auth_enabled(f"localhost:{port}") + assert is_auth_enabled(f"{host}:{port}") pw = os.environ.get(env_variable_name) if pw is None: @@ -107,7 +116,7 @@ def test_authentication_user_pw( else: auth = wvc.init.Auth.client_password(username=user, password=pw) - with weaviate.connect_to_local(port=port, auth_credentials=auth) as client: + with weaviate.connect_to_local(host=host, port=port, auth_credentials=auth) as client: client.collections.list_all() # no exception if warning: @@ -124,12 +133,14 @@ def test_authentication_user_pw( def test_client_with_authentication_with_anon_weaviate() -> None: """Test that we warn users when their client has auth enabled, but weaviate has only anon access.""" - assert not is_auth_enabled(f"localhost:{ANON_PORT}") + assert not is_auth_enabled(f"{ANON_HOST}:{ANON_PORT}") auth = wvc.init.Auth.client_password(username="someUser", password="SomePw") with pytest.warns(UserWarning) as recwarn: warnings.filterwarnings(action="ignore", message=r"datetime.datetime.utcnow") - with weaviate.connect_to_local(auth_credentials=auth) as client: + with weaviate.connect_to_local( + host=ANON_HOST, port=ANON_PORT, auth_credentials=auth + ) as client: client.collections.list_all() if len(recwarn) > 1: for rwarning in recwarn.list: @@ -163,27 +174,29 @@ def _get_access_token(url: str, user: str, pw: str) -> Dict[str, str]: @pytest.mark.parametrize( - "name,user,env_variable_name,port", + "name,user,env_variable_name,host,port", [ ( # WCS keycloak times out too often "WCS", "oidc-test-user@weaviate.io", "WCS_DUMMY_CI_PW", + WCS_HOST, WCS_PORT, ), ( "okta", "test@test.de", "OKTA_DUMMY_CI_PW", + OIDC_HOST, OKTA_PORT_USERS, ), ], ) def test_authentication_with_bearer_token( - name: str, user: str, env_variable_name: str, port: int + name: str, user: str, env_variable_name: str, host: str, port: int ) -> None: """Test authentication using existing bearer token.""" - url = f"localhost:{port}" + url = f"{host}:{port}" assert is_auth_enabled(url) pw = os.environ.get(env_variable_name) if pw is None: @@ -196,13 +209,13 @@ def test_authentication_with_bearer_token( expires_in=int(token["expires_in"]), refresh_token=token["refresh_token"], ) - with weaviate.connect_to_local(port=port, auth_credentials=auth) as client: + with weaviate.connect_to_local(host=host, port=port, auth_credentials=auth) as client: client.collections.exists("something") def test_authentication_with_bearer_token_no_refresh() -> None: """Test authentication using existing bearer token.""" - url = f"localhost:{OKTA_PORT_USERS}" + url = f"{OIDC_HOST}:{OKTA_PORT_USERS}" assert is_auth_enabled(url) pw = os.environ.get("OKTA_DUMMY_CI_PW") if pw is None: @@ -215,30 +228,37 @@ def test_authentication_with_bearer_token_no_refresh() -> None: expires_in=int(token["expires_in"]), ) with pytest.warns(UserWarning) as recwarn: - with weaviate.connect_to_local(port=OKTA_PORT_USERS, auth_credentials=auth) as client: + with weaviate.connect_to_local( + host=OIDC_HOST, port=OKTA_PORT_USERS, auth_credentials=auth + ) as client: client.collections.list_all() assert len(recwarn) == 1 assert str(recwarn.list[0].message).startswith("Auth002") def test_api_key_string() -> None: - assert is_auth_enabled(f"localhost:{WCS_PORT}") - with weaviate.connect_to_local(port=WCS_PORT, auth_credentials="my-secret-key") as client: + assert is_auth_enabled(f"{WCS_HOST}:{WCS_PORT}") + with weaviate.connect_to_local( + host=WCS_HOST, port=WCS_PORT, auth_credentials="my-secret-key" + ) as client: client.collections.list_all() def test_api_key() -> None: - assert is_auth_enabled(f"localhost:{WCS_PORT}") + assert is_auth_enabled(f"{WCS_HOST}:{WCS_PORT}") with weaviate.connect_to_local( - port=WCS_PORT, auth_credentials=wvc.init.Auth.api_key(api_key="my-secret-key") + host=WCS_HOST, + port=WCS_PORT, + auth_credentials=wvc.init.Auth.api_key(api_key="my-secret-key"), ) as client: client.collections.list_all() @pytest.mark.parametrize("creds", [None, grpc.ssl_channel_credentials()]) def test_custom_grpc_credentials(creds: Optional[grpc.ChannelCredentials]) -> None: - assert is_auth_enabled(f"localhost:{WCS_PORT}") + assert is_auth_enabled(f"{WCS_HOST}:{WCS_PORT}") with weaviate.connect_to_local( + host=WCS_HOST, port=WCS_PORT, grpc_port=WCS_PORT_GRPC, auth_credentials=wvc.init.Auth.api_key(api_key="my-secret-key"), @@ -251,29 +271,32 @@ def test_custom_grpc_credentials(creds: Optional[grpc.ChannelCredentials]) -> No @pytest.mark.parametrize("header_name", ["Authorization", "authorization"]) def test_api_key_in_header(header_name: str) -> None: - assert is_auth_enabled(f"localhost:{WCS_PORT}") + assert is_auth_enabled(f"{WCS_HOST}:{WCS_PORT}") with weaviate.connect_to_local( - port=WCS_PORT, headers={header_name: "Bearer my-secret-key"} + host=WCS_HOST, port=WCS_PORT, headers={header_name: "Bearer my-secret-key"} ) as client: client.collections.list_all() def test_api_key_wrong_key() -> None: - assert is_auth_enabled(f"localhost:{WCS_PORT}") + assert is_auth_enabled(f"{WCS_HOST}:{WCS_PORT}") with pytest.raises(UnexpectedStatusCodeError) as e: weaviate.connect_to_local( - port=WCS_PORT, auth_credentials=wvc.init.Auth.api_key(api_key="my-secret-key-wrong") + host=WCS_HOST, + port=WCS_PORT, + auth_credentials=wvc.init.Auth.api_key(api_key="my-secret-key-wrong"), ) assert e.value.status_code == 401 def test_auth_e2e(request: SubRequest) -> None: name = _sanitize_collection_name(request.node.name) - url = f"localhost:{WCS_PORT}" + url = f"{WCS_HOST}:{WCS_PORT}" assert is_auth_enabled(url) with weaviate.connect_to_local( + host=WCS_HOST, port=WCS_PORT, grpc_port=WCS_PORT_GRPC, auth_credentials=wvc.init.Auth.api_key(api_key="my-secret-key"), diff --git a/integration/test_client_debug.py b/integration/test_client_debug.py index d9b2777c2..8f1f81e51 100644 --- a/integration/test_client_debug.py +++ b/integration/test_client_debug.py @@ -1,6 +1,7 @@ import pytest from integration.conftest import ( + _DEFAULT_CLUSTER_PORTS, AsyncClientFactory, AsyncCollectionFactory, ClientFactory, @@ -52,9 +53,9 @@ async def test_get_object_single_node_async( def test_get_object_multi_node( client_factory: ClientFactory, collection_factory: CollectionFactory ) -> None: - client = client_factory(ports=(8087, 50058)) + client = client_factory(ports=_DEFAULT_CLUSTER_PORTS) collection = collection_factory( - ports=(8087, 50058), properties=[Property(name="name", data_type=DataType.TEXT)] + ports=_DEFAULT_CLUSTER_PORTS, properties=[Property(name="name", data_type=DataType.TEXT)] ) uuid = collection.data.insert({"name": "John Doe"}) diff --git a/integration/test_collection_config.py b/integration/test_collection_config.py index 3f33a30b7..e18902f72 100644 --- a/integration/test_collection_config.py +++ b/integration/test_collection_config.py @@ -47,12 +47,17 @@ WeaviateInvalidInputError, WeaviateUnsupportedFeatureError, ) -from integration.conftest import retry_on_http_error +from integration.conftest import ( + _DEFAULT_CLUSTER_HOST, + _DEFAULT_CLUSTER_PORTS, + _DEFAULT_VECTOR_PORTS, + retry_on_http_error, +) @pytest.fixture(scope="module") def client() -> Generator[weaviate.WeaviateClient, None, None]: - client = weaviate.connect_to_local(port=8087) + client = weaviate.connect_to_local(host=_DEFAULT_CLUSTER_HOST, port=_DEFAULT_CLUSTER_PORTS[0]) client.collections.delete_all() yield client client.collections.delete_all() @@ -407,7 +412,7 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None Property(name="name", data_type=DataType.TEXT), Property(name="age", data_type=DataType.INT), ], - ports=(8087, 50058), + ports=_DEFAULT_CLUSTER_PORTS, multi_tenancy_config=Configure.multi_tenancy( enabled=True, auto_tenant_creation=False, auto_tenant_activation=False ), @@ -1795,12 +1800,12 @@ def is_supported(): def test_config_multi_vector_enabled( collection_factory: CollectionFactory, ) -> None: - dummy = collection_factory("dummy", ports=(8086, 50057)) + dummy = collection_factory("dummy", ports=_DEFAULT_VECTOR_PORTS) if dummy._connection._weaviate_version.is_lower_than(1, 29, 0): pytest.skip("Multi vector is not supported in Weaviate versions lower than 1.29.0") collection = collection_factory( - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, properties=[Property(name="name", data_type=DataType.TEXT)], vector_config=[ Configure.MultiVectors.text2vec_jinaai( @@ -1823,7 +1828,7 @@ def test_config_multi_vector_disabled( collection_factory: CollectionFactory, ) -> None: collection = collection_factory( - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, properties=[Property(name="name", data_type=DataType.TEXT)], vectorizer_config=[ Configure.NamedVectors.text2vec_cohere( @@ -1842,12 +1847,12 @@ def test_config_multi_vector_disabled( def test_config_muvera_enabled( collection_factory: CollectionFactory, ) -> None: - dummy = collection_factory("dummy", ports=(8086, 50057)) + dummy = collection_factory("dummy", ports=_DEFAULT_VECTOR_PORTS) if dummy._connection._weaviate_version.is_lower_than(1, 31, 0): pytest.skip("Muvera is not supported in Weaviate versions lower than 1.31.0") collection = collection_factory( - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, properties=[Property(name="name", data_type=DataType.TEXT)], vector_config=[ Configure.MultiVectors.text2vec_jinaai( @@ -1871,12 +1876,12 @@ def test_config_muvera_enabled( def test_config_muvera_disabled( collection_factory: CollectionFactory, ) -> None: - dummy = collection_factory("dummy", ports=(8086, 50057)) + dummy = collection_factory("dummy", ports=_DEFAULT_VECTOR_PORTS) if dummy._connection._weaviate_version.is_lower_than(1, 29, 0): pytest.skip("Multivector is not supported in Weaviate versions lower than 1.29.0") collection = collection_factory( - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, properties=[Property(name="name", data_type=DataType.TEXT)], vector_config=[ Configure.MultiVectors.text2vec_jinaai( diff --git a/integration/test_collection_multi_node.py b/integration/test_collection_multi_node.py index 355936f96..7bc2d8896 100644 --- a/integration/test_collection_multi_node.py +++ b/integration/test_collection_multi_node.py @@ -1,6 +1,6 @@ import pytest -from integration.conftest import CollectionFactory +from integration.conftest import _DEFAULT_CLUSTER_PORTS, CollectionFactory from weaviate.collections.classes.config import ( Configure, ConsistencyLevel, @@ -23,7 +23,7 @@ def test_consistency_on_multinode( Property(name="name", data_type=DataType.TEXT), ], replication_config=Configure.replication(factor=2, async_enabled=False), - ports=(8087, 50058), + ports=_DEFAULT_CLUSTER_PORTS, ).with_consistency_level(level) collection.data.insert({"name": "first"}) diff --git a/integration/test_collection_openai.py b/integration/test_collection_openai.py index 0bd224f8e..3ab5ef26c 100644 --- a/integration/test_collection_openai.py +++ b/integration/test_collection_openai.py @@ -5,7 +5,12 @@ from _pytest.fixtures import SubRequest import weaviate -from integration.conftest import CollectionFactory, OpenAICollection +from integration.conftest import ( + _DEFAULT_VECTOR_HOST, + _DEFAULT_VECTOR_PORTS, + CollectionFactory, + OpenAICollection, +) from weaviate.collections.classes.config import ( Configure, DataType, @@ -530,7 +535,10 @@ def test_near_vector_generate_and_group_by_with_everything( def test_openai_invalid_key(request: SubRequest) -> None: with weaviate.connect_to_local( - port=8086, grpc_port=50057, headers={"X-OpenAI-Api-Key": "IamNotValid"} + host=_DEFAULT_VECTOR_HOST, + port=_DEFAULT_VECTOR_PORTS[0], + grpc_port=_DEFAULT_VECTOR_PORTS[1], + headers={"X-OpenAI-Api-Key": "IamNotValid"}, ) as client: client.collections.delete(request.node.name) collection = client.collections.create( @@ -591,7 +599,7 @@ def test_queries_with_rerank_and_generative(collection_factory: CollectionFactor reranker_config=Configure.Reranker.cohere(), vectorizer_config=Configure.Vectorizer.text2vec_cohere(), properties=[Property(name="text", data_type=DataType.TEXT)], - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, headers={"X-Cohere-Api-Key": api_key}, ) if collection._connection._weaviate_version < _ServerVersion(1, 23, 1): @@ -766,7 +774,7 @@ def test_contextualai_generative_search_single( Property(name="content", data_type=DataType.TEXT), ], headers={"X-Contextual-Api-Key": api_key}, - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, ) if collection._connection._weaviate_version.is_lower_than(1, 23, 1): pytest.skip("Generative search requires Weaviate 1.23.1 or higher") @@ -809,7 +817,7 @@ def test_contextualai_generative_with_knowledge_parameter( Property(name="text", data_type=DataType.TEXT), ], headers={"X-Contextual-Api-Key": api_key}, - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, ) if collection._connection._weaviate_version.is_lower_than(1, 23, 1): pytest.skip("Generative search requires Weaviate 1.23.1 or higher") @@ -854,7 +862,7 @@ def test_contextualai_generative_and_rerank_combined(collection_factory: Collect vectorizer_config=Configure.Vectorizer.text2vec_openai(), properties=[Property(name="text", data_type=DataType.TEXT)], headers={"X-Contextual-Api-Key": contextual_api_key}, - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, ) if collection._connection._weaviate_version < _ServerVersion(1, 23, 1): pytest.skip("Generative reranking requires Weaviate 1.23.1 or higher") diff --git a/integration/test_collection_rerank.py b/integration/test_collection_rerank.py index 61f6bade0..417b0bc68 100644 --- a/integration/test_collection_rerank.py +++ b/integration/test_collection_rerank.py @@ -4,7 +4,7 @@ import weaviate.classes as wvc -from .conftest import CollectionFactory +from .conftest import _DEFAULT_VECTOR_PORTS, CollectionFactory def test_query_using_rerank_with_old_server(collection_factory: CollectionFactory) -> None: @@ -38,7 +38,7 @@ def test_queries_with_rerank(collection_factory: CollectionFactory) -> None: vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_cohere(), properties=[wvc.config.Property(name="text", data_type=wvc.config.DataType.TEXT)], headers={"X-Cohere-Api-Key": api_key}, - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, ) if collection._connection._weaviate_version.is_lower_than(1, 23, 1): pytest.skip("Reranking requires Weaviate 1.23.1 or higher") @@ -94,7 +94,7 @@ def test_queries_with_rerank_and_group_by(collection_factory: CollectionFactory) ), properties=[wvc.config.Property(name="text", data_type=wvc.config.DataType.TEXT)], headers={"X-Cohere-Api-Key": api_key}, - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, ) if collection._connection._weaviate_version.is_lower_than(1, 23, 1): pytest.skip("Reranking requires Weaviate 1.23.1 or higher") @@ -155,7 +155,7 @@ def test_queries_with_rerank_contextualai(collection_factory: CollectionFactory) vectorizer_config=wvc.config.Configure.Vectorizer.text2vec_openai(), properties=[wvc.config.Property(name="text", data_type=wvc.config.DataType.TEXT)], headers={"X-Contextual-Api-Key": api_key}, - ports=(8086, 50057), + ports=_DEFAULT_VECTOR_PORTS, ) if collection._connection._weaviate_version.is_lower_than(1, 23, 1): pytest.skip("Reranking requires Weaviate 1.23.1 or higher") diff --git a/integration/test_groups.py b/integration/test_groups.py index 92ee95d2a..894157a45 100644 --- a/integration/test_groups.py +++ b/integration/test_groups.py @@ -1,10 +1,10 @@ import pytest -from integration.conftest import ClientFactory +from integration.conftest import _DEFAULT_RBAC_PORTS, ClientFactory from weaviate.auth import Auth from weaviate.rbac.models import GroupTypes, Role -RBAC_PORTS = (8092, 50063) +RBAC_PORTS = _DEFAULT_RBAC_PORTS RBAC_AUTH_CREDS = Auth.api_key("admin-key") diff --git a/integration/test_rbac.py b/integration/test_rbac.py index 0f8657a2d..29668a4a0 100644 --- a/integration/test_rbac.py +++ b/integration/test_rbac.py @@ -3,7 +3,12 @@ import pytest from _pytest.fixtures import SubRequest -from integration.conftest import ClientFactory, _sanitize_collection_name +from integration.conftest import ( + _DEFAULT_RBAC_HOST, + _DEFAULT_RBAC_PORTS, + ClientFactory, + _sanitize_collection_name, +) from weaviate.auth import Auth from weaviate.classes.rbac import Actions, Permissions, RoleScope from weaviate.connect.helpers import connect_to_local @@ -25,7 +30,7 @@ _Permission, ) -RBAC_PORTS = (8092, 50063) +RBAC_PORTS = _DEFAULT_RBAC_PORTS RBAC_AUTH_CREDS = Auth.api_key("admin-key") @@ -799,7 +804,10 @@ def test_permission_joining(client_factory: ClientFactory) -> None: def test_server_side_batching_with_auth() -> None: collection_name = "TestSSBAuth" with connect_to_local( - port=RBAC_PORTS[0], grpc_port=RBAC_PORTS[1], auth_credentials=RBAC_AUTH_CREDS + host=_DEFAULT_RBAC_HOST, + port=RBAC_PORTS[0], + grpc_port=RBAC_PORTS[1], + auth_credentials=RBAC_AUTH_CREDS, ) as client: if client._connection._weaviate_version.is_lower_than(1, 36, 0): pytest.skip("Server-side batching not supported in Weaviate < 1.36.0") diff --git a/integration/test_replicate.py b/integration/test_replicate.py index 4839ee0da..309d95c9b 100644 --- a/integration/test_replicate.py +++ b/integration/test_replicate.py @@ -1,10 +1,10 @@ import time import pytest -from integration.conftest import ClientFactory, CollectionFactory +from integration.conftest import _DEFAULT_CLUSTER_PORTS, ClientFactory, CollectionFactory import weaviate -PORTS = (8087, 50058) +PORTS = _DEFAULT_CLUSTER_PORTS pytestmark = pytest.mark.xdist_group(name="replicate") diff --git a/integration/test_users.py b/integration/test_users.py index 01a960506..107720fa6 100644 --- a/integration/test_users.py +++ b/integration/test_users.py @@ -2,11 +2,11 @@ from _pytest.fixtures import SubRequest import weaviate -from integration.conftest import ClientFactory, _sanitize_collection_name +from integration.conftest import _DEFAULT_RBAC_PORTS, ClientFactory, _sanitize_collection_name from weaviate.auth import Auth from weaviate.rbac.models import Role, RoleBase, UserTypes -RBAC_PORTS = (8092, 50063) +RBAC_PORTS = _DEFAULT_RBAC_PORTS RBAC_AUTH_CREDS = Auth.api_key("admin-key") diff --git a/integration/test_vectors.py b/integration/test_vectors.py index 35538ad30..345499f3a 100644 --- a/integration/test_vectors.py +++ b/integration/test_vectors.py @@ -5,7 +5,7 @@ import pytest import weaviate.classes as wvc -from integration.conftest import CollectionFactory, OpenAICollection +from integration.conftest import _DEFAULT_VECTOR_PORTS, CollectionFactory, OpenAICollection from weaviate.collections.classes.aggregate import AggregateInteger from weaviate.collections.classes.config import ( PQConfig, @@ -867,7 +867,7 @@ def test_colbert_vectors_jinaai(collection_factory: CollectionFactory) -> None: if api_key is None: pytest.skip("No JinaAI API key found.") - dummy = collection_factory(ports=(8086, 50057), headers={"X-Jinaai-Api-Key": api_key}) + dummy = collection_factory(ports=_DEFAULT_VECTOR_PORTS, headers={"X-Jinaai-Api-Key": api_key}) if dummy._connection._weaviate_version.is_lower_than(1, 29, 0): pytest.skip("ColBERT vectors are only supported in Weaviate v1.29.0 and higher.")