From 0d2ef35b9c1c2f115997ac548e1403c69a53604e Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Mon, 18 Mar 2024 23:54:11 -0400 Subject: [PATCH 01/32] Add integration tests with proxy --- .github/workflows/testing-integration.yaml | 46 ++++++++++- compose.yaml | 20 +++++ pinecone/config/config.py | 38 +++++++-- pinecone/control/pinecone.py | 52 ++++++++++++- pinecone/data/index.py | 5 +- pinecone/utils/setup_openapi_client.py | 4 +- tests/integration/proxy_config/__init__.py | 0 tests/integration/proxy_config/conftest.py | 10 +++ .../proxy_config/test_proxy_settings.py | 78 +++++++++++++++++++ tests/unit/test_config.py | 38 ++++++--- tests/unit/test_config_builder.py | 46 +++++++++-- 11 files changed, 306 insertions(+), 31 deletions(-) create mode 100644 compose.yaml create mode 100644 tests/integration/proxy_config/__init__.py create mode 100644 tests/integration/proxy_config/conftest.py create mode 100644 tests/integration/proxy_config/test_proxy_settings.py diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index ee07e42f8..f1802711b 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -3,6 +3,51 @@ name: "Integration Tests" workflow_call: {} jobs: + setup-index: + name: Setup proxyconfig test index + runs-on: ubuntu-latest + outputs: + index_name: ${{ steps.create-index.outputs.index_name }} + steps: + - uses: actions/checkout@v4 + - name: Create index + id: create-index + uses: ./.github/actions/create-index + with: + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + NAME_PREFIX: 'proxyconfig' + REGION: 'us-west-2' + CLOUD: 'aws' + DIMENSION: 1536 + METRIC: 'cosine' + + proxy-config: + name: Proxy config tests + needs: [setup-index] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.9 + - name: Setup Poetry + uses: ./.github/actions/setup-poetry + - name: Start MITM proxy instances + uses: isbang/compose-action@v1.5.1 + with: + compose-file: compose.yaml + - name: 'Run integration tests (proxy config)' + run: poetry run pytest tests/integration/proxy_config -s -v + env: + PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' + PINECONE_INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} + - name: Cleanup index + if: always() + uses: ./.github/actions/delete-index + with: + PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} + data-plane-serverless: name: Data plane serverless integration tests runs-on: ubuntu-latest @@ -27,7 +72,6 @@ jobs: spec: '${{ matrix.spec }}' PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' freshness_timeout_seconds: 600 - # data-plane-pod: # name: Data plane pod integration tests # runs-on: ubuntu-latest diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 000000000..0bb3820fb --- /dev/null +++ b/compose.yaml @@ -0,0 +1,20 @@ +services: + proxy: + image: mitmproxy/mitmproxy + command: mitmdump + ports: + - 8080:8080 + volumes: + - type: bind + source: ~/.mitmproxy + target: /home/mitmproxy/.mitmproxy + + proxy-w-auth: + image: mitmproxy/mitmproxy + command: mitmdump --set proxyauth=testuser:testpassword + ports: + - 8081:8080 + volumes: + - type: bind + source: ~/.mitmproxy2 + target: /home/mitmproxy/.mitmproxy \ No newline at end of file diff --git a/pinecone/config/config.py b/pinecone/config/config.py index a73ae87b3..a506c6ea0 100644 --- a/pinecone/config/config.py +++ b/pinecone/config/config.py @@ -10,7 +10,10 @@ class Config(NamedTuple): api_key: str = "" host: str = "" - openapi_config: Optional[OpenApiConfiguration] = None + proxy_url: Optional[str] = None + proxy_headers: Optional[Dict[str, str]] = None + ssl_ca_certs: Optional[str] = None + ssl_verify: Optional[bool] = None additional_headers: Optional[Dict[str, str]] = {} class ConfigBuilder: @@ -34,7 +37,10 @@ class ConfigBuilder: def build( api_key: Optional[str] = None, host: Optional[str] = None, - openapi_config: Optional[OpenApiConfiguration] = None, + proxy_url: Optional[str] = None, + proxy_headers: Optional[Dict[str, str]] = None, + ssl_ca_certs: Optional[str] = None, + ssl_verify: Optional[bool] = None, additional_headers: Optional[Dict[str, str]] = {}, **kwargs, ) -> Config: @@ -47,11 +53,29 @@ def build( if not host: raise PineconeConfigurationError("You haven't specified a host.") + return Config(api_key, host, proxy_url, proxy_headers, ssl_ca_certs, ssl_verify, additional_headers) + + @staticmethod + def build_openapi_config( + config: Config, openapi_config: Optional[OpenApiConfiguration] = None, **kwargs + ) -> OpenApiConfiguration: if openapi_config: openapi_config = copy.deepcopy(openapi_config) - openapi_config.host = host - openapi_config.api_key = {"ApiKeyAuth": api_key} - else: - openapi_config = OpenApiConfigFactory.build(api_key=api_key, host=host) + elif openapi_config is None: + openapi_config = OpenApiConfigFactory.build(api_key=config.api_key, host=config.host) + + openapi_config.host = config.host + openapi_config.api_key = {"ApiKeyAuth": config.api_key} - return Config(api_key, host, openapi_config, additional_headers) \ No newline at end of file + # Check if value passed before overriding any values present + # in the openapi_config + if (config.proxy_url): + openapi_config.proxy = config.proxy_url + if (config.proxy_headers): + openapi_config.proxy_headers = config.proxy_headers + if (config.ssl_ca_certs): + openapi_config.ssl_ca_cert = config.ssl_ca_certs + if (config.ssl_verify != None): + openapi_config.verify_ssl = config.ssl_verify + + return openapi_config \ No newline at end of file diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index ca8ebba49..98c0ad90d 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -3,7 +3,7 @@ from .index_host_store import IndexHostStore -from pinecone.config import PineconeConfig, Config +from pinecone.config import PineconeConfig, Config, ConfigBuilder from pinecone.core.client.api.manage_indexes_api import ManageIndexesApi from pinecone.utils import normalize_host, setup_openapi_client @@ -24,6 +24,10 @@ def __init__( self, api_key: Optional[str] = None, host: Optional[str] = None, + proxy_url: Optional[str] = None, + proxy_headers: Optional[Dict[str, str]] = None, + ssl_ca_certs: Optional[str] = None, + ssl_verify: Optional[bool] = None, config: Optional[Config] = None, additional_headers: Optional[Dict[str, str]] = {}, pool_threads: Optional[int] = 1, @@ -83,6 +87,36 @@ def __init__( request parameters to print out an equivalent curl command that you can run yourself or share with Pinecone support. **Be very careful with this option, as it will print out your API key** which forms part of a required authentication header. Default: `false` + + + ### SSL and proxy configuration + + By default the Pinecone python client will perform SSL certificate verification + using the CA bundle maintained by Mozilla in the [certifi](https://pypi.org/project/certifi/) package. + + If your network setup requires you to interact with Pinecone via a proxy, you will need + to pass additional configuration using optional keyword parameters. These optional parameters + are forwarded to urllib3, which is the underlying library used by the Pinecone client to + make HTTP requests. + + You may find it helpful to refer to the + [urllib3 documentation on working with proxies](https://urllib3.readthedocs.io/en/stable/advanced-usage.html#http-and-https-proxies) + while troubleshooting these settings. The example below also uses the + [make_headers](https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#urllib3.util.make_headers) + utility to create a header with basic authentication. + + ```python + from pinecone import Pinecone + import urllib3 import make_headers + + pc = Pinecone( + api_key="YOUR_API_KEY", + proxy_url='https://your-proxy.com', + proxy_headers=make_headers(proxy_basic_auth='username:password') + ssl_ca_certs='path/to/cert-bundle.pem' + ) + + pc.list_indexes() """ if config: if not isinstance(config, Config): @@ -90,14 +124,24 @@ def __init__( else: self.config = config else: - self.config = PineconeConfig.build(api_key=api_key, host=host, additional_headers=additional_headers, **kwargs) + self.config = PineconeConfig.build( + api_key=api_key, + host=host, + additional_headers=additional_headers, + proxy_url=proxy_url, + proxy_headers=proxy_headers, + ssl_ca_certs=ssl_ca_certs, + ssl_verify=ssl_verify, + **kwargs + ) + self.openapi_config = ConfigBuilder.build_openapi_config(self.config, **kwargs) self.pool_threads = pool_threads if index_api: self.index_api = index_api else: - self.index_api = setup_openapi_client(ManageIndexesApi, self.config, pool_threads) + self.index_api = setup_openapi_client(ManageIndexesApi, self.config, self.openapi_config, pool_threads) self.index_host_store = IndexHostStore() """ @private """ @@ -516,7 +560,7 @@ def Index(self, name: str = '', host: str = '', **kwargs): pt = kwargs.pop('pool_threads', None) or self.pool_threads api_key = self.config.api_key - openapi_config = self.config.openapi_config + openapi_config = self.openapi_config if host != '': # Use host url if it is provided diff --git a/pinecone/data/index.py b/pinecone/data/index.py index 87915e92e..8596c7eb1 100644 --- a/pinecone/data/index.py +++ b/pinecone/data/index.py @@ -82,10 +82,11 @@ def __init__( api_key=api_key, host=host, additional_headers=additional_headers, - openapi_config=openapi_config, **kwargs ) - self._vector_api = setup_openapi_client(DataPlaneApi, self._config, pool_threads) + openapi_config = ConfigBuilder.build_openapi_config(self._config, openapi_config) + + self._vector_api = setup_openapi_client(DataPlaneApi, self._config, openapi_config, pool_threads) def __enter__(self): return self diff --git a/pinecone/utils/setup_openapi_client.py b/pinecone/utils/setup_openapi_client.py index 2bc9c61f0..d1dde0617 100644 --- a/pinecone/utils/setup_openapi_client.py +++ b/pinecone/utils/setup_openapi_client.py @@ -1,9 +1,9 @@ from pinecone.core.client.api_client import ApiClient from .user_agent import get_user_agent -def setup_openapi_client(api_klass, config, pool_threads): +def setup_openapi_client(api_klass, config, openapi_config, pool_threads): api_client = ApiClient( - configuration=config.openapi_config, + configuration=openapi_config, pool_threads=pool_threads ) api_client.user_agent = get_user_agent() diff --git a/tests/integration/proxy_config/__init__.py b/tests/integration/proxy_config/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py new file mode 100644 index 000000000..d223abf95 --- /dev/null +++ b/tests/integration/proxy_config/conftest.py @@ -0,0 +1,10 @@ +import pytest +from ..helpers import get_environment_var + +@pytest.fixture() +def api_key(): + return get_environment_var('PINECONE_API_KEY') + +@pytest.fixture() +def index_name(): + return get_environment_var('PINECONE_INDEX_NAME') \ No newline at end of file diff --git a/tests/integration/proxy_config/test_proxy_settings.py b/tests/integration/proxy_config/test_proxy_settings.py new file mode 100644 index 000000000..b3d0a94ba --- /dev/null +++ b/tests/integration/proxy_config/test_proxy_settings.py @@ -0,0 +1,78 @@ +import os +import pytest +from pinecone import Pinecone +from urllib3 import make_headers +from urllib3.exceptions import InsecureRequestWarning + +PROXY_URL_HTTPS = 'https://localhost:8080' +PROXY_URL_HTTP = 'http://localhost:8080' + +PROXY_AUTH_CREDS = 'testuser:testpassword' +PROXY_W_PROXY_AUTH = 'https://localhost:8081' + +def exercise_all_apis(client, index_name): + # Control plane + client.list_indexes() + + # Data plane + index = client.Index(index_name) + index.describe_index_stats() + +class TestProxyConfig: + def test_https_proxy_with_self_signed_cert(self, api_key, index_name): + pc = Pinecone( + api_key=api_key, + proxy_url=PROXY_URL_HTTPS, + ssl_ca_certs='~/.mitmproxy/mitmproxy-ca-cert.pem', + ) + exercise_all_apis(pc, index_name) + + def test_http_proxy_with_self_signed_cert(self, api_key, index_name): + pc = Pinecone( + api_key=api_key, + proxy_url=PROXY_URL_HTTP, + ssl_ca_certs='~/.mitmproxy/mitmproxy-ca-cert.pem', + ) + exercise_all_apis(pc, index_name) + + def test_proxy_with_ssl_verification_disabled_emits_warning(self, api_key): + pc = Pinecone( + api_key=api_key, + proxy_url=PROXY_URL_HTTPS, + ssl_verify=False, + ) + + with pytest.warns(InsecureRequestWarning): + pc.list_indexes() + + def test_proxy_with_incorrect_cert_path(self, api_key): + with pytest.raises(Exception) as e: + pc = Pinecone( + api_key=api_key, + proxy_url=PROXY_URL_HTTPS, + ssl_ca_certs='~/incorrect/path', + ) + pc.list_indexes() + + assert 'No such file or directory' in str(e.value) + + def test_proxy_with_valid_path_to_incorrect_cert(self, api_key): + with pytest.raises(Exception) as e: + pc = Pinecone( + api_key=api_key, + proxy_url=PROXY_URL_HTTPS, + ssl_ca_certs='~/.mitmproxy2/mitmproxy-ca-cert.pem', + ) + pc.list_indexes() + + assert 'CERTIFICATE_VERIFY_FAILED' in str(e.value) + + def test_proxy_that_requires_proxyauth(self, api_key, index_name): + pc = Pinecone( + api_key=api_key, + proxy_url=PROXY_W_PROXY_AUTH, + proxy_headers=make_headers(proxy_basic_auth=PROXY_AUTH_CREDS), + ssl_ca_certs='~/.mitmproxy2/mitmproxy-ca-cert.pem' + ) + exercise_all_apis(pc, index_name) + diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index f1d6af7a0..cf3996e12 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -51,14 +51,15 @@ def test_init_with_positional_args(self): def test_init_with_kwargs(self): api_key = "my-api-key" controller_host = "my-controller-host" + ssl_ca_cert = 'path/to/cert-bundle.pem' + openapi_config = OpenApiConfiguration() - openapi_config.ssl_ca_cert = 'path/to/cert' - config = PineconeConfig.build(api_key=api_key, host=controller_host, openapi_config=openapi_config) + config = PineconeConfig.build(api_key=api_key, host=controller_host, ssl_ca_certs=ssl_ca_cert, openapi_config=openapi_config) assert config.api_key == api_key assert config.host == 'https://' + controller_host - assert config.openapi_config.ssl_ca_cert == 'path/to/cert' + assert config.ssl_ca_certs == 'path/to/cert-bundle.pem' def test_resolution_order_kwargs_over_env_vars(self): """ @@ -92,7 +93,7 @@ def test_config_pool_threads(self): def test_config_when_openapi_config_is_passed_merges_api_key(self): oai_config = OpenApiConfiguration() pc = Pinecone(api_key='asdf', openapi_config=oai_config) - assert pc.config.openapi_config.api_key == {'ApiKeyAuth': 'asdf'} + assert pc.openapi_config.api_key == {'ApiKeyAuth': 'asdf'} def test_ssl_config_passed_to_index_client(self): oai_config = OpenApiConfiguration() @@ -102,8 +103,8 @@ def test_ssl_config_passed_to_index_client(self): pc = Pinecone(api_key='key', openapi_config=oai_config) - assert pc.config.openapi_config.ssl_ca_cert == 'path/to/cert' - assert pc.config.openapi_config.proxy_headers == proxy_headers + assert pc.openapi_config.ssl_ca_cert == 'path/to/cert' + assert pc.openapi_config.proxy_headers == proxy_headers idx = pc.Index(host='host') assert idx._vector_api.api_client.configuration.ssl_ca_cert == 'path/to/cert' @@ -117,13 +118,30 @@ def test_host_config_not_clobbered_by_index(self): pc = Pinecone(api_key='key', openapi_config=oai_config) - assert pc.config.openapi_config.ssl_ca_cert == 'path/to/cert' - assert pc.config.openapi_config.proxy_headers == proxy_headers - assert pc.config.openapi_config.host == 'https://api.pinecone.io' + assert pc.openapi_config.ssl_ca_cert == 'path/to/cert' + assert pc.openapi_config.proxy_headers == proxy_headers + assert pc.openapi_config.host == 'https://api.pinecone.io' idx = pc.Index(host='host') assert idx._vector_api.api_client.configuration.ssl_ca_cert == 'path/to/cert' assert idx._vector_api.api_client.configuration.proxy_headers == proxy_headers assert idx._vector_api.api_client.configuration.host == 'https://host' - assert pc.config.openapi_config.host == 'https://api.pinecone.io' \ No newline at end of file + assert pc.openapi_config.host == 'https://api.pinecone.io' + + def test_proxy_config(self): + pc = Pinecone( + api_key='asdf', + proxy_url='http://localhost:8080', + ssl_ca_certs='path/to/cert-bundle.pem', + ) + + assert pc.config.proxy_url == 'http://localhost:8080' + assert pc.config.ssl_ca_certs == 'path/to/cert-bundle.pem' + + assert pc.openapi_config.proxy == 'http://localhost:8080' + assert pc.openapi_config.ssl_ca_cert == 'path/to/cert-bundle.pem' + + assert pc.index_api.api_client.configuration.proxy == 'http://localhost:8080' + assert pc.index_api.api_client.configuration.ssl_ca_cert == 'path/to/cert-bundle.pem' + \ No newline at end of file diff --git a/tests/unit/test_config_builder.py b/tests/unit/test_config_builder.py index 7f4d63dc0..ce8d6569f 100644 --- a/tests/unit/test_config_builder.py +++ b/tests/unit/test_config_builder.py @@ -10,8 +10,6 @@ def test_build_simple(self): assert config.api_key == "my-api-key" assert config.host == "https://my-controller-host" assert config.additional_headers == {} - assert config.openapi_config.host == "https://my-controller-host" - assert config.openapi_config.api_key == {"ApiKeyAuth": "my-api-key"} def test_build_merges_key_and_host_when_openapi_config_provided(self): config = ConfigBuilder.build( @@ -22,8 +20,6 @@ def test_build_merges_key_and_host_when_openapi_config_provided(self): assert config.api_key == "my-api-key" assert config.host == "https://my-controller-host" assert config.additional_headers == {} - assert config.openapi_config.host == "https://my-controller-host" - assert config.openapi_config.api_key == {"ApiKeyAuth": "my-api-key"} def test_build_errors_when_no_api_key_is_present(self): with pytest.raises(PineconeConfigurationError) as e: @@ -33,4 +29,44 @@ def test_build_errors_when_no_api_key_is_present(self): def test_build_errors_when_no_host_is_present(self): with pytest.raises(PineconeConfigurationError) as e: ConfigBuilder.build(api_key='my-api-key') - assert str(e.value) == "You haven't specified a host." \ No newline at end of file + assert str(e.value) == "You haven't specified a host." + + def test_build_openapi_config(self): + config = ConfigBuilder.build(api_key="my-api-key", host="https://my-controller-host") + openapi_config = ConfigBuilder.build_openapi_config(config) + assert openapi_config.host == "https://my-controller-host" + assert openapi_config.api_key == {"ApiKeyAuth": "my-api-key"} + + def test_build_openapi_config_merges_with_existing_config(self): + config = ConfigBuilder.build( + api_key="my-api-key", + host="https://my-controller-host" + ) + openapi_config = OpenApiConfiguration() + openapi_config.ssl_ca_cert = "path/to/bundle" + openapi_config.proxy = 'http://my-proxy:8080' + + openapi_config = ConfigBuilder.build_openapi_config(config, openapi_config) + + assert openapi_config.api_key == {"ApiKeyAuth": "my-api-key"} + assert openapi_config.host == "https://my-controller-host" + assert openapi_config.ssl_ca_cert == "path/to/bundle" + assert openapi_config.proxy == 'http://my-proxy:8080' + + def test_build_openapi_config_does_not_mutate_input(self): + config = ConfigBuilder.build( + api_key="my-api-key", + host="foo", + ssl_ca_certs="path/to/bundle.foo" + ) + + input_openapi_config = OpenApiConfiguration() + input_openapi_config.host = 'bar' + input_openapi_config.ssl_ca_cert = "asdfasdf" + + openapi_config = ConfigBuilder.build_openapi_config(config, input_openapi_config) + assert openapi_config.host == "https://foo" + assert openapi_config.ssl_ca_cert == "path/to/bundle.foo" + + assert input_openapi_config.host == 'bar' + assert input_openapi_config.ssl_ca_cert == "asdfasdf" \ No newline at end of file From c36f4b7758c4a01ba4875c6cfe6650a66daeb96b Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 00:17:07 -0400 Subject: [PATCH 02/32] Adjust working dir for github actions --- .github/workflows/testing-integration.yaml | 4 ++++ .gitignore | 3 +++ Makefile | 7 +++++++ compose.yaml | 4 ++-- tests/integration/proxy_config/test_proxy_settings.py | 8 ++++---- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index f1802711b..4fa85df8e 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -32,10 +32,14 @@ jobs: python-version: 3.9 - name: Setup Poetry uses: ./.github/actions/setup-poetry + - name: Prepare MITM config dirs + run: make prepare-proxy-config - name: Start MITM proxy instances uses: isbang/compose-action@v1.5.1 with: compose-file: compose.yaml + env: + WORKDIR: ${{ github.workspace }} - name: 'Run integration tests (proxy config)' run: poetry run pytest tests/integration/proxy_config -s -v env: diff --git a/.gitignore b/.gitignore index 3f6050533..b128e3d20 100644 --- a/.gitignore +++ b/.gitignore @@ -154,3 +154,6 @@ dmypy.json # Datasets *.hdf5 *~ + +# MITM proxy config test, generated configs +.mitm \ No newline at end of file diff --git a/Makefile b/Makefile index 45e13cefc..2ea768aec 100644 --- a/Makefile +++ b/Makefile @@ -46,3 +46,10 @@ set-production: set-development: echo "" > pinecone/__environment__ + +prepare-proxy-config: + mkdir -p .mitm/proxy1 + mkdir -p .mitm/proxy2 + +proxy-up: prepare-proxy-config + WORKDIR=${mkfile_path} docker-compose up \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 0bb3820fb..2cfc5d8c6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -6,7 +6,7 @@ services: - 8080:8080 volumes: - type: bind - source: ~/.mitmproxy + source: $WORKDIR/.mitm/proxy1 target: /home/mitmproxy/.mitmproxy proxy-w-auth: @@ -16,5 +16,5 @@ services: - 8081:8080 volumes: - type: bind - source: ~/.mitmproxy2 + source: $WORKDIR/.mitm/proxy2 target: /home/mitmproxy/.mitmproxy \ No newline at end of file diff --git a/tests/integration/proxy_config/test_proxy_settings.py b/tests/integration/proxy_config/test_proxy_settings.py index b3d0a94ba..d3245a05f 100644 --- a/tests/integration/proxy_config/test_proxy_settings.py +++ b/tests/integration/proxy_config/test_proxy_settings.py @@ -23,7 +23,7 @@ def test_https_proxy_with_self_signed_cert(self, api_key, index_name): pc = Pinecone( api_key=api_key, proxy_url=PROXY_URL_HTTPS, - ssl_ca_certs='~/.mitmproxy/mitmproxy-ca-cert.pem', + ssl_ca_certs='./.mitm/proxy1/mitmproxy-ca-cert.pem', ) exercise_all_apis(pc, index_name) @@ -31,7 +31,7 @@ def test_http_proxy_with_self_signed_cert(self, api_key, index_name): pc = Pinecone( api_key=api_key, proxy_url=PROXY_URL_HTTP, - ssl_ca_certs='~/.mitmproxy/mitmproxy-ca-cert.pem', + ssl_ca_certs='./.mitm/proxy1/mitmproxy-ca-cert.pem', ) exercise_all_apis(pc, index_name) @@ -61,7 +61,7 @@ def test_proxy_with_valid_path_to_incorrect_cert(self, api_key): pc = Pinecone( api_key=api_key, proxy_url=PROXY_URL_HTTPS, - ssl_ca_certs='~/.mitmproxy2/mitmproxy-ca-cert.pem', + ssl_ca_certs='./.mitm/proxy2/mitmproxy-ca-cert.pem', ) pc.list_indexes() @@ -72,7 +72,7 @@ def test_proxy_that_requires_proxyauth(self, api_key, index_name): api_key=api_key, proxy_url=PROXY_W_PROXY_AUTH, proxy_headers=make_headers(proxy_basic_auth=PROXY_AUTH_CREDS), - ssl_ca_certs='~/.mitmproxy2/mitmproxy-ca-cert.pem' + ssl_ca_certs='./.mitm/proxy2/mitmproxy-ca-cert.pem' ) exercise_all_apis(pc, index_name) From 96620459b39ee5d98dbaff4f4b14481c64a1f5a5 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 00:51:18 -0400 Subject: [PATCH 03/32] Update docs --- pinecone/control/pinecone.py | 62 +++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index 98c0ad90d..2fc6eb563 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -42,6 +42,14 @@ def __init__( :type api_key: str, optional :param host: The control plane host to connect to. :type host: str, optional + :param proxy_url: The URL of the proxy to use for the connection. Default: `None` + :type proxy_url: str, optional + :param proxy_headers: Additional headers to pass to the proxy. Use this if your proxy setup requires authentication. Default: `{}` + :type proxy_headers: Dict[str, str], optional + :param ssl_ca_certs: The path to the SSL CA certificate bundle to use for the connection. This path should point to a file in PEM format. Default: `None` + :type ssl_ca_certs: str, optional + :param ssl_verify: SSL verification is performed by default, but can be disabled using the boolean flag. Default: `True` + :type ssl_verify: bool, optional :param config: A `pinecone.config.Config` object. If passed, the `api_key` and `host` parameters will be ignored. :type config: pinecone.config.Config, optional :param additional_headers: Additional headers to pass to the API. Default: `{}` @@ -89,34 +97,64 @@ def __init__( your API key** which forms part of a required authentication header. Default: `false` - ### SSL and proxy configuration - - By default the Pinecone python client will perform SSL certificate verification - using the CA bundle maintained by Mozilla in the [certifi](https://pypi.org/project/certifi/) package. + ### Proxy configuration If your network setup requires you to interact with Pinecone via a proxy, you will need to pass additional configuration using optional keyword parameters. These optional parameters - are forwarded to urllib3, which is the underlying library used by the Pinecone client to - make HTTP requests. - - You may find it helpful to refer to the + are forwarded to `urllib3`, which is the underlying library currently used by the Pinecone client to + make HTTP requests. You may find it helpful to refer to the [urllib3 documentation on working with proxies](https://urllib3.readthedocs.io/en/stable/advanced-usage.html#http-and-https-proxies) - while troubleshooting these settings. The example below also uses the - [make_headers](https://urllib3.readthedocs.io/en/stable/reference/urllib3.util.html#urllib3.util.make_headers) - utility to create a header with basic authentication. + while troubleshooting these settings. + + Here is a basic example: + + ```python + from pinecone import Pinecone + + pc = Pinecone( + api_key="YOUR_API_KEY", + proxy_url='https://your-proxy.com' + ) + + pc.list_indexes() + ``` + + If your proxy requires authentication, you can pass those values in a header dictionary using the `proxy_headers` parameter. ```python from pinecone import Pinecone import urllib3 import make_headers pc = Pinecone( - api_key="YOUR_API_KEY", + api_key="YOUR_API_KEY", + proxy_url='https://your-proxy.com', + proxy_headers=make_headers(proxy_basic_auth='username:password') + ) + + pc.list_indexes() + ``` + + ### Using proxies with self-signed certificates + + By default the Pinecone Python client will perform SSL certificate verification + using the CA bundle maintained by Mozilla in the [certifi](https://pypi.org/project/certifi/) package. + If your proxy server is using a self-signed certificate, you will need to pass the path to the certificate + in PEM format using the `ssl_ca_certs` parameter. + + ```python + from pinecone import Pinecone + import urllib3 import make_headers + + pc = Pinecone( + api_key="YOUR_API_KEY", proxy_url='https://your-proxy.com', proxy_headers=make_headers(proxy_basic_auth='username:password') ssl_ca_certs='path/to/cert-bundle.pem' ) pc.list_indexes() + ``` + """ if config: if not isinstance(config, Config): From c228cde30aafa25df9fe13be8ad2e69986da1a87 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 00:51:41 -0400 Subject: [PATCH 04/32] Add debug output in tests --- .github/workflows/testing-dependency.yaml | 15 ++ .github/workflows/testing-integration.yaml | 228 +++++++++++---------- 2 files changed, 130 insertions(+), 113 deletions(-) diff --git a/.github/workflows/testing-dependency.yaml b/.github/workflows/testing-dependency.yaml index 5ba301067..05492c494 100644 --- a/.github/workflows/testing-dependency.yaml +++ b/.github/workflows/testing-dependency.yaml @@ -158,3 +158,18 @@ jobs: index_name: '${{ needs.dependency-matrix-setup.outputs.index_name }}' PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' urllib3_version: '${{ matrix.urllib3_version }}' + + deps-cleanup: + name: Deps cleanup + runs-on: ubuntu-latest + needs: + - dependency-matrix-setup + - dependency-matrix-grpc + - dependency-matrix-grpc-312 + - dependency-matrix-rest + - dependency-matrix-rest-312 + steps: + - uses: ./.github/actions/delete-index + with: + index_name: '${{ needs.dependency-matrix-setup.outputs.index_name }}' + PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' \ No newline at end of file diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 4fa85df8e..07a71f83d 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -40,6 +40,8 @@ jobs: compose-file: compose.yaml env: WORKDIR: ${{ github.workspace }} + - name: 'debug' + run: netstat -lt - name: 'Run integration tests (proxy config)' run: poetry run pytest tests/integration/proxy_config -s -v env: @@ -52,131 +54,131 @@ jobs: PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} - data-plane-serverless: - name: Data plane serverless integration tests - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python_version: [3.8, 3.12] - use_grpc: [true, false] - metric: - - cosine - # - euclidean - # - dotproduct - spec: - - '{ "serverless": { "region": "us-west-2", "cloud": "aws" }}' - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/test-data-plane - with: - python_version: '${{ matrix.python_version }}' - use_grpc: '${{ matrix.use_grpc }}' - metric: '${{ matrix.metric }}' - spec: '${{ matrix.spec }}' - PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' - freshness_timeout_seconds: 600 -# data-plane-pod: -# name: Data plane pod integration tests +# data-plane-serverless: +# name: Data plane serverless integration tests # runs-on: ubuntu-latest # strategy: -# max-parallel: 1 +# fail-fast: false # matrix: +# python_version: [3.8, 3.12] # use_grpc: [true, false] -# metric: [cosine, dotproduct] +# metric: +# - cosine +# # - euclidean +# # - dotproduct # spec: -# - '{ "pod": { "environment": "us-east1-gcp", "pod_type": "p1" }}' +# - '{ "serverless": { "region": "us-west-2", "cloud": "aws" }}' # steps: # - uses: actions/checkout@v4 # - uses: ./.github/actions/test-data-plane # with: +# python_version: '${{ matrix.python_version }}' # use_grpc: '${{ matrix.use_grpc }}' # metric: '${{ matrix.metric }}' # spec: '${{ matrix.spec }}' # PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' +# freshness_timeout_seconds: 600 +# # data-plane-pod: +# # name: Data plane pod integration tests +# # runs-on: ubuntu-latest +# # strategy: +# # max-parallel: 1 +# # matrix: +# # use_grpc: [true, false] +# # metric: [cosine, dotproduct] +# # spec: +# # - '{ "pod": { "environment": "us-east1-gcp", "pod_type": "p1" }}' +# # steps: +# # - uses: actions/checkout@v4 +# # - uses: ./.github/actions/test-data-plane +# # with: +# # use_grpc: '${{ matrix.use_grpc }}' +# # metric: '${{ matrix.metric }}' +# # spec: '${{ matrix.spec }}' +# # PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' - control-rest-pod: - name: control plane pod/collection tests - runs-on: ubuntu-latest - strategy: - matrix: - pineconeEnv: - - prod - testConfig: - - python-version: 3.8 - pod: { environment: 'us-east1-gcp'} - - python-version: 3.12 - pod: { environment: 'us-east4-gcp'} - fail-fast: false - steps: - - uses: actions/checkout@v4 - - name: 'Set up Python ${{ matrix.testConfig.python-version }}' - uses: actions/setup-python@v5 - with: - python-version: '${{ matrix.testConfig.python-version }}' - - name: Setup Poetry - uses: ./.github/actions/setup-poetry - - name: 'Run integration tests (REST, prod)' - if: matrix.pineconeEnv == 'prod' - run: poetry run pytest tests/integration/control/serverless -s -v - env: - PINECONE_DEBUG_CURL: 'true' - PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' - PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' - GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' - DIMENSION: 1536 - METRIC: 'cosine' - - name: 'Run integration tests (REST, staging)' - if: matrix.pineconeEnv == 'staging' - run: poetry run pytest tests/integration/control/serverless -s -v - env: - PINECONE_DEBUG_CURL: 'true' - PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' - PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' - PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' - GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' - DIMENSION: 1536 - METRIC: 'cosine' +# control-rest-pod: +# name: control plane pod/collection tests +# runs-on: ubuntu-latest +# strategy: +# matrix: +# pineconeEnv: +# - prod +# testConfig: +# - python-version: 3.8 +# pod: { environment: 'us-east1-gcp'} +# - python-version: 3.12 +# pod: { environment: 'us-east4-gcp'} +# fail-fast: false +# steps: +# - uses: actions/checkout@v4 +# - name: 'Set up Python ${{ matrix.testConfig.python-version }}' +# uses: actions/setup-python@v5 +# with: +# python-version: '${{ matrix.testConfig.python-version }}' +# - name: Setup Poetry +# uses: ./.github/actions/setup-poetry +# - name: 'Run integration tests (REST, prod)' +# if: matrix.pineconeEnv == 'prod' +# run: poetry run pytest tests/integration/control/serverless -s -v +# env: +# PINECONE_DEBUG_CURL: 'true' +# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' +# PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' +# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' +# DIMENSION: 1536 +# METRIC: 'cosine' +# - name: 'Run integration tests (REST, staging)' +# if: matrix.pineconeEnv == 'staging' +# run: poetry run pytest tests/integration/control/serverless -s -v +# env: +# PINECONE_DEBUG_CURL: 'true' +# PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' +# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' +# PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' +# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' +# DIMENSION: 1536 +# METRIC: 'cosine' - control-rest-serverless: - name: control plane serverless - runs-on: ubuntu-latest - strategy: - matrix: - pineconeEnv: - - prod - testConfig: - - python-version: 3.8 # Do one test run with 3.8 for sanity check - pod: { environment: 'us-east1-gcp'} - serverless: { cloud: 'aws', region: 'us-west-2'} - - python-version: 3.12 - pod: { environment: 'us-east1-gcp'} - serverless: { cloud: 'aws', region: 'us-west-2'} - fail-fast: false - steps: - - uses: actions/checkout@v4 - - name: 'Set up Python ${{ matrix.testConfig.python-version }}' - uses: actions/setup-python@v5 - with: - python-version: '${{ matrix.testConfig.python-version }}' - - name: Setup Poetry - uses: ./.github/actions/setup-poetry - - name: 'Run integration tests (REST, prod)' - if: matrix.pineconeEnv == 'prod' - run: poetry run pytest tests/integration/control/serverless -s -vv - env: - PINECONE_DEBUG_CURL: 'true' - PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' - GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' - SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' - SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' - - name: 'Run integration tests (REST, staging)' - if: matrix.pineconeEnv == 'staging' - run: poetry run pytest tests/integration/control/serverless -s -vv - env: - PINECONE_DEBUG_CURL: 'true' - PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' - PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' - GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' - SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' - SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' +# control-rest-serverless: +# name: control plane serverless +# runs-on: ubuntu-latest +# strategy: +# matrix: +# pineconeEnv: +# - prod +# testConfig: +# - python-version: 3.8 # Do one test run with 3.8 for sanity check +# pod: { environment: 'us-east1-gcp'} +# serverless: { cloud: 'aws', region: 'us-west-2'} +# - python-version: 3.12 +# pod: { environment: 'us-east1-gcp'} +# serverless: { cloud: 'aws', region: 'us-west-2'} +# fail-fast: false +# steps: +# - uses: actions/checkout@v4 +# - name: 'Set up Python ${{ matrix.testConfig.python-version }}' +# uses: actions/setup-python@v5 +# with: +# python-version: '${{ matrix.testConfig.python-version }}' +# - name: Setup Poetry +# uses: ./.github/actions/setup-poetry +# - name: 'Run integration tests (REST, prod)' +# if: matrix.pineconeEnv == 'prod' +# run: poetry run pytest tests/integration/control/serverless -s -vv +# env: +# PINECONE_DEBUG_CURL: 'true' +# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' +# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' +# SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' +# SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' +# - name: 'Run integration tests (REST, staging)' +# if: matrix.pineconeEnv == 'staging' +# run: poetry run pytest tests/integration/control/serverless -s -vv +# env: +# PINECONE_DEBUG_CURL: 'true' +# PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' +# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' +# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' +# SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' +# SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' From 8ee2695a925ce3acd508ee332e3f48d1f05d81e5 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 01:00:11 -0400 Subject: [PATCH 05/32] Simplify compose up --- .github/workflows/testing-integration.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 07a71f83d..b86ffabbe 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -32,12 +32,10 @@ jobs: python-version: 3.9 - name: Setup Poetry uses: ./.github/actions/setup-poetry - - name: Prepare MITM config dirs - run: make prepare-proxy-config - name: Start MITM proxy instances - uses: isbang/compose-action@v1.5.1 - with: - compose-file: compose.yaml + run: | + make prepare-proxy-config + docker-compose up -d env: WORKDIR: ${{ github.workspace }} - name: 'debug' From 8ab5da01989d207adc3de40379d63318df09e170 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 10:04:26 -0400 Subject: [PATCH 06/32] Iterate on test setup --- .github/workflows/testing-dependency.yaml | 1 + tests/integration/proxy_config/test_proxy_settings.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing-dependency.yaml b/.github/workflows/testing-dependency.yaml index 05492c494..2074a01a5 100644 --- a/.github/workflows/testing-dependency.yaml +++ b/.github/workflows/testing-dependency.yaml @@ -169,6 +169,7 @@ jobs: - dependency-matrix-rest - dependency-matrix-rest-312 steps: + - uses: actions/checkout@v4 - uses: ./.github/actions/delete-index with: index_name: '${{ needs.dependency-matrix-setup.outputs.index_name }}' diff --git a/tests/integration/proxy_config/test_proxy_settings.py b/tests/integration/proxy_config/test_proxy_settings.py index d3245a05f..ed4f63718 100644 --- a/tests/integration/proxy_config/test_proxy_settings.py +++ b/tests/integration/proxy_config/test_proxy_settings.py @@ -4,11 +4,11 @@ from urllib3 import make_headers from urllib3.exceptions import InsecureRequestWarning -PROXY_URL_HTTPS = 'https://localhost:8080' -PROXY_URL_HTTP = 'http://localhost:8080' +PROXY_URL_HTTPS = 'https://127.0.0.1:8080' +PROXY_URL_HTTP = 'http://127.0.0.1:8080' PROXY_AUTH_CREDS = 'testuser:testpassword' -PROXY_W_PROXY_AUTH = 'https://localhost:8081' +PROXY_W_PROXY_AUTH = 'https://127.0.0.1:8081' def exercise_all_apis(client, index_name): # Control plane From 1e4555c3f78993e247320a112c090ac7d96fbda5 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 11:36:00 -0400 Subject: [PATCH 07/32] More debug output --- .github/workflows/testing-integration.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index b86ffabbe..48395c58c 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -15,7 +15,7 @@ jobs: uses: ./.github/actions/create-index with: PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} - NAME_PREFIX: 'proxyconfig' + NAME_PREFIX: 'proxyconfig-' REGION: 'us-west-2' CLOUD: 'aws' DIMENSION: 1536 @@ -40,6 +40,8 @@ jobs: WORKDIR: ${{ github.workspace }} - name: 'debug' run: netstat -lt + - name: 'configs' + run: ls ${{ github.workspace }}/.mitm - name: 'Run integration tests (proxy config)' run: poetry run pytest tests/integration/proxy_config -s -v env: From e5f0130105928ac1ab0a5d5258ad03d6e994d0b7 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 11:41:27 -0400 Subject: [PATCH 08/32] More debug output --- .github/workflows/pr.yaml | 12 ++++++------ .github/workflows/testing-integration.yaml | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index e48aa2681..69c6150d4 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -8,15 +8,15 @@ on: workflow_dispatch: {} jobs: - unit-tests: - uses: './.github/workflows/testing-unit.yaml' - secrets: inherit + # unit-tests: + # uses: './.github/workflows/testing-unit.yaml' + # secrets: inherit integration-tests: uses: './.github/workflows/testing-integration.yaml' secrets: inherit - dependency-tests: - uses: './.github/workflows/testing-dependency.yaml' - secrets: inherit + # dependency-tests: + # uses: './.github/workflows/testing-dependency.yaml' + # secrets: inherit package: name: Check packaging runs-on: ubuntu-latest diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 48395c58c..fbdbdeb68 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -41,7 +41,10 @@ jobs: - name: 'debug' run: netstat -lt - name: 'configs' - run: ls ${{ github.workspace }}/.mitm + run: | + ls ${{ github.workspace }}/.mitm + ls ${{ github.workspace }}/.mitm/proxy1 + cat ${{ github.workspace }}/.mitm/proxy1/mitmproxy-ca-cert.pem - name: 'Run integration tests (proxy config)' run: poetry run pytest tests/integration/proxy_config -s -v env: From 88a8c62c74b96778f2e6b318cc4097c484a2d919 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 11:43:30 -0400 Subject: [PATCH 09/32] List running containers --- .github/workflows/testing-integration.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index fbdbdeb68..7f7f98a7c 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -38,6 +38,10 @@ jobs: docker-compose up -d env: WORKDIR: ${{ github.workspace }} + + - name: 'docker ps' + run: | + docker-compose ps - name: 'debug' run: netstat -lt - name: 'configs' @@ -45,6 +49,7 @@ jobs: ls ${{ github.workspace }}/.mitm ls ${{ github.workspace }}/.mitm/proxy1 cat ${{ github.workspace }}/.mitm/proxy1/mitmproxy-ca-cert.pem + - name: 'Run integration tests (proxy config)' run: poetry run pytest tests/integration/proxy_config -s -v env: From 9f5f0369b9187eae96a7d6a8b1ceb247180c700b Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 12:06:49 -0400 Subject: [PATCH 10/32] Adjust docker volumes --- .github/workflows/testing-integration.yaml | 2 +- compose.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 7f7f98a7c..e723902b0 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -35,7 +35,7 @@ jobs: - name: Start MITM proxy instances run: | make prepare-proxy-config - docker-compose up -d + docker-compose --verbose up -d env: WORKDIR: ${{ github.workspace }} diff --git a/compose.yaml b/compose.yaml index 2cfc5d8c6..5b4b4d435 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,9 +5,7 @@ services: ports: - 8080:8080 volumes: - - type: bind - source: $WORKDIR/.mitm/proxy1 - target: /home/mitmproxy/.mitmproxy + - proxy1:/home/mitmproxy/.mitmproxy proxy-w-auth: image: mitmproxy/mitmproxy @@ -15,6 +13,8 @@ services: ports: - 8081:8080 volumes: - - type: bind - source: $WORKDIR/.mitm/proxy2 - target: /home/mitmproxy/.mitmproxy \ No newline at end of file + - proxy2:/home/mitmproxy/.mitmproxy + +volumes: + proxy1: + proxy2: From 8ac4bdfaf1cb8fdca5281e818b8c63d4a4f09609 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 14:02:31 -0400 Subject: [PATCH 11/32] Revert "Adjust docker volumes" This reverts commit 9f5f0369b9187eae96a7d6a8b1ceb247180c700b. --- .github/workflows/testing-integration.yaml | 2 +- compose.yaml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index e723902b0..7f7f98a7c 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -35,7 +35,7 @@ jobs: - name: Start MITM proxy instances run: | make prepare-proxy-config - docker-compose --verbose up -d + docker-compose up -d env: WORKDIR: ${{ github.workspace }} diff --git a/compose.yaml b/compose.yaml index 5b4b4d435..2cfc5d8c6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,7 +5,9 @@ services: ports: - 8080:8080 volumes: - - proxy1:/home/mitmproxy/.mitmproxy + - type: bind + source: $WORKDIR/.mitm/proxy1 + target: /home/mitmproxy/.mitmproxy proxy-w-auth: image: mitmproxy/mitmproxy @@ -13,8 +15,6 @@ services: ports: - 8081:8080 volumes: - - proxy2:/home/mitmproxy/.mitmproxy - -volumes: - proxy1: - proxy2: + - type: bind + source: $WORKDIR/.mitm/proxy2 + target: /home/mitmproxy/.mitmproxy \ No newline at end of file From da52763b03036cacf77b1868af4b1873e8e788a9 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 14:25:54 -0400 Subject: [PATCH 12/32] Adjust volume config --- compose.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compose.yaml b/compose.yaml index 2cfc5d8c6..583627486 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,3 +1,7 @@ +version: "3.8" + +name: proxy-test-deps + services: proxy: image: mitmproxy/mitmproxy @@ -5,9 +9,7 @@ services: ports: - 8080:8080 volumes: - - type: bind - source: $WORKDIR/.mitm/proxy1 - target: /home/mitmproxy/.mitmproxy + - ./.mitm/proxy1:/home/mitmproxy/.mitmproxy proxy-w-auth: image: mitmproxy/mitmproxy @@ -15,6 +17,4 @@ services: ports: - 8081:8080 volumes: - - type: bind - source: $WORKDIR/.mitm/proxy2 - target: /home/mitmproxy/.mitmproxy \ No newline at end of file + - ./.mitm/proxy2:/home/mitmproxy/.mitmproxy \ No newline at end of file From 4653d0316e7bb740c4a31cf946b0bf56484a9a6e Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 14:31:14 -0400 Subject: [PATCH 13/32] Remove name from compose file --- compose.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/compose.yaml b/compose.yaml index 583627486..a2dc2b7c9 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,5 @@ version: "3.8" -name: proxy-test-deps - services: proxy: image: mitmproxy/mitmproxy From 74ee9e78b15541117cc6d146c5a595face398e4d Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 15:57:28 -0400 Subject: [PATCH 14/32] Consolidate docker run into same step as test run --- .github/workflows/testing-integration.yaml | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 7f7f98a7c..23a2e8458 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -35,23 +35,14 @@ jobs: - name: Start MITM proxy instances run: | make prepare-proxy-config - docker-compose up -d env: WORKDIR: ${{ github.workspace }} - - - name: 'docker ps' + - name: 'Run integration tests (proxy config)' run: | + docker-compose up -d docker-compose ps - - name: 'debug' - run: netstat -lt - - name: 'configs' - run: | - ls ${{ github.workspace }}/.mitm ls ${{ github.workspace }}/.mitm/proxy1 - cat ${{ github.workspace }}/.mitm/proxy1/mitmproxy-ca-cert.pem - - - name: 'Run integration tests (proxy config)' - run: poetry run pytest tests/integration/proxy_config -s -v + poetry run pytest tests/integration/proxy_config -s -v env: PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' PINECONE_INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} From 8786d3d92d392ca1e78851a7d0fe723f094ec861 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 16:12:32 -0400 Subject: [PATCH 15/32] Experiment: file permissions --- .github/workflows/testing-integration.yaml | 10 +++++----- Makefile | 2 +- compose.yaml | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 23a2e8458..43e745170 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -32,15 +32,15 @@ jobs: python-version: 3.9 - name: Setup Poetry uses: ./.github/actions/setup-poetry - - name: Start MITM proxy instances - run: | - make prepare-proxy-config - env: - WORKDIR: ${{ github.workspace }} - name: 'Run integration tests (proxy config)' run: | + make prepare-proxy-config + ls -l ./.mitm + ls -l ./pinecone + docker-compose up -d docker-compose ps + ls ${{ github.workspace }}/.mitm/proxy1 poetry run pytest tests/integration/proxy_config -s -v env: diff --git a/Makefile b/Makefile index 2ea768aec..5b3158b72 100644 --- a/Makefile +++ b/Makefile @@ -52,4 +52,4 @@ prepare-proxy-config: mkdir -p .mitm/proxy2 proxy-up: prepare-proxy-config - WORKDIR=${mkfile_path} docker-compose up \ No newline at end of file + WORKDIR=${mkfile_path} docker-compose up -d \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index a2dc2b7c9..b307a55fa 100644 --- a/compose.yaml +++ b/compose.yaml @@ -7,7 +7,7 @@ services: ports: - 8080:8080 volumes: - - ./.mitm/proxy1:/home/mitmproxy/.mitmproxy + - ./pinecone:/home/mitmproxy/.mitmproxy proxy-w-auth: image: mitmproxy/mitmproxy @@ -15,4 +15,4 @@ services: ports: - 8081:8080 volumes: - - ./.mitm/proxy2:/home/mitmproxy/.mitmproxy \ No newline at end of file + - ./pinecone:/home/mitmproxy/.mitmproxy \ No newline at end of file From 0b97dd31c6efe2876f4e9680f625003b807bf025 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 16:21:55 -0400 Subject: [PATCH 16/32] Docker compose with no daemon option --- .github/workflows/testing-integration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 43e745170..b7b25d792 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -38,7 +38,7 @@ jobs: ls -l ./.mitm ls -l ./pinecone - docker-compose up -d + docker-compose up docker-compose ps ls ${{ github.workspace }}/.mitm/proxy1 From 3c249048a7696d191e90facc50aba40883e91e53 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 17:08:26 -0400 Subject: [PATCH 17/32] Adjust user permissions --- .github/workflows/testing-integration.yaml | 6 +++--- Makefile | 5 ++++- compose.yaml | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index b7b25d792..55b53bf83 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -35,10 +35,10 @@ jobs: - name: 'Run integration tests (proxy config)' run: | make prepare-proxy-config - ls -l ./.mitm - ls -l ./pinecone + + set -x - docker-compose up + DOCKER_GID=$(python -c "import os; print(os.getgid())") DOCKER_UID=$(python -c "import os; print(os.getuid())") docker-compose up -d docker-compose ps ls ${{ github.workspace }}/.mitm/proxy1 diff --git a/Makefile b/Makefile index 5b3158b72..78c3ddea4 100644 --- a/Makefile +++ b/Makefile @@ -52,4 +52,7 @@ prepare-proxy-config: mkdir -p .mitm/proxy2 proxy-up: prepare-proxy-config - WORKDIR=${mkfile_path} docker-compose up -d \ No newline at end of file + DOCKER_GID=$$(python -c "import os; print(os.getgid())") DOCKER_UID=$$(python -c "import os; print(os.getuid())") docker-compose up -d --remove-orphans + +proxy-stop: + DOCKER_GID=$$(python -c "import os; print(os.getgid())") DOCKER_UID=$$(python -c "import os; print(os.getuid())") docker-compose stop \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index b307a55fa..9ff499644 100644 --- a/compose.yaml +++ b/compose.yaml @@ -2,17 +2,19 @@ version: "3.8" services: proxy: + user: "${DOCKER_UID}:${DOCKER_GID}" image: mitmproxy/mitmproxy command: mitmdump ports: - 8080:8080 volumes: - - ./pinecone:/home/mitmproxy/.mitmproxy + - ./mitm/proxy1:/home/mitmproxy/.mitmproxy proxy-w-auth: + user: "${DOCKER_UID}:${DOCKER_GID}" image: mitmproxy/mitmproxy command: mitmdump --set proxyauth=testuser:testpassword ports: - 8081:8080 volumes: - - ./pinecone:/home/mitmproxy/.mitmproxy \ No newline at end of file + - ./mitm/proxy2:/home/mitmproxy/.mitmproxy \ No newline at end of file From b9517f27d2363861a59c421a086705abc9a2e130 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Tue, 19 Mar 2024 20:14:12 -0400 Subject: [PATCH 18/32] Remove docker compose --- .github/workflows/testing-integration.yaml | 8 --- .gitignore | 2 - Makefile | 10 ---- compose.yaml | 20 ------- .../.mitm/proxy1/mitmproxy-ca-cert.cer | 20 +++++++ .../.mitm/proxy1/mitmproxy-ca-cert.p12 | Bin 0 -> 1035 bytes .../.mitm/proxy1/mitmproxy-ca-cert.pem | 20 +++++++ .../.mitm/proxy1/mitmproxy-ca.p12 | Bin 0 -> 2412 bytes .../.mitm/proxy1/mitmproxy-ca.pem | 47 ++++++++++++++++ .../.mitm/proxy1/mitmproxy-dhparam.pem | 14 +++++ .../.mitm/proxy2/mitmproxy-ca-cert.cer | 20 +++++++ .../.mitm/proxy2/mitmproxy-ca-cert.p12 | Bin 0 -> 1035 bytes .../.mitm/proxy2/mitmproxy-ca-cert.pem | 20 +++++++ .../.mitm/proxy2/mitmproxy-ca.p12 | Bin 0 -> 2410 bytes .../.mitm/proxy2/mitmproxy-ca.pem | 47 ++++++++++++++++ .../.mitm/proxy2/mitmproxy-dhparam.pem | 14 +++++ tests/integration/proxy_config/conftest.py | 52 ++++++++++++++++++ .../proxy_config/test_proxy_settings.py | 44 ++++++++------- tests/perf/grpc/conftest.py | 28 ++++++++++ tests/perf/grpc/test_list.py | 26 +++++++++ 20 files changed, 332 insertions(+), 60 deletions(-) delete mode 100644 compose.yaml create mode 100644 tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.cer create mode 100644 tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.p12 create mode 100644 tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.pem create mode 100644 tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca.p12 create mode 100644 tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca.pem create mode 100644 tests/integration/proxy_config/.mitm/proxy1/mitmproxy-dhparam.pem create mode 100644 tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.cer create mode 100644 tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.p12 create mode 100644 tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.pem create mode 100644 tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca.p12 create mode 100644 tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca.pem create mode 100644 tests/integration/proxy_config/.mitm/proxy2/mitmproxy-dhparam.pem create mode 100644 tests/perf/grpc/conftest.py create mode 100644 tests/perf/grpc/test_list.py diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 55b53bf83..a5b1b258d 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -34,14 +34,6 @@ jobs: uses: ./.github/actions/setup-poetry - name: 'Run integration tests (proxy config)' run: | - make prepare-proxy-config - - set -x - - DOCKER_GID=$(python -c "import os; print(os.getgid())") DOCKER_UID=$(python -c "import os; print(os.getuid())") docker-compose up -d - docker-compose ps - - ls ${{ github.workspace }}/.mitm/proxy1 poetry run pytest tests/integration/proxy_config -s -v env: PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' diff --git a/.gitignore b/.gitignore index b128e3d20..fbbb5de87 100644 --- a/.gitignore +++ b/.gitignore @@ -155,5 +155,3 @@ dmypy.json *.hdf5 *~ -# MITM proxy config test, generated configs -.mitm \ No newline at end of file diff --git a/Makefile b/Makefile index 78c3ddea4..45e13cefc 100644 --- a/Makefile +++ b/Makefile @@ -46,13 +46,3 @@ set-production: set-development: echo "" > pinecone/__environment__ - -prepare-proxy-config: - mkdir -p .mitm/proxy1 - mkdir -p .mitm/proxy2 - -proxy-up: prepare-proxy-config - DOCKER_GID=$$(python -c "import os; print(os.getgid())") DOCKER_UID=$$(python -c "import os; print(os.getuid())") docker-compose up -d --remove-orphans - -proxy-stop: - DOCKER_GID=$$(python -c "import os; print(os.getgid())") DOCKER_UID=$$(python -c "import os; print(os.getuid())") docker-compose stop \ No newline at end of file diff --git a/compose.yaml b/compose.yaml deleted file mode 100644 index 9ff499644..000000000 --- a/compose.yaml +++ /dev/null @@ -1,20 +0,0 @@ -version: "3.8" - -services: - proxy: - user: "${DOCKER_UID}:${DOCKER_GID}" - image: mitmproxy/mitmproxy - command: mitmdump - ports: - - 8080:8080 - volumes: - - ./mitm/proxy1:/home/mitmproxy/.mitmproxy - - proxy-w-auth: - user: "${DOCKER_UID}:${DOCKER_GID}" - image: mitmproxy/mitmproxy - command: mitmdump --set proxyauth=testuser:testpassword - ports: - - 8081:8080 - volumes: - - ./mitm/proxy2:/home/mitmproxy/.mitmproxy \ No newline at end of file diff --git a/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.cer b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.cer new file mode 100644 index 000000000..5f1337564 --- /dev/null +++ b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.cer @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDNTCCAh2gAwIBAgIUG5Ji5NxWD3Q7h8remh7vYloa1UMwDQYJKoZIhvcNAQEL +BQAwKDESMBAGA1UEAwwJbWl0bXByb3h5MRIwEAYDVQQKDAltaXRtcHJveHkwHhcN +MjQwMzE3MDQwNjA2WhcNMzQwMzE3MDQwNjA2WjAoMRIwEAYDVQQDDAltaXRtcHJv +eHkxEjAQBgNVBAoMCW1pdG1wcm94eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAI96RxFM2U3cXyhJre0DbJvZDvrr5IEFJhEO9+7vRFM73cTax2jhUDQx +ZLx5LgWWQmqTfNop5ON1XKqYMxpjTJrHEbIcnybLRmLL+SXVsj547vRH1rps+G4m +3iJWorGju3PieJYj8ppro0mhlynZRHOM8EzkX9TgxdtFpz3hejy9btOwEkRGrjM1 +5prsDubYn0JwGz6N2N/yAf9mviWKnP1xc1CD2xIJwJKX1Tyqi9B93w1YL5JFV7yg +rdlRw4X0a3wav7GiJJkylv8cZrtZ4Kt4TwNMLpqh21LRqJkwyFE8NLXMD/aS4q2U +3K5ml6H9MthNkrheH0RlsiOe5RQJMAcCAwEAAaNXMFUwDwYDVR0TAQH/BAUwAwEB +/zATBgNVHSUEDDAKBggrBgEFBQcDATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE +FM83YTNU3L2z9vvQvHrGX0U/XAf2MA0GCSqGSIb3DQEBCwUAA4IBAQARURZnD7Nm +d/kN1gIpl+x9aAaMLlvS3hgn6quuVVJzyiHYZKmBq/76VPIyn4dSFQakvS5nob3R +FNzlq3QR6o4jAR6BIEzuKDKExFdYz7hfBA6JgGUxTsofJPBmqC2BvRZlkt/Qb3ea +HDCJUYOXfppABimlVi5gOVf6r80wcuqTK6sIp+V+HVhAf2RbpAFnLWOSzkZ7Qaa9 +jZJ5Jd2nYTx+eOjkNZL2kiV6R9tvuJK0C9nQeJJDTwkmksLJEg+5CS6D51zdRgdc +dCvvesmF6dWQmOxZdm3pqusTkIWNq2RBb2kEqZA84cfVLX4+OOhbieC9XKQjsOcE +h+rsI/lmeuR9 +-----END CERTIFICATE----- diff --git a/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.p12 b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.p12 new file mode 100644 index 0000000000000000000000000000000000000000..10e4d4e63f139708edde5b6a63ce843027f920c6 GIT binary patch literal 1035 zcmXqLVqs@uWHxAG-pj_R)#lOmotKfFaX}OFI+iBpRY2ioK)eW5YBEr&A1K@n#O-X{ zP+dG+jLblNfj~iDHZG_jrx?gATc8F@ptz|)6O-%$W+p}^CK2gLNl)&C@t0V)pSm|o z?tM~})KzB#Ubsb!+^h@+8iqm!0&L8oEX+KdxtS%o1x5K4l`t_bBryXyab6=617kyT z0}}%?1G6Y`USnh~2_`i$Dj_?Ak(GhDiIJbdpox)-sfm%1p})#q(C4P_op=q;wQreo zX5Zxd_4-L8tC}F+_jm7Ig01f!xph3_VStHY%AQI+)@e>zlWT5iK6zXkvucL1RI<;k zwPkYozvXT%PDcsuCgikSu{0&PsTp5gyC>CxILch;p%U-;MPhVP^uaq=#yo0R8072z~sXJTe# zU|bw-5Nf~=j2T&BM#ldvtOm?L%0L(-pvuByz{SR)&Bn;e%FfJazy}iK2dQEKMm(E= zEQrs?BE}+e-aOGbTe4R#ec|4VB6psyE)jgy zr_3nVsNnNX!>Hv*c*OY~@hp6u4XK8Hr{q;Wq^;0x+$)wk>HdZM@>wzloq^5M>t;Ey zX)X=ZORx<8wf?L@(W}YYt2vfGt&@##s85Mr!kDg`Jn5WUwd1nAy^|_c?=DZYsjGPL z#B|cPNvc)uxAS*Q+QNPFLd7I!e@?YYhfWId@8r~LejanzjXkDB`+e2P)|Xc&%y<)7 zmiuzmYvBp4y{l6k^D|jiPOy1+{Hku9oyCjj&IfyAmMCv{&eHzsjq=a5swcIE$_9$? ze8DMVC?Y4skjs$CPy!?i7>XG387dem4IB*&L4lXh=E0cC%)$grw=4>4y;wZ*E>GXn seM-u`=;6%Q-G9RDce*BSuu~CRmiYTh01L;CNzFB@uHNNmV&Y%`02QHvvH$=8 literal 0 HcmV?d00001 diff --git a/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.pem b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.pem new file mode 100644 index 000000000..5f1337564 --- /dev/null +++ b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca-cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDNTCCAh2gAwIBAgIUG5Ji5NxWD3Q7h8remh7vYloa1UMwDQYJKoZIhvcNAQEL +BQAwKDESMBAGA1UEAwwJbWl0bXByb3h5MRIwEAYDVQQKDAltaXRtcHJveHkwHhcN +MjQwMzE3MDQwNjA2WhcNMzQwMzE3MDQwNjA2WjAoMRIwEAYDVQQDDAltaXRtcHJv +eHkxEjAQBgNVBAoMCW1pdG1wcm94eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAI96RxFM2U3cXyhJre0DbJvZDvrr5IEFJhEO9+7vRFM73cTax2jhUDQx +ZLx5LgWWQmqTfNop5ON1XKqYMxpjTJrHEbIcnybLRmLL+SXVsj547vRH1rps+G4m +3iJWorGju3PieJYj8ppro0mhlynZRHOM8EzkX9TgxdtFpz3hejy9btOwEkRGrjM1 +5prsDubYn0JwGz6N2N/yAf9mviWKnP1xc1CD2xIJwJKX1Tyqi9B93w1YL5JFV7yg +rdlRw4X0a3wav7GiJJkylv8cZrtZ4Kt4TwNMLpqh21LRqJkwyFE8NLXMD/aS4q2U +3K5ml6H9MthNkrheH0RlsiOe5RQJMAcCAwEAAaNXMFUwDwYDVR0TAQH/BAUwAwEB +/zATBgNVHSUEDDAKBggrBgEFBQcDATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE +FM83YTNU3L2z9vvQvHrGX0U/XAf2MA0GCSqGSIb3DQEBCwUAA4IBAQARURZnD7Nm +d/kN1gIpl+x9aAaMLlvS3hgn6quuVVJzyiHYZKmBq/76VPIyn4dSFQakvS5nob3R +FNzlq3QR6o4jAR6BIEzuKDKExFdYz7hfBA6JgGUxTsofJPBmqC2BvRZlkt/Qb3ea +HDCJUYOXfppABimlVi5gOVf6r80wcuqTK6sIp+V+HVhAf2RbpAFnLWOSzkZ7Qaa9 +jZJ5Jd2nYTx+eOjkNZL2kiV6R9tvuJK0C9nQeJJDTwkmksLJEg+5CS6D51zdRgdc +dCvvesmF6dWQmOxZdm3pqusTkIWNq2RBb2kEqZA84cfVLX4+OOhbieC9XKQjsOcE +h+rsI/lmeuR9 +-----END CERTIFICATE----- diff --git a/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca.p12 b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca.p12 new file mode 100644 index 0000000000000000000000000000000000000000..e0177f8a4f4209dc6a3a533fa9a66e923433baa4 GIT binary patch literal 2412 zcmeH{dpK148pmhNS~Cn8+ZYt%o?8rSW++9Z+}Z~_WQHi@GP<}ca?6ZcqS91E5h3AF zh{IuOE4OG%iQFTD$Sn<_i?ck>-W})9^E~Iz^T%(k=l6Nv-*3Io_g&u?X5)O&00^^j za#-As1j~dkB7gvp!^Vk1Y@9HH1zm#EG5nXgc~g6Xp~n6e zpV33Q6wmr|+L*NcC$B~JYw*U-xD?-{Nqbmjwun`b?x?n#A8%h(>8>yeo8w#b{PXmR zpX#s@{cd?)UGV#`H08z2Q+Wq-(>3}`gHsl)c&=|ong+}Y_l|}ea{am<5=_m@XnGTw zGx&+#JNpAJRU zoSI|urd}1w+2ceUEPw_96p+V&9bi$UGqU0Uunu8h5P8Ak8$box0t;aUHL(B&BLD(0 zeglebWI;&dv9RpM9uG-E#Fx9=X@>{7mCIi{>%*H}&5T_HmN!d}`~isc07}eOk||p0 z9l9#ggVso&iSogwXgj|i-l{fTQs!V6+@{#;S;Q*&v37WodMD9N0-Mj(X6ABV5eLUh zLd2#oD+6*Y1*v?ZF>#(DXIU62ZdpXj#X7=RKYC0Vdgl(_tQAa*un7b53Qb(A_XP>;q4a zv&>Nmw;1rR;XD%V>kQ)@_zkDZdHS3nT8q<;opc#87jOyDoDY8RjbH?ec?^N+e z@znTBC7ve!C!nHK!_k&*a_u1mi1!$~M{dPaHGJDe9qv4j<@Z0Io>Ky7Xc;s=Ng-A5w%NaX*H_{$N95-7=xBvrl8A~k4- zqR%`SBqrx}^Fh}6T%~WrqcuH>C$Y1Fb*s+5^vBuA2YpMArnU1t9?cIjB7HLCx2^1{ zc^gRXRj8FZeRbM_akWNn0nAdGV@1cY$PNTG z&89%3G2TR+IQ7+54{V7w{c&{B$ljj8BL;Sv%F{r-@YIl^;yb~mj6$lTvrloh^XDN2 zN%adR?iacGnL`pQT+g1iZL!2;rWRGt8~>1MW?5TY5JMOkAIa1#Yfm-t*3rJv&PZWc$!87OLs#GgjcW;Ea{o z^)a&_(~Jw5btWEXiKc0&@Eb#sRd!fEBUxX;*Sfs!)2(8KNh7PSRtr5``|Y30Lb|Sg zZI*c(E8F;o7<9``G3CYgE}~cD@qmaF`~Cw9dE?^|2Fa6^-kK8EZcKrrFO~JHG2zW) z#%?7ojRXGbB7V?XT}Ags4YhSrU%L4B3iG=pq+P|I?XFce|G~UyZ`?B^qub!#;pDR` z0iSgwWjWlsuJ5a%PrGVEZE@vC=H1(l!IRp(&(wrY0e#Tq6~pn^-ZN5_PH2rVn%v$C zqTPpSD}1B+GfRR|NAD^XE8Zw4WGj=ZBI>LNe(om5B1S}Rx0%6Z@~Mp)l44gwB@%b3 z-E*k5v6>b_M=}g8)FxtZEC!JXVLex-P8v(`)2 zx_;GyoMo?Rb_jp;J!MTbDnve}^$9OXXW?l1lDdXK#iI*VGE;Q%ij-RwZDf%oWbxs56|wPj7o}O4=hC&Abbyrn{Sor5|8Z81zHIc^ zlZeA7^#rC{u4dy<(m8JneYZrdw2sxW^I45x0nUlR`AFd2vmv}H%h9-;(5X}1)EQ?V zC5%t4R@wIM%ZCgdb0>|1`sJMv{3~AjlWg<;hqKcJrfdvCw**VT3xv=cgHT~ve~y@5N>F$z=o>4# lS2ryn8M0Evk4DtXoECDfZha03erbBNWr^@(7L67}{R@1$|DgZ? literal 0 HcmV?d00001 diff --git a/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca.pem b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca.pem new file mode 100644 index 000000000..b681605c4 --- /dev/null +++ b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-ca.pem @@ -0,0 +1,47 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAj3pHEUzZTdxfKEmt7QNsm9kO+uvkgQUmEQ737u9EUzvdxNrH +aOFQNDFkvHkuBZZCapN82ink43VcqpgzGmNMmscRshyfJstGYsv5JdWyPnju9EfW +umz4bibeIlaisaO7c+J4liPymmujSaGXKdlEc4zwTORf1ODF20WnPeF6PL1u07AS +REauMzXmmuwO5tifQnAbPo3Y3/IB/2a+JYqc/XFzUIPbEgnAkpfVPKqL0H3fDVgv +kkVXvKCt2VHDhfRrfBq/saIkmTKW/xxmu1ngq3hPA0wumqHbUtGomTDIUTw0tcwP +9pLirZTcrmaXof0y2E2SuF4fRGWyI57lFAkwBwIDAQABAoIBABaZiSY1d6knBCoh +aO8DchEeYJivnX+hIvze4bjWIWoG7Qi7+VsQ2oROH3L8l34zy+RjtO/cV3xomR8Z ++Dq413Et2CC5F2yR6lVXkbge8AOdIu6BflZBIeSf5K99/ASFKNq5GotzwBwIxmCr +vlbOLVUSJyvFcT7j5OaEEzLRGGMGq01Wvn6p4D3W3Fo7Upoj6gG8C+ndISHfCPWZ +pzJYW2iqnlvz3SAWKIhBYYq9OJrdFfi9ZNbKGYMUi2csMjVmDrAyRUi5qqVxM40x +Jumj4+0T8la8j9fms/9lkBzDh05pWGuuRfFj2ztTkIXUA23shNkpRwnuzu9kn786 +NqulHdkCgYEAxcLDgXGTc5n47f/jRf7qV4iau0FjdhRElgB6ld18tVIGbj4dbQjS +NOTVbMgRp4ng+V9M8Na9UyTzrnTTkfvGG9eDHcTNEQSbYCGMzP3TFGV8YnB7jFPa +Q/Cj5eV7O4vns2YrFZOV6QPhzyM4tgV6xuM/YKvHxNtvKA1uBPq7stUCgYEAubsX +99P0pqek0xUaXxPDObkjRv5nilM/1t0bNMFhzlloN4YOnVqM9npNu9n7PGjLJsG5 +qrPrZ6KcWHPnLtjDJwprAdkE54885YPYdRezWQIpeDMePYgP1VQz+PQ+vHX1CH1d +oiKqIZWxEp4jHLV7u0wSbmFBPw0+FL3VRTuOLWsCgYEAiYP5dxWHNyemVblOTOoK +AnxXPEcn5oAJgVUr6PJvOZakKhy/UYaExYsqbc5hmGLkMgP2+LIaTKqxWGqchDLT +e6DM5/JltqPBd4Nc6V7HXLOFXt5gyx+z8vJuxfphSvLqV3GAHCzYXYP5jZQsZ0ZA +LfTvqUVKULVWAj/0dTn1M1ECgYB9gX46zBHgpBxvPy1o3jPoR8Ec8kEJaiQTj6oY +xizPgf84tfAeSNhEnnT04eIx+iZ9dB+AyL/kci/wXbH1KCkHsrSItRvpVhOyjJuy +1GcvWJSpUvG2ZsE8SQAt1O6n75W7POwO6hnJRBw6Fn5nogOQl2FFEZdDgjFXVshN +VmdHLQKBgQCtqBqkyldZDVXxKIZnYKErxN2JeWZHOGCHLJbO+eN/ncQDpQlZV5Lr +Er2mThLRrqApjobQL7bF0IRTfQsOkLYlGd/36JkvRlkpSTixyJRn0PRvR/PdIrbk +LT6c0+82drLGyJHXHUR2P1kDJ03Snh2EMqVLVhm3hmXT9I9lQolRow== +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDNTCCAh2gAwIBAgIUG5Ji5NxWD3Q7h8remh7vYloa1UMwDQYJKoZIhvcNAQEL +BQAwKDESMBAGA1UEAwwJbWl0bXByb3h5MRIwEAYDVQQKDAltaXRtcHJveHkwHhcN +MjQwMzE3MDQwNjA2WhcNMzQwMzE3MDQwNjA2WjAoMRIwEAYDVQQDDAltaXRtcHJv +eHkxEjAQBgNVBAoMCW1pdG1wcm94eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAI96RxFM2U3cXyhJre0DbJvZDvrr5IEFJhEO9+7vRFM73cTax2jhUDQx +ZLx5LgWWQmqTfNop5ON1XKqYMxpjTJrHEbIcnybLRmLL+SXVsj547vRH1rps+G4m +3iJWorGju3PieJYj8ppro0mhlynZRHOM8EzkX9TgxdtFpz3hejy9btOwEkRGrjM1 +5prsDubYn0JwGz6N2N/yAf9mviWKnP1xc1CD2xIJwJKX1Tyqi9B93w1YL5JFV7yg +rdlRw4X0a3wav7GiJJkylv8cZrtZ4Kt4TwNMLpqh21LRqJkwyFE8NLXMD/aS4q2U +3K5ml6H9MthNkrheH0RlsiOe5RQJMAcCAwEAAaNXMFUwDwYDVR0TAQH/BAUwAwEB +/zATBgNVHSUEDDAKBggrBgEFBQcDATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE +FM83YTNU3L2z9vvQvHrGX0U/XAf2MA0GCSqGSIb3DQEBCwUAA4IBAQARURZnD7Nm +d/kN1gIpl+x9aAaMLlvS3hgn6quuVVJzyiHYZKmBq/76VPIyn4dSFQakvS5nob3R +FNzlq3QR6o4jAR6BIEzuKDKExFdYz7hfBA6JgGUxTsofJPBmqC2BvRZlkt/Qb3ea +HDCJUYOXfppABimlVi5gOVf6r80wcuqTK6sIp+V+HVhAf2RbpAFnLWOSzkZ7Qaa9 +jZJ5Jd2nYTx+eOjkNZL2kiV6R9tvuJK0C9nQeJJDTwkmksLJEg+5CS6D51zdRgdc +dCvvesmF6dWQmOxZdm3pqusTkIWNq2RBb2kEqZA84cfVLX4+OOhbieC9XKQjsOcE +h+rsI/lmeuR9 +-----END CERTIFICATE----- diff --git a/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-dhparam.pem b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-dhparam.pem new file mode 100644 index 000000000..c10121fbf --- /dev/null +++ b/tests/integration/proxy_config/.mitm/proxy1/mitmproxy-dhparam.pem @@ -0,0 +1,14 @@ + +-----BEGIN DH PARAMETERS----- +MIICCAKCAgEAyT6LzpwVFS3gryIo29J5icvgxCnCebcdSe/NHMkD8dKJf8suFCg3 +O2+dguLakSVif/t6dhImxInJk230HmfC8q93hdcg/j8rLGJYDKu3ik6H//BAHKIv +j5O9yjU3rXCfmVJQic2Nne39sg3CreAepEts2TvYHhVv3TEAzEqCtOuTjgDv0ntJ +Gwpj+BJBRQGG9NvprX1YGJ7WOFBP/hWU7d6tgvE6Xa7T/u9QIKpYHMIkcN/l3ZFB +chZEqVlyrcngtSXCROTPcDOQ6Q8QzhaBJS+Z6rcsd7X+haiQqvoFcmaJ08Ks6LQC +ZIL2EtYJw8V8z7C0igVEBIADZBI6OTbuuhDwRw//zU1uq52Oc48CIZlGxTYG/Evq +o9EWAXUYVzWkDSTeBH1r4z/qLPE2cnhtMxbFxuvK53jGB0emy2y1Ei6IhKshJ5qX +IB/aE7SSHyQ3MDHHkCmQJCsOd4Mo26YX61NZ+n501XjqpCBQ2+DfZCBh8Va2wDyv +A2Ryg9SUz8j0AXViRNMJgJrr446yro/FuJZwnQcO3WQnXeqSBnURqKjmqkeFP+d8 +6mk2tqJaY507lRNqtGlLnj7f5RNoBFJDCLBNurVgfvq9TCVWKDIFD4vZRjCrnl6I +rD693XKIHUCWOjMh1if6omGXKHH40QuME2gNa50+YPn1iYDl88uDbbMCAQI= +-----END DH PARAMETERS----- diff --git a/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.cer b/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.cer new file mode 100644 index 000000000..fb8851978 --- /dev/null +++ b/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.cer @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDNTCCAh2gAwIBAgIUUo4sMqY4s3aM0RqjLhD1ZzGOhnowDQYJKoZIhvcNAQEL +BQAwKDESMBAGA1UEAwwJbWl0bXByb3h5MRIwEAYDVQQKDAltaXRtcHJveHkwHhcN +MjQwMzE3MDQwNjA2WhcNMzQwMzE3MDQwNjA2WjAoMRIwEAYDVQQDDAltaXRtcHJv +eHkxEjAQBgNVBAoMCW1pdG1wcm94eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAJ/BEbexCoDvIEB2zF8R13tNVqc5eW5kS4Rp0IqKSfWmmrghA0bc6X22 +p6juusl1KSpoWcR1L0iD1Wa2Tlaip0c/DJUwJHwJ70UZyWjwAJPbF282dYqqwygC +hWP1EFKVlctHE6MEMc+o1W7hLC690n0EKtatT5lCHSuUwK69RoNijfPqJrqstQKN +hJZ9bDIHVwi86jUbUcfjb9Uo/AiMjAonuy82wiarHdNmRIIcRcBvXkhx7on/5X5z +/Vq4+lgR91lP+6qYotHI988e4plF0KuzjrTPyki7+OiyJkMxJwJW/E1DU6bvTchN +H9wB27kJ6GtFW21n1YqRWpCR7JyQ4D8CAwEAAaNXMFUwDwYDVR0TAQH/BAUwAwEB +/zATBgNVHSUEDDAKBggrBgEFBQcDATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE +FBNhRsjEjijaA8rS3XezhrtEpVvRMA0GCSqGSIb3DQEBCwUAA4IBAQAc8wSUSk7y +Sz4pQmi6EciZmU9jEnBHld9uYJ4mqRR2oPm+eRPq0yW1VifNEgMLSqNcv8/EH93o +C16jHHQ5TrV0C+wMnnUN3BxliDsi6FdbMa92Df09K9C/LP/v68H4rtMaMskvOrHw +k/r/NsKCxZ1GywLA7s/yVKgtr7ARARf6hHJS6/bxqohdaCFZtxmQIH26sOkTV2Ds +pf1ey+d3xitOl/roLXV91KjGfML4PRCzIPOw0+odSw62e2kikI77OQxOEn4zjyg+ +a0B344gMV7LaNTyqLTx41wU0hk62CeHHS4Gc0XLMfw9NYPTrjyQYK1+lEWDSEHCn +TiBThXoIGeAU +-----END CERTIFICATE----- diff --git a/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.p12 b/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca-cert.p12 new file mode 100644 index 0000000000000000000000000000000000000000..331252619cee6e07250761a39b65e758ea00b5b9 GIT binary patch literal 1035 zcmXqLVqs@uWHxAG-pj_R)#lOmotKfFaX}OFI+iBpRY2ioK)eW5YBEr&A1K@n#O-X{ zP+dG+jLblNfj~iDHZG_jrx?gATc8F@ptz|)6O-%$W+p}^CXt{%9iwFyo6CAGN-fqC z_?m9m*H&e~3%7`oo0Y*p!%)aTfQ>nng_(ylH?t(SpeVnh5+=rlBxWEd&TC|1U~Fh^ zU}9iqU=}6LYmCe#!K5ZeC1htXvNA9?G4eAQG%<29H8CyI>~BJIk0Z8TXRzH=T~aG)@)_!ZJAb^W5gcLvFDYkbl~yF`BydmaP;(WsqfY| zJEXQ+_Hvp_lZ@+u{5X%ocb)&A))oJa+VLww@Oz~H?^QDvT|DvqyxgOit`}Bs?%Q(y zl*jHLFE*(;8>%yf{qc1UUiRMigs=P^#@jnNUu3&R=cZrnniw@<;+r`W9@sN6GcqtP z4mSuj;0MNxtS}?ve->5)W*}uC3=&Xf;W6N1d2U%|I5! z=VK9L5fM&wJ8`5>;}-L&OLxmRx9xUW8hsHt=z%E!81#$`GM`zdc=>(uw$pUV*d=&k z=1l)&p#t}*_wy3wsjU<#TkvyVrSPlEs$0X<&k8Yfdo7OHfBuO4-51<(i)BhI{kE2H zzu}oz%6ms9wZmHJMR>H~`ZC_Xw%Ql=>->NJ`rwasm!*tO>RWC6F!|SivqMcs=enI{ zI`HoNr;ru8>o*88ivMaU3VQwR48_Rpk`okacWrnn9G>uI>EF21&&!W#`%VA# zLbtT`%8Fw(hkn=!Y*zTZ;qoh4Z@z8SnMxD-ep~YR3Dp_*YuIHwlt1p^3EySrR8QIDe zQkEJqk;qQTR~4~J)ir2p69;q`}y85LiE6Z z5R4F|@I>VVvxF}skOwS8h$JjRB%&AxBT&bGm>>=ofvQnlg^mY!zQ0cK^MX(z0-Zpi z1)ldWNZf_q1?i&)bWyGaBN*vI2m@j;qSj0mjba^kNJ{^nA~m6PPbxDZ0w#Tb2;{>7 zuo6`m7Q#ceScsqK;~nJVAK(`j{x{>@!C)D2lExueld26Lf@v_#QJkc?bNgT1gn;rp z!vJvrgn)tojDWlt1O$PC=j7UlyfI6%$3kA7B@ahh*p=vp`?@i%diNzK|6{#4ha(5k zN9LkxN=g^&x`GcVd!1?xRyT`#<56R2cc;YEfIkaXyi8m&k?8VT27dk^?netwE^AT3 z#JjEwS!ZRvFcm4nQhQ6^_)e&(H4H>ym50i$SVqzZGn*Odi6%s zMGYQ%!qd-Mk|#PQ{oW{jBc!D8QtH)d&HL|54|*6QQYKA)&SsYuf7+Uk4&*v=HXX=c zPFZ~|%f8d!`K4FpBg>@kKATzH+ih0AG5cu$aViC4_s!zCP4SXNr^Vh8@WT`0>;)4i zAI~?*8II{03%Tjz1{eqgz#@Ct78XP+BP{}gTUZJ6%{#0?`&l%y@$F7Mnl;N^~QId`gf)t{Q+p|K|pE^n`v&j z$~bz!$g7Ur$zoZ#3j3R8jrqFd@4qJ+QuxQSaFNf0`ySg-dW0c9^Pg1;i`I;^ z<{^S`f@C7tn-J5?)@E*n)>H78>4vT&E{{Nht+`$5Z_ zo3pCHQLjteFE?-K3$bO_ss=wxGX!cPz2(!HUv>E{g`+jol#X6F7CM>4Z~y4M){!#R zBVoh1LkX5O#EA|@Y;J$R%PWEwF2BvEDegXa_Ac3FK*+zuQr0Fuf*>(2N;QM!zUzW0 zN)?q627CZ-APAlPfdIe{2m``lg@3zXK8IT-bfP@Tx^Je5ghHi z+qTMa6fA;MK=EF5NbZy}YQ#3d2=*xk1a=k$)dLp67NeFssOA5P_*)TZCIG>-G|fvK ze-_ENeW=aRbd_o8DBKwH{sLp{xl~_miftCV(k5PATIiLGu|D2P>@Y!OIOk@`RhE={ zz~B?8m+dQ_W^&%kP1`OfHJ3Xx$<|w27(U)+vs!N3RbfvnuU2kygsdDd+di5KdZE{V z1pTPUE;pfOzty&{UFmUfYK<=aVJN-e+M4TKvv(b#ksDiCCBrxIfw>Rjde+y22D%et z3|c~b7n=BVXwtt_JgFsL6V?&)?VI42N%*S4k$AU&p9jx~Qipk7%r(5)l^yc=o&es7 z$*$p#vd7&*jV6$g58+F zl#CZ;Y0mI^utO?=eEdeFUjJ5yO7z=*md`wht$z|WSw4Ose`NSDG0sX)!|;-PQw^4< zM8EH7i$va?#k6MYln%Y_Jp)?Ksz6W6FRvb&UrJ93$e&F#f32823?1d4^LD2> zc+HV+F>NQ5XJgjH-1sUfW?fFV!xO6|69FBsOEtyj%Lb;ib9qy%RTDJvvuZU>YKKLH zSkHcvj*YH-JjPX9<9Of330eV$!(B$V$4*cl_-Qp6%=ai=)>Z9xS$Dtq{*duJCN@U* z5!FcHJkxO*n7=Nrm~xbRs~z9d=4ZIo(RpI@wIuTHU4%{-Xp{e(y&f@m+F1)|aZokU z|HQ}Xd6p6StiIn?g`N4)X2MuPsm$%boCSj599~S}=_}@b**q zSdu1#L#UFlI(|<@H)jP-Cl9iGe|1Mg(3>VJ6YqsZ-xG^>aI>dvWLyhuzZ~W{XtyY=po50%8iUiB&IKBY-Ac0Hfs#N z%1pNrm$DY$itup1PKD+ivjpVWIlh9~aSO|DTAIS?HC$3uTc*f|Yh>UJA+NiYN5AuMLQ4a&xg(fnk@#yvs8 ot7C~28~R;=mXpFA=P8wD^3+K(^&FOveO|U9b><`$gCPKa0(b)bEdT%j literal 0 HcmV?d00001 diff --git a/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca.pem b/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca.pem new file mode 100644 index 000000000..103f5f22a --- /dev/null +++ b/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-ca.pem @@ -0,0 +1,47 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAn8ERt7EKgO8gQHbMXxHXe01Wpzl5bmRLhGnQiopJ9aaauCED +RtzpfbanqO66yXUpKmhZxHUvSIPVZrZOVqKnRz8MlTAkfAnvRRnJaPAAk9sXbzZ1 +iqrDKAKFY/UQUpWVy0cTowQxz6jVbuEsLr3SfQQq1q1PmUIdK5TArr1Gg2KN8+om +uqy1Ao2Eln1sMgdXCLzqNRtRx+Nv1Sj8CIyMCie7LzbCJqsd02ZEghxFwG9eSHHu +if/lfnP9Wrj6WBH3WU/7qpii0cj3zx7imUXQq7OOtM/KSLv46LImQzEnAlb8TUNT +pu9NyE0f3AHbuQnoa0VbbWfVipFakJHsnJDgPwIDAQABAoIBAA+PjzNxuHCZDW7G +1sVaR/KOTloSv4Daa0vfwRzQt4xVlbOvU4UvHRDOHkQ9Bk8VOggT15qXp4SZHGVy +07kDz7NuF49FYmhkN1aajZz95uOzO/Ps10PFU/KtVcmuVzattCrAWgNPWnxVsuR0 +yzu9gnRqJLOtRTGY2DdXt/HNWFvEfqhM1pCfi/NjpUjZx3d7+P+Vp9eXBnOcrIPN +9fV00sqHgD/Ddm7swAs4Nh3errm3EYsSOBVu0OEMHob7MrgZ2ewG6wFdFDHXB8vp +vc4WmHbqqQ4GW5lkJ/qKwuPxfSS4vZ+eYaZmZkerN3oyeEYvqifbitRcxBnzc/v1 +YMT4+ZECgYEA2yNW3w7kHmgn7+lBknVYjQgRQ5Z7O9H/xyx+2FCt5qyBu7l4463g +KZ7c1zoJg087MkFxIsC2BAenPdA+wxmdou6PwlKMxzvKGtI1Xi0AzcPezrFKcZCI +cp7oh0rUJIrXAz4M6f1R6X+Hg8MYMl/CZthVSxfH5paC0afCdEaZTP0CgYEAuqCB +Gk/1tHdY3X/b5V1Cu52O8bjl4QPtoZ0Yj1ho6Q2bjlXhKuiA8xVkC68nSMlboXmH +tBuHADhocbamSvA/R+jpneTysOE2F18utsAuOhMQmb6JHYF+r7Xf/S7zuGmhBQ9P +AEHXyUKh31EnrG81wD/rzSh8OS3KYPVlbNo0ROsCgYA5sjFCI2KOWvAA65IXJIw+ +/ZvGBs3Fb0H/x8hR3dQbgtnZejjJAVOewbP1etNcXjUAw1gtRT3nC7jNvpF3vrvR +VSxGhoOIRUauDyB7/i9S/bohA27NPbefLhWc4We/g0qfEOxHgynY53nfiDNLuAiw +GU9DqSw5mvEwkBHTmW7tZQKBgDvlESoJqXh+qRWFWGRXNviRi3PGfHhn01b/3Qb8 +P8cz582ZgEdOETxyjAY382qnvPGo2EWUZBJNCDAeh2YbjqOce4WCGeVskfiUQqDC +MtPOlJBTFxxSF/96ZmWSMQPpWpUOIbOabg+Yg+zw1cPAeUa2/Q19xchwCrhtaVyy +9v17AoGAEnWqMtZGCl9XKrRLtowLS2GxI/iEfnPaxtZkbOTso/oFB/fFf+Cez5wQ +RIZ7/QYNYCrSVGMu0vvMiG+u5Am4yDpVmTCY6PIiZXfpXdwh9GZ33CjM8Mwgp5mu +5aOBmmdrxnPmO/rnWHJLnuacmCXiGThj4o7W5pAT87MAIZvWGZ8= +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIIDNTCCAh2gAwIBAgIUUo4sMqY4s3aM0RqjLhD1ZzGOhnowDQYJKoZIhvcNAQEL +BQAwKDESMBAGA1UEAwwJbWl0bXByb3h5MRIwEAYDVQQKDAltaXRtcHJveHkwHhcN +MjQwMzE3MDQwNjA2WhcNMzQwMzE3MDQwNjA2WjAoMRIwEAYDVQQDDAltaXRtcHJv +eHkxEjAQBgNVBAoMCW1pdG1wcm94eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBAJ/BEbexCoDvIEB2zF8R13tNVqc5eW5kS4Rp0IqKSfWmmrghA0bc6X22 +p6juusl1KSpoWcR1L0iD1Wa2Tlaip0c/DJUwJHwJ70UZyWjwAJPbF282dYqqwygC +hWP1EFKVlctHE6MEMc+o1W7hLC690n0EKtatT5lCHSuUwK69RoNijfPqJrqstQKN +hJZ9bDIHVwi86jUbUcfjb9Uo/AiMjAonuy82wiarHdNmRIIcRcBvXkhx7on/5X5z +/Vq4+lgR91lP+6qYotHI988e4plF0KuzjrTPyki7+OiyJkMxJwJW/E1DU6bvTchN +H9wB27kJ6GtFW21n1YqRWpCR7JyQ4D8CAwEAAaNXMFUwDwYDVR0TAQH/BAUwAwEB +/zATBgNVHSUEDDAKBggrBgEFBQcDATAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE +FBNhRsjEjijaA8rS3XezhrtEpVvRMA0GCSqGSIb3DQEBCwUAA4IBAQAc8wSUSk7y +Sz4pQmi6EciZmU9jEnBHld9uYJ4mqRR2oPm+eRPq0yW1VifNEgMLSqNcv8/EH93o +C16jHHQ5TrV0C+wMnnUN3BxliDsi6FdbMa92Df09K9C/LP/v68H4rtMaMskvOrHw +k/r/NsKCxZ1GywLA7s/yVKgtr7ARARf6hHJS6/bxqohdaCFZtxmQIH26sOkTV2Ds +pf1ey+d3xitOl/roLXV91KjGfML4PRCzIPOw0+odSw62e2kikI77OQxOEn4zjyg+ +a0B344gMV7LaNTyqLTx41wU0hk62CeHHS4Gc0XLMfw9NYPTrjyQYK1+lEWDSEHCn +TiBThXoIGeAU +-----END CERTIFICATE----- diff --git a/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-dhparam.pem b/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-dhparam.pem new file mode 100644 index 000000000..c10121fbf --- /dev/null +++ b/tests/integration/proxy_config/.mitm/proxy2/mitmproxy-dhparam.pem @@ -0,0 +1,14 @@ + +-----BEGIN DH PARAMETERS----- +MIICCAKCAgEAyT6LzpwVFS3gryIo29J5icvgxCnCebcdSe/NHMkD8dKJf8suFCg3 +O2+dguLakSVif/t6dhImxInJk230HmfC8q93hdcg/j8rLGJYDKu3ik6H//BAHKIv +j5O9yjU3rXCfmVJQic2Nne39sg3CreAepEts2TvYHhVv3TEAzEqCtOuTjgDv0ntJ +Gwpj+BJBRQGG9NvprX1YGJ7WOFBP/hWU7d6tgvE6Xa7T/u9QIKpYHMIkcN/l3ZFB +chZEqVlyrcngtSXCROTPcDOQ6Q8QzhaBJS+Z6rcsd7X+haiQqvoFcmaJ08Ks6LQC +ZIL2EtYJw8V8z7C0igVEBIADZBI6OTbuuhDwRw//zU1uq52Oc48CIZlGxTYG/Evq +o9EWAXUYVzWkDSTeBH1r4z/qLPE2cnhtMxbFxuvK53jGB0emy2y1Ei6IhKshJ5qX +IB/aE7SSHyQ3MDHHkCmQJCsOd4Mo26YX61NZ+n501XjqpCBQ2+DfZCBh8Va2wDyv +A2Ryg9SUz8j0AXViRNMJgJrr446yro/FuJZwnQcO3WQnXeqSBnURqKjmqkeFP+d8 +6mk2tqJaY507lRNqtGlLnj7f5RNoBFJDCLBNurVgfvq9TCVWKDIFD4vZRjCrnl6I +rD693XKIHUCWOjMh1if6omGXKHH40QuME2gNa50+YPn1iYDl88uDbbMCAQI= +-----END DH PARAMETERS----- diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py index d223abf95..239ca1a09 100644 --- a/tests/integration/proxy_config/conftest.py +++ b/tests/integration/proxy_config/conftest.py @@ -1,6 +1,58 @@ +import time +import os import pytest +import subprocess from ..helpers import get_environment_var +PROXIES = { + 'proxy1': { + 'name': 'proxy1', + 'port': 8080, + 'ssl_ca_certs': os.path.abspath('./tests/integration/proxy_config/.mitm/proxy1'), + 'auth': None + }, + 'proxy2': { + 'name': 'proxy2', + 'port': 8081, + 'ssl_ca_certs': os.path.abspath('./tests/integration/proxy_config/.mitm/proxy2'), + 'auth': ('testuser', 'testpassword') + } +} + +def docker_command(proxy): + cmd = [ + "docker", "run", "-d", # detach to run in background + "--rm", # remove container when stopped + "--name", proxy['name'], # name the container + "-p", f"{proxy['port']}:8080", # map the port + "-v", f"{proxy['ssl_ca_certs']}:/home/mitmproxy/.mitmproxy", # mount config as volume + "mitmproxy/mitmproxy", # docker image name + "mitmdump" # command to run + ] + if proxy['auth']: + cmd.append(f"--set proxyauth={proxy['auth'][0]}:{proxy['auth'][1]}") + print(" ".join(cmd)) + return " ".join(cmd) + +@pytest.fixture(scope='session', autouse=True) +def start_docker(): + with open("/tmp/proxyconfig-docker-start.log", "a") as output: + subprocess.call(docker_command(PROXIES['proxy1']), shell=True, stdout=output, stderr=output) + subprocess.call(docker_command(PROXIES['proxy2']), shell=True, stdout=output, stderr=output) + time.sleep(2) + yield + with open("/tmp/proxyconfig-docker-stop.log", "a") as output: + subprocess.call("docker stop proxy1", shell=True, stdout=output, stderr=output) + subprocess.call("docker stop proxy2", shell=True, stdout=output, stderr=output) + +@pytest.fixture() +def proxy1(): + return PROXIES['proxy1'] + +@pytest.fixture() +def proxy2(): + return PROXIES['proxy2'] + @pytest.fixture() def api_key(): return get_environment_var('PINECONE_API_KEY') diff --git a/tests/integration/proxy_config/test_proxy_settings.py b/tests/integration/proxy_config/test_proxy_settings.py index ed4f63718..906c1debf 100644 --- a/tests/integration/proxy_config/test_proxy_settings.py +++ b/tests/integration/proxy_config/test_proxy_settings.py @@ -4,41 +4,41 @@ from urllib3 import make_headers from urllib3.exceptions import InsecureRequestWarning -PROXY_URL_HTTPS = 'https://127.0.0.1:8080' -PROXY_URL_HTTP = 'http://127.0.0.1:8080' +PROXY1_URL_HTTPS = 'https://localhost:8080' +PROXY1_URL_HTTP = 'http://localhost:8080' -PROXY_AUTH_CREDS = 'testuser:testpassword' -PROXY_W_PROXY_AUTH = 'https://127.0.0.1:8081' +PROXY2_URL = 'https://localhost:8081' def exercise_all_apis(client, index_name): # Control plane client.list_indexes() - # Data plane index = client.Index(index_name) index.describe_index_stats() class TestProxyConfig: - def test_https_proxy_with_self_signed_cert(self, api_key, index_name): + def test_https_proxy_with_self_signed_cert(self, api_key, index_name, proxy1): + ssl_ca_certs = os.path.join(proxy1['ssl_ca_certs'], 'mitmproxy-ca-cert.pem') pc = Pinecone( api_key=api_key, - proxy_url=PROXY_URL_HTTPS, - ssl_ca_certs='./.mitm/proxy1/mitmproxy-ca-cert.pem', + proxy_url=PROXY1_URL_HTTPS, + ssl_ca_certs=ssl_ca_certs, ) exercise_all_apis(pc, index_name) - def test_http_proxy_with_self_signed_cert(self, api_key, index_name): + def test_http_proxy_with_self_signed_cert(self, api_key, index_name, proxy1): + ssl_ca_certs = os.path.join(proxy1['ssl_ca_certs'], 'mitmproxy-ca-cert.pem') pc = Pinecone( api_key=api_key, - proxy_url=PROXY_URL_HTTP, - ssl_ca_certs='./.mitm/proxy1/mitmproxy-ca-cert.pem', + proxy_url=PROXY1_URL_HTTP, + ssl_ca_certs=ssl_ca_certs, ) exercise_all_apis(pc, index_name) def test_proxy_with_ssl_verification_disabled_emits_warning(self, api_key): pc = Pinecone( api_key=api_key, - proxy_url=PROXY_URL_HTTPS, + proxy_url=PROXY1_URL_HTTPS, ssl_verify=False, ) @@ -49,30 +49,34 @@ def test_proxy_with_incorrect_cert_path(self, api_key): with pytest.raises(Exception) as e: pc = Pinecone( api_key=api_key, - proxy_url=PROXY_URL_HTTPS, + proxy_url=PROXY1_URL_HTTPS, ssl_ca_certs='~/incorrect/path', ) pc.list_indexes() assert 'No such file or directory' in str(e.value) - def test_proxy_with_valid_path_to_incorrect_cert(self, api_key): + def test_proxy_with_valid_path_to_incorrect_cert(self, api_key, proxy2): + ssl_ca_certs = os.path.join(proxy2['ssl_ca_certs'], 'mitmproxy-ca-cert.pem') with pytest.raises(Exception) as e: pc = Pinecone( api_key=api_key, - proxy_url=PROXY_URL_HTTPS, - ssl_ca_certs='./.mitm/proxy2/mitmproxy-ca-cert.pem', + proxy_url=PROXY1_URL_HTTPS, + ssl_ca_certs=ssl_ca_certs, ) pc.list_indexes() assert 'CERTIFICATE_VERIFY_FAILED' in str(e.value) - def test_proxy_that_requires_proxyauth(self, api_key, index_name): + def test_proxy_that_requires_proxyauth(self, api_key, index_name, proxy2): + ssl_ca_certs = os.path.join(proxy2['ssl_ca_certs'], 'mitmproxy-ca-cert.pem') + username = proxy2['auth'][0] + password = proxy2['auth'][1] pc = Pinecone( api_key=api_key, - proxy_url=PROXY_W_PROXY_AUTH, - proxy_headers=make_headers(proxy_basic_auth=PROXY_AUTH_CREDS), - ssl_ca_certs='./.mitm/proxy2/mitmproxy-ca-cert.pem' + proxy_url=PROXY2_URL, + proxy_headers=make_headers(proxy_basic_auth=f'{username}:{password}'), + ssl_ca_certs=ssl_ca_certs ) exercise_all_apis(pc, index_name) diff --git a/tests/perf/grpc/conftest.py b/tests/perf/grpc/conftest.py new file mode 100644 index 000000000..88e7f4755 --- /dev/null +++ b/tests/perf/grpc/conftest.py @@ -0,0 +1,28 @@ +import pytest +import time + +@pytest.fixture(scope="session") +def idx(): + from pinecone import ServerlessSpec + from pinecone.grpc import PineconeGRPC + pc = PineconeGRPC() + + index_name = 'perf-testing' + if index_name not in pc.list_indexes().names(): + pc.create_index( + index_name, + dimension=2, + spec=ServerlessSpec(cloud='aws', region='us-west-2') + ) + + return pc.Index(index_name) + +def setup_list_data(idx, target_namespace, wait): + # Upsert a bunch more stuff for testing list pagination + for i in range(0, 1000, 50): + idx.upsert(vectors=[ + (str(i+d), [0.111, 0.222]) for d in range(50) + ], + namespace=target_namespace + ) + time.sleep(60) diff --git a/tests/perf/grpc/test_list.py b/tests/perf/grpc/test_list.py new file mode 100644 index 000000000..bf47a5dca --- /dev/null +++ b/tests/perf/grpc/test_list.py @@ -0,0 +1,26 @@ +import pytest +import cProfile, pstats, io +from pstats import SortKey + +def benchmark_config(): + return { + 'iterations': 10, + 'rounds': 10 + } + +def test_list_paginated(benchmark, idx): + benchmark.pedantic(idx.list_paginated, **benchmark_config()) + +def test_list_paginated2(benchmark, idx): + benchmark.pedantic(idx.list_paginated2, **benchmark_config()) + +def test_list_cProfile(idx): + pr = cProfile.Profile() + pr.enable() + idx.list_paginated2() + pr.disable() + s = io.StringIO() + sortby = SortKey.CUMULATIVE + ps = pstats.Stats(pr, stream=s).sort_stats(sortby) + ps.print_stats() + print(s.getvalue()) From 677d282d7bcb5031bcabbdb7e01ab66c387c02ed Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 11:08:13 -0400 Subject: [PATCH 19/32] Adjust urls --- tests/integration/proxy_config/test_proxy_settings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/proxy_config/test_proxy_settings.py b/tests/integration/proxy_config/test_proxy_settings.py index 906c1debf..2cb5446c9 100644 --- a/tests/integration/proxy_config/test_proxy_settings.py +++ b/tests/integration/proxy_config/test_proxy_settings.py @@ -4,10 +4,10 @@ from urllib3 import make_headers from urllib3.exceptions import InsecureRequestWarning -PROXY1_URL_HTTPS = 'https://localhost:8080' -PROXY1_URL_HTTP = 'http://localhost:8080' +PROXY1_URL_HTTPS = 'https://127.0.0.1:8080' +PROXY1_URL_HTTP = 'http://127.0.0.1:8080' -PROXY2_URL = 'https://localhost:8081' +PROXY2_URL = 'https://127.0.0.1:8081' def exercise_all_apis(client, index_name): # Control plane From 0e5173026cb075c0b91edd4b7497efbde0c6bba9 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 11:12:31 -0400 Subject: [PATCH 20/32] Remove files accidentally committed --- tests/perf/grpc/conftest.py | 28 ---------------------------- tests/perf/grpc/test_list.py | 26 -------------------------- 2 files changed, 54 deletions(-) delete mode 100644 tests/perf/grpc/conftest.py delete mode 100644 tests/perf/grpc/test_list.py diff --git a/tests/perf/grpc/conftest.py b/tests/perf/grpc/conftest.py deleted file mode 100644 index 88e7f4755..000000000 --- a/tests/perf/grpc/conftest.py +++ /dev/null @@ -1,28 +0,0 @@ -import pytest -import time - -@pytest.fixture(scope="session") -def idx(): - from pinecone import ServerlessSpec - from pinecone.grpc import PineconeGRPC - pc = PineconeGRPC() - - index_name = 'perf-testing' - if index_name not in pc.list_indexes().names(): - pc.create_index( - index_name, - dimension=2, - spec=ServerlessSpec(cloud='aws', region='us-west-2') - ) - - return pc.Index(index_name) - -def setup_list_data(idx, target_namespace, wait): - # Upsert a bunch more stuff for testing list pagination - for i in range(0, 1000, 50): - idx.upsert(vectors=[ - (str(i+d), [0.111, 0.222]) for d in range(50) - ], - namespace=target_namespace - ) - time.sleep(60) diff --git a/tests/perf/grpc/test_list.py b/tests/perf/grpc/test_list.py deleted file mode 100644 index bf47a5dca..000000000 --- a/tests/perf/grpc/test_list.py +++ /dev/null @@ -1,26 +0,0 @@ -import pytest -import cProfile, pstats, io -from pstats import SortKey - -def benchmark_config(): - return { - 'iterations': 10, - 'rounds': 10 - } - -def test_list_paginated(benchmark, idx): - benchmark.pedantic(idx.list_paginated, **benchmark_config()) - -def test_list_paginated2(benchmark, idx): - benchmark.pedantic(idx.list_paginated2, **benchmark_config()) - -def test_list_cProfile(idx): - pr = cProfile.Profile() - pr.enable() - idx.list_paginated2() - pr.disable() - s = io.StringIO() - sortby = SortKey.CUMULATIVE - ps = pstats.Stats(pr, stream=s).sort_stats(sortby) - ps.print_stats() - print(s.getvalue()) From 174816cc780a01b28e280e61b8bfaee76a6a6a1b Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 11:29:05 -0400 Subject: [PATCH 21/32] Upload test log as artifacts --- .github/workflows/testing-integration.yaml | 6 ++++++ .gitignore | 1 + tests/integration/proxy_config/conftest.py | 4 ++-- tests/integration/proxy_config/logs/.gitkeep | 0 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tests/integration/proxy_config/logs/.gitkeep diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index a5b1b258d..b320a8e36 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -38,6 +38,12 @@ jobs: env: PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' PINECONE_INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} + - name: Upload logs + if: always() + uses: actions/upload-artifact@v2 + with: + name: proxy_config_test_logs + path: tests/integration/proxy_config/logs - name: Cleanup index if: always() uses: ./.github/actions/delete-index diff --git a/.gitignore b/.gitignore index fbbb5de87..4200d51d6 100644 --- a/.gitignore +++ b/.gitignore @@ -155,3 +155,4 @@ dmypy.json *.hdf5 *~ +tests/integration/proxy_config/logs \ No newline at end of file diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py index 239ca1a09..2bf89adfc 100644 --- a/tests/integration/proxy_config/conftest.py +++ b/tests/integration/proxy_config/conftest.py @@ -36,12 +36,12 @@ def docker_command(proxy): @pytest.fixture(scope='session', autouse=True) def start_docker(): - with open("/tmp/proxyconfig-docker-start.log", "a") as output: + with open("tests/integration/proxy_config/logs/proxyconfig-docker-start.log", "a") as output: subprocess.call(docker_command(PROXIES['proxy1']), shell=True, stdout=output, stderr=output) subprocess.call(docker_command(PROXIES['proxy2']), shell=True, stdout=output, stderr=output) time.sleep(2) yield - with open("/tmp/proxyconfig-docker-stop.log", "a") as output: + with open("tests/integration/proxy_config/logs/proxyconfig-docker-stop.log", "a") as output: subprocess.call("docker stop proxy1", shell=True, stdout=output, stderr=output) subprocess.call("docker stop proxy2", shell=True, stdout=output, stderr=output) diff --git a/tests/integration/proxy_config/logs/.gitkeep b/tests/integration/proxy_config/logs/.gitkeep new file mode 100644 index 000000000..e69de29bb From a6a1e9e68fb2327ab6d3fb950783ea28f7b4e064 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 15:48:56 -0400 Subject: [PATCH 22/32] Log docker status --- tests/integration/proxy_config/conftest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py index 2bf89adfc..dc25cc27d 100644 --- a/tests/integration/proxy_config/conftest.py +++ b/tests/integration/proxy_config/conftest.py @@ -40,6 +40,9 @@ def start_docker(): subprocess.call(docker_command(PROXIES['proxy1']), shell=True, stdout=output, stderr=output) subprocess.call(docker_command(PROXIES['proxy2']), shell=True, stdout=output, stderr=output) time.sleep(2) + with open("tests/integration/proxy_config/logs/proxyconfig-docker-ps.log", "a") as output: + subprocess.call("docker ps", shell=True, stdout=output, stderr=output) + yield with open("tests/integration/proxy_config/logs/proxyconfig-docker-stop.log", "a") as output: subprocess.call("docker stop proxy1", shell=True, stdout=output, stderr=output) From cb3ad734d5d2953b94bdb3583f361cd8d6df8945 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 16:08:54 -0400 Subject: [PATCH 23/32] Adjust sleep --- tests/integration/proxy_config/conftest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py index dc25cc27d..eba5d4f8a 100644 --- a/tests/integration/proxy_config/conftest.py +++ b/tests/integration/proxy_config/conftest.py @@ -39,9 +39,9 @@ def start_docker(): with open("tests/integration/proxy_config/logs/proxyconfig-docker-start.log", "a") as output: subprocess.call(docker_command(PROXIES['proxy1']), shell=True, stdout=output, stderr=output) subprocess.call(docker_command(PROXIES['proxy2']), shell=True, stdout=output, stderr=output) - time.sleep(2) + time.sleep(60) with open("tests/integration/proxy_config/logs/proxyconfig-docker-ps.log", "a") as output: - subprocess.call("docker ps", shell=True, stdout=output, stderr=output) + subprocess.call("docker ps --all", shell=True, stdout=output, stderr=output) yield with open("tests/integration/proxy_config/logs/proxyconfig-docker-stop.log", "a") as output: From 87092a502935a88b7730ed787858e058112df703 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 16:15:09 -0400 Subject: [PATCH 24/32] Bump upload-artifact --- .github/workflows/testing-integration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index b320a8e36..8d954c3df 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -40,7 +40,7 @@ jobs: PINECONE_INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} - name: Upload logs if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: proxy_config_test_logs path: tests/integration/proxy_config/logs From edfb88cd3e96ff221bbb3fc085bda65fccd08585 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 16:15:39 -0400 Subject: [PATCH 25/32] Temporarily comment other tests --- .github/workflows/pr.yaml | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 69c6150d4..cf4f2a38e 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -17,30 +17,30 @@ jobs: # dependency-tests: # uses: './.github/workflows/testing-dependency.yaml' # secrets: inherit - package: - name: Check packaging - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.8, 3.12] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Setup Poetry - uses: ./.github/actions/setup-poetry - - name: Package - run: poetry build + # package: + # name: Check packaging + # runs-on: ubuntu-latest + # strategy: + # matrix: + # python-version: [3.8, 3.12] + # steps: + # - uses: actions/checkout@v4 + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v5 + # with: + # python-version: ${{ matrix.python-version }} + # - name: Setup Poetry + # uses: ./.github/actions/setup-poetry + # - name: Package + # run: poetry build - build-docs: - name: Build docs with pdoc - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build docs with pdoc - uses: './.github/actions/build-docs' - with: - python-version: 3.11 \ No newline at end of file + # build-docs: + # name: Build docs with pdoc + # runs-on: ubuntu-latest + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # - name: Build docs with pdoc + # uses: './.github/actions/build-docs' + # with: + # python-version: 3.11 \ No newline at end of file From 72dd0b2cdbd612a1670d47be32639a37fa67869b Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 16:23:30 -0400 Subject: [PATCH 26/32] Temporarily keep containers after they exit --- tests/integration/proxy_config/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py index eba5d4f8a..05a5abe90 100644 --- a/tests/integration/proxy_config/conftest.py +++ b/tests/integration/proxy_config/conftest.py @@ -22,7 +22,7 @@ def docker_command(proxy): cmd = [ "docker", "run", "-d", # detach to run in background - "--rm", # remove container when stopped + # "--rm", # remove container when stopped "--name", proxy['name'], # name the container "-p", f"{proxy['port']}:8080", # map the port "-v", f"{proxy['ssl_ca_certs']}:/home/mitmproxy/.mitmproxy", # mount config as volume From c3a6566a2d480ecdddbea72d0b87be298e556573 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Wed, 20 Mar 2024 16:50:20 -0400 Subject: [PATCH 27/32] Adjust log out --- tests/integration/proxy_config/conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py index 05a5abe90..29a79dd84 100644 --- a/tests/integration/proxy_config/conftest.py +++ b/tests/integration/proxy_config/conftest.py @@ -37,9 +37,15 @@ def docker_command(proxy): @pytest.fixture(scope='session', autouse=True) def start_docker(): with open("tests/integration/proxy_config/logs/proxyconfig-docker-start.log", "a") as output: + output.write("cert path: " + PROXIES['proxy1']['ssl_ca_certs'] + "\n\n") + subprocess.call("ls -l " + PROXIES['proxy1']['ssl_ca_certs'], shell=True, stdout=output, stderr=output) + + output.write("\n\nStarting docker containers\n") + output.write("Going to run: " + docker_command(PROXIES['proxy1']) + "\n") subprocess.call(docker_command(PROXIES['proxy1']), shell=True, stdout=output, stderr=output) + output.write("Going to run: " + docker_command(PROXIES['proxy2']) + "\n") subprocess.call(docker_command(PROXIES['proxy2']), shell=True, stdout=output, stderr=output) - time.sleep(60) + time.sleep(30) with open("tests/integration/proxy_config/logs/proxyconfig-docker-ps.log", "a") as output: subprocess.call("docker ps --all", shell=True, stdout=output, stderr=output) From e05923efe82dde15fdb0b51cecf935016d6edace Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 21 Mar 2024 11:22:38 -0400 Subject: [PATCH 28/32] Disable proxy tests in CI --- .github/workflows/testing-integration.yaml | 310 +++++++++--------- tests/integration/proxy_config/conftest.py | 27 +- .../proxy_config/test_proxy_settings.py | 6 +- 3 files changed, 172 insertions(+), 171 deletions(-) diff --git a/.github/workflows/testing-integration.yaml b/.github/workflows/testing-integration.yaml index 8d954c3df..3334becf5 100644 --- a/.github/workflows/testing-integration.yaml +++ b/.github/workflows/testing-integration.yaml @@ -3,179 +3,179 @@ name: "Integration Tests" workflow_call: {} jobs: - setup-index: - name: Setup proxyconfig test index - runs-on: ubuntu-latest - outputs: - index_name: ${{ steps.create-index.outputs.index_name }} - steps: - - uses: actions/checkout@v4 - - name: Create index - id: create-index - uses: ./.github/actions/create-index - with: - PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} - NAME_PREFIX: 'proxyconfig-' - REGION: 'us-west-2' - CLOUD: 'aws' - DIMENSION: 1536 - METRIC: 'cosine' + # setup-index: + # name: Setup proxyconfig test index + # runs-on: ubuntu-latest + # outputs: + # index_name: ${{ steps.create-index.outputs.index_name }} + # steps: + # - uses: actions/checkout@v4 + # - name: Create index + # id: create-index + # uses: ./.github/actions/create-index + # with: + # PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + # NAME_PREFIX: 'proxyconfig-' + # REGION: 'us-west-2' + # CLOUD: 'aws' + # DIMENSION: 1536 + # METRIC: 'cosine' + + # proxy-config: + # name: Proxy config tests + # needs: [setup-index] + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: actions/setup-python@v5 + # with: + # python-version: 3.9 + # - name: Setup Poetry + # uses: ./.github/actions/setup-poetry + # - name: 'Run integration tests (proxy config)' + # run: | + # poetry run pytest tests/integration/proxy_config -s -v + # env: + # PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' + # PINECONE_INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} + # - name: Upload logs + # if: always() + # uses: actions/upload-artifact@v4 + # with: + # name: proxy_config_test_logs + # path: tests/integration/proxy_config/logs + # - name: Cleanup index + # if: always() + # uses: ./.github/actions/delete-index + # with: + # PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} + # INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} - proxy-config: - name: Proxy config tests - needs: [setup-index] + data-plane-serverless: + name: Data plane serverless integration tests runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python_version: [3.8, 3.12] + use_grpc: [true, false] + metric: + - cosine + # - euclidean + # - dotproduct + spec: + - '{ "serverless": { "region": "us-west-2", "cloud": "aws" }}' steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: ./.github/actions/test-data-plane with: - python-version: 3.9 - - name: Setup Poetry - uses: ./.github/actions/setup-poetry - - name: 'Run integration tests (proxy config)' - run: | - poetry run pytest tests/integration/proxy_config -s -v - env: + python_version: '${{ matrix.python_version }}' + use_grpc: '${{ matrix.use_grpc }}' + metric: '${{ matrix.metric }}' + spec: '${{ matrix.spec }}' PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' - PINECONE_INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} - - name: Upload logs - if: always() - uses: actions/upload-artifact@v4 - with: - name: proxy_config_test_logs - path: tests/integration/proxy_config/logs - - name: Cleanup index - if: always() - uses: ./.github/actions/delete-index - with: - PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }} - INDEX_NAME: ${{ needs.setup-index.outputs.index_name }} - -# data-plane-serverless: -# name: Data plane serverless integration tests + freshness_timeout_seconds: 600 +# data-plane-pod: +# name: Data plane pod integration tests # runs-on: ubuntu-latest # strategy: -# fail-fast: false +# max-parallel: 1 # matrix: -# python_version: [3.8, 3.12] # use_grpc: [true, false] -# metric: -# - cosine -# # - euclidean -# # - dotproduct +# metric: [cosine, dotproduct] # spec: -# - '{ "serverless": { "region": "us-west-2", "cloud": "aws" }}' +# - '{ "pod": { "environment": "us-east1-gcp", "pod_type": "p1" }}' # steps: # - uses: actions/checkout@v4 # - uses: ./.github/actions/test-data-plane # with: -# python_version: '${{ matrix.python_version }}' # use_grpc: '${{ matrix.use_grpc }}' # metric: '${{ matrix.metric }}' # spec: '${{ matrix.spec }}' # PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' -# freshness_timeout_seconds: 600 -# # data-plane-pod: -# # name: Data plane pod integration tests -# # runs-on: ubuntu-latest -# # strategy: -# # max-parallel: 1 -# # matrix: -# # use_grpc: [true, false] -# # metric: [cosine, dotproduct] -# # spec: -# # - '{ "pod": { "environment": "us-east1-gcp", "pod_type": "p1" }}' -# # steps: -# # - uses: actions/checkout@v4 -# # - uses: ./.github/actions/test-data-plane -# # with: -# # use_grpc: '${{ matrix.use_grpc }}' -# # metric: '${{ matrix.metric }}' -# # spec: '${{ matrix.spec }}' -# # PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' -# control-rest-pod: -# name: control plane pod/collection tests -# runs-on: ubuntu-latest -# strategy: -# matrix: -# pineconeEnv: -# - prod -# testConfig: -# - python-version: 3.8 -# pod: { environment: 'us-east1-gcp'} -# - python-version: 3.12 -# pod: { environment: 'us-east4-gcp'} -# fail-fast: false -# steps: -# - uses: actions/checkout@v4 -# - name: 'Set up Python ${{ matrix.testConfig.python-version }}' -# uses: actions/setup-python@v5 -# with: -# python-version: '${{ matrix.testConfig.python-version }}' -# - name: Setup Poetry -# uses: ./.github/actions/setup-poetry -# - name: 'Run integration tests (REST, prod)' -# if: matrix.pineconeEnv == 'prod' -# run: poetry run pytest tests/integration/control/serverless -s -v -# env: -# PINECONE_DEBUG_CURL: 'true' -# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' -# PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' -# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' -# DIMENSION: 1536 -# METRIC: 'cosine' -# - name: 'Run integration tests (REST, staging)' -# if: matrix.pineconeEnv == 'staging' -# run: poetry run pytest tests/integration/control/serverless -s -v -# env: -# PINECONE_DEBUG_CURL: 'true' -# PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' -# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' -# PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' -# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' -# DIMENSION: 1536 -# METRIC: 'cosine' + control-rest-pod: + name: control plane pod/collection tests + runs-on: ubuntu-latest + strategy: + matrix: + pineconeEnv: + - prod + testConfig: + - python-version: 3.8 + pod: { environment: 'us-east1-gcp'} + - python-version: 3.12 + pod: { environment: 'us-east4-gcp'} + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: 'Set up Python ${{ matrix.testConfig.python-version }}' + uses: actions/setup-python@v5 + with: + python-version: '${{ matrix.testConfig.python-version }}' + - name: Setup Poetry + uses: ./.github/actions/setup-poetry + - name: 'Run integration tests (REST, prod)' + if: matrix.pineconeEnv == 'prod' + run: poetry run pytest tests/integration/control/serverless -s -v + env: + PINECONE_DEBUG_CURL: 'true' + PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' + PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' + GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' + DIMENSION: 1536 + METRIC: 'cosine' + - name: 'Run integration tests (REST, staging)' + if: matrix.pineconeEnv == 'staging' + run: poetry run pytest tests/integration/control/serverless -s -v + env: + PINECONE_DEBUG_CURL: 'true' + PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' + PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' + PINECONE_ENVIRONMENT: '${{ matrix.testConfig.pod.environment }}' + GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' + DIMENSION: 1536 + METRIC: 'cosine' -# control-rest-serverless: -# name: control plane serverless -# runs-on: ubuntu-latest -# strategy: -# matrix: -# pineconeEnv: -# - prod -# testConfig: -# - python-version: 3.8 # Do one test run with 3.8 for sanity check -# pod: { environment: 'us-east1-gcp'} -# serverless: { cloud: 'aws', region: 'us-west-2'} -# - python-version: 3.12 -# pod: { environment: 'us-east1-gcp'} -# serverless: { cloud: 'aws', region: 'us-west-2'} -# fail-fast: false -# steps: -# - uses: actions/checkout@v4 -# - name: 'Set up Python ${{ matrix.testConfig.python-version }}' -# uses: actions/setup-python@v5 -# with: -# python-version: '${{ matrix.testConfig.python-version }}' -# - name: Setup Poetry -# uses: ./.github/actions/setup-poetry -# - name: 'Run integration tests (REST, prod)' -# if: matrix.pineconeEnv == 'prod' -# run: poetry run pytest tests/integration/control/serverless -s -vv -# env: -# PINECONE_DEBUG_CURL: 'true' -# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' -# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' -# SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' -# SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' -# - name: 'Run integration tests (REST, staging)' -# if: matrix.pineconeEnv == 'staging' -# run: poetry run pytest tests/integration/control/serverless -s -vv -# env: -# PINECONE_DEBUG_CURL: 'true' -# PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' -# PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' -# GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' -# SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' -# SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' + control-rest-serverless: + name: control plane serverless + runs-on: ubuntu-latest + strategy: + matrix: + pineconeEnv: + - prod + testConfig: + - python-version: 3.8 # Do one test run with 3.8 for sanity check + pod: { environment: 'us-east1-gcp'} + serverless: { cloud: 'aws', region: 'us-west-2'} + - python-version: 3.12 + pod: { environment: 'us-east1-gcp'} + serverless: { cloud: 'aws', region: 'us-west-2'} + fail-fast: false + steps: + - uses: actions/checkout@v4 + - name: 'Set up Python ${{ matrix.testConfig.python-version }}' + uses: actions/setup-python@v5 + with: + python-version: '${{ matrix.testConfig.python-version }}' + - name: Setup Poetry + uses: ./.github/actions/setup-poetry + - name: 'Run integration tests (REST, prod)' + if: matrix.pineconeEnv == 'prod' + run: poetry run pytest tests/integration/control/serverless -s -vv + env: + PINECONE_DEBUG_CURL: 'true' + PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY }}' + GITHUB_BUILD_NUMBER: '${{ github.run_number }}-p-${{ matrix.testConfig.python-version}}' + SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' + SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' + - name: 'Run integration tests (REST, staging)' + if: matrix.pineconeEnv == 'staging' + run: poetry run pytest tests/integration/control/serverless -s -vv + env: + PINECONE_DEBUG_CURL: 'true' + PINECONE_CONTROLLER_HOST: 'https://api-staging.pinecone.io' + PINECONE_API_KEY: '${{ secrets.PINECONE_API_KEY_STAGING }}' + GITHUB_BUILD_NUMBER: '${{ github.run_number }}-s-${{ matrix.testConfig.python-version}}' + SERVERLESS_CLOUD: '${{ matrix.testConfig.serverless.cloud }}' + SERVERLESS_REGION: '${{ matrix.testConfig.serverless.region }}' diff --git a/tests/integration/proxy_config/conftest.py b/tests/integration/proxy_config/conftest.py index 29a79dd84..2c59361f1 100644 --- a/tests/integration/proxy_config/conftest.py +++ b/tests/integration/proxy_config/conftest.py @@ -22,7 +22,7 @@ def docker_command(proxy): cmd = [ "docker", "run", "-d", # detach to run in background - # "--rm", # remove container when stopped + "--rm", # remove container when stopped "--name", proxy['name'], # name the container "-p", f"{proxy['port']}:8080", # map the port "-v", f"{proxy['ssl_ca_certs']}:/home/mitmproxy/.mitmproxy", # mount config as volume @@ -33,26 +33,27 @@ def docker_command(proxy): cmd.append(f"--set proxyauth={proxy['auth'][0]}:{proxy['auth'][1]}") print(" ".join(cmd)) return " ".join(cmd) - + +def run_cmd(cmd, output): + output.write("Going to run: " + cmd + "\n") + exit_code = subprocess.call(cmd, shell=True, stdout=output, stderr=output) + if exit_code != 0: + raise Exception(f"Failed to run command: {cmd}") + @pytest.fixture(scope='session', autouse=True) def start_docker(): with open("tests/integration/proxy_config/logs/proxyconfig-docker-start.log", "a") as output: - output.write("cert path: " + PROXIES['proxy1']['ssl_ca_certs'] + "\n\n") - subprocess.call("ls -l " + PROXIES['proxy1']['ssl_ca_certs'], shell=True, stdout=output, stderr=output) + run_cmd(docker_command(PROXIES['proxy1']), output) + run_cmd(docker_command(PROXIES['proxy2']), output) - output.write("\n\nStarting docker containers\n") - output.write("Going to run: " + docker_command(PROXIES['proxy1']) + "\n") - subprocess.call(docker_command(PROXIES['proxy1']), shell=True, stdout=output, stderr=output) - output.write("Going to run: " + docker_command(PROXIES['proxy2']) + "\n") - subprocess.call(docker_command(PROXIES['proxy2']), shell=True, stdout=output, stderr=output) - time.sleep(30) + time.sleep(5) with open("tests/integration/proxy_config/logs/proxyconfig-docker-ps.log", "a") as output: - subprocess.call("docker ps --all", shell=True, stdout=output, stderr=output) + run_cmd("docker ps --all", output) yield with open("tests/integration/proxy_config/logs/proxyconfig-docker-stop.log", "a") as output: - subprocess.call("docker stop proxy1", shell=True, stdout=output, stderr=output) - subprocess.call("docker stop proxy2", shell=True, stdout=output, stderr=output) + run_cmd("docker stop proxy1", output) + run_cmd("docker stop proxy2", output) @pytest.fixture() def proxy1(): diff --git a/tests/integration/proxy_config/test_proxy_settings.py b/tests/integration/proxy_config/test_proxy_settings.py index 2cb5446c9..906c1debf 100644 --- a/tests/integration/proxy_config/test_proxy_settings.py +++ b/tests/integration/proxy_config/test_proxy_settings.py @@ -4,10 +4,10 @@ from urllib3 import make_headers from urllib3.exceptions import InsecureRequestWarning -PROXY1_URL_HTTPS = 'https://127.0.0.1:8080' -PROXY1_URL_HTTP = 'http://127.0.0.1:8080' +PROXY1_URL_HTTPS = 'https://localhost:8080' +PROXY1_URL_HTTP = 'http://localhost:8080' -PROXY2_URL = 'https://127.0.0.1:8081' +PROXY2_URL = 'https://localhost:8081' def exercise_all_apis(client, index_name): # Control plane From 9714afdc1b624d06d90e3646ad7365905ff7569c Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 21 Mar 2024 11:23:11 -0400 Subject: [PATCH 29/32] Reenable other tests --- .github/workflows/pr.yaml | 64 +++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index cf4f2a38e..e48aa2681 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -8,39 +8,39 @@ on: workflow_dispatch: {} jobs: - # unit-tests: - # uses: './.github/workflows/testing-unit.yaml' - # secrets: inherit + unit-tests: + uses: './.github/workflows/testing-unit.yaml' + secrets: inherit integration-tests: uses: './.github/workflows/testing-integration.yaml' secrets: inherit - # dependency-tests: - # uses: './.github/workflows/testing-dependency.yaml' - # secrets: inherit - # package: - # name: Check packaging - # runs-on: ubuntu-latest - # strategy: - # matrix: - # python-version: [3.8, 3.12] - # steps: - # - uses: actions/checkout@v4 - # - name: Set up Python ${{ matrix.python-version }} - # uses: actions/setup-python@v5 - # with: - # python-version: ${{ matrix.python-version }} - # - name: Setup Poetry - # uses: ./.github/actions/setup-poetry - # - name: Package - # run: poetry build + dependency-tests: + uses: './.github/workflows/testing-dependency.yaml' + secrets: inherit + package: + name: Check packaging + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.12] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Setup Poetry + uses: ./.github/actions/setup-poetry + - name: Package + run: poetry build - # build-docs: - # name: Build docs with pdoc - # runs-on: ubuntu-latest - # steps: - # - name: Checkout - # uses: actions/checkout@v4 - # - name: Build docs with pdoc - # uses: './.github/actions/build-docs' - # with: - # python-version: 3.11 \ No newline at end of file + build-docs: + name: Build docs with pdoc + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build docs with pdoc + uses: './.github/actions/build-docs' + with: + python-version: 3.11 \ No newline at end of file From a057145bf8c9567198e2ad87265bee5d961c2f7f Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 21 Mar 2024 11:38:55 -0400 Subject: [PATCH 30/32] Update README --- README.md | 58 ++++++++++++++++++++++++++++++++++-- pinecone/control/pinecone.py | 1 - 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d7016ec71..964db7c93 100644 --- a/README.md +++ b/README.md @@ -71,14 +71,14 @@ from pinecone import Pinecone pc = Pinecone() # This reads the PINECONE_API_KEY env var ``` -#### Using a configuration object +#### Using configuration keyword params If you prefer to pass configuration in code, for example if you have a complex application that needs to interact with multiple different Pinecone projects, the constructor accepts a keyword argument for `api_key`. If you pass configuration in this way, you can have full control over what name to use for the environment variable, sidestepping any issues that would result from two different client instances both needing to read the same `PINECONE_API_KEY` variable that the client implicitly checks for. -Configuration passed with keyword arguments takes precedent over environment variables. +Configuration passed with keyword arguments takes precedence over environment variables. ```python import os @@ -87,6 +87,60 @@ from pinecone import Pinecone pc = Pinecone(api_key=os.environ.get('CUSTOM_VAR')) ``` +### Proxy configuration + +If your network setup requires you to interact with Pinecone via a proxy, you will need +to pass additional configuration using optional keyword parameters. These optional parameters are forwarded to `urllib3`, which is the underlying library currently used by the Pinecone client to make HTTP requests. You may find it helpful to refer to the [urllib3 documentation on working with proxies](https://urllib3.readthedocs.io/en/stable/advanced-usage.html#http-and-https-proxies) while troubleshooting these settings. + +Here is a basic example: + +```python +from pinecone import Pinecone + +pc = Pinecone( + api_key='YOUR_API_KEY', + proxy_url='https://your-proxy.com' +) + +pc.list_indexes() +``` + +If your proxy requires authentication, you can pass those values in a header dictionary using the `proxy_headers` parameter. + +```python +from pinecone import Pinecone +import urllib3 import make_headers + +pc = Pinecone( + api_key='YOUR_API_KEY', + proxy_url='https://your-proxy.com', + proxy_headers=make_headers(proxy_basic_auth='username:password') +) + +pc.list_indexes() +``` + +### Using proxies with self-signed certificates + +By default the Pinecone Python client will perform SSL certificate verification +using the CA bundle maintained by Mozilla in the [certifi](https://pypi.org/project/certifi/) package. + +If your proxy server is using a self-signed certificate, you will need to pass the path to the certificate in PEM format using the `ssl_ca_certs` parameter. + +```python +from pinecone import Pinecone +import urllib3 import make_headers + +pc = Pinecone( + api_key="YOUR_API_KEY", + proxy_url='https://your-proxy.com', + proxy_headers=make_headers(proxy_basic_auth='username:password') + ssl_ca_certs='path/to/cert-bundle.pem' +) + +pc.list_indexes() +``` + ### Working with GRPC (for improved performance) If you've followed instructions above to install with optional `grpc` extras, you can unlock some performance improvements by working with an alternative version of the client imported from the `pinecone.grpc` subpackage. diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index 2fc6eb563..2d1165601 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -96,7 +96,6 @@ def __init__( or share with Pinecone support. **Be very careful with this option, as it will print out your API key** which forms part of a required authentication header. Default: `false` - ### Proxy configuration If your network setup requires you to interact with Pinecone via a proxy, you will need From 70b2d9a2171afae5ed46299a90aeb821bee6b397 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 21 Mar 2024 11:50:58 -0400 Subject: [PATCH 31/32] Update READMe --- README.md | 23 ++++++++++++++++++++++- pinecone/control/pinecone.py | 30 ++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 964db7c93..1277555e9 100644 --- a/README.md +++ b/README.md @@ -134,13 +134,34 @@ import urllib3 import make_headers pc = Pinecone( api_key="YOUR_API_KEY", proxy_url='https://your-proxy.com', - proxy_headers=make_headers(proxy_basic_auth='username:password') + proxy_headers=make_headers(proxy_basic_auth='username:password'), ssl_ca_certs='path/to/cert-bundle.pem' ) pc.list_indexes() ``` +### Disabling SSL verification + +If you would like to disable SSL verification, you can pass the `ssl_verify` +parameter with a value of `False`. We do not recommend going to production with SSL verification disabled. + +```python +from pinecone import Pinecone +import urllib3 import make_headers + +pc = Pinecone( + api_key='YOUR_API_KEY', + proxy_url='https://your-proxy.com', + proxy_headers=make_headers(proxy_basic_auth='username:password'), + ssl_ca_certs='path/to/cert-bundle.pem', + ssl_verify=False +) + +pc.list_indexes() + +``` + ### Working with GRPC (for improved performance) If you've followed instructions above to install with optional `grpc` extras, you can unlock some performance improvements by working with an alternative version of the client imported from the `pinecone.grpc` subpackage. diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py index 2d1165601..ad25247cf 100644 --- a/pinecone/control/pinecone.py +++ b/pinecone/control/pinecone.py @@ -111,7 +111,7 @@ def __init__( from pinecone import Pinecone pc = Pinecone( - api_key="YOUR_API_KEY", + api_key='YOUR_API_KEY', proxy_url='https://your-proxy.com' ) @@ -125,7 +125,7 @@ def __init__( import urllib3 import make_headers pc = Pinecone( - api_key="YOUR_API_KEY", + api_key='YOUR_API_KEY', proxy_url='https://your-proxy.com', proxy_headers=make_headers(proxy_basic_auth='username:password') ) @@ -145,15 +145,37 @@ def __init__( import urllib3 import make_headers pc = Pinecone( - api_key="YOUR_API_KEY", + api_key='YOUR_API_KEY', proxy_url='https://your-proxy.com', - proxy_headers=make_headers(proxy_basic_auth='username:password') + proxy_headers=make_headers(proxy_basic_auth='username:password'), ssl_ca_certs='path/to/cert-bundle.pem' ) pc.list_indexes() ``` + ### Disabling SSL verification + + If you would like to disable SSL verification, you can pass the `ssl_verify` + parameter with a value of `False`. We do not recommend going to production with SSL verification disabled. + + ```python + from pinecone import Pinecone + import urllib3 import make_headers + + pc = Pinecone( + api_key='YOUR_API_KEY', + proxy_url='https://your-proxy.com', + proxy_headers=make_headers(proxy_basic_auth='username:password'), + ssl_ca_certs='path/to/cert-bundle.pem', + ssl_verify=False + ) + + pc.list_indexes() + + ``` + + """ if config: if not isinstance(config, Config): From 5450689d04b3a6d397da5d7bca3b66899a1d0f27 Mon Sep 17 00:00:00 2001 From: Jen Hamon Date: Thu, 21 Mar 2024 12:27:21 -0400 Subject: [PATCH 32/32] Add inline comments --- pinecone/config/config.py | 12 +++++------- pinecone/config/openapi.py | 28 +++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/pinecone/config/config.py b/pinecone/config/config.py index a506c6ea0..2cf50a410 100644 --- a/pinecone/config/config.py +++ b/pinecone/config/config.py @@ -1,6 +1,5 @@ from typing import NamedTuple, Optional, Dict import os -import copy from pinecone.exceptions import PineconeConfigurationError from pinecone.config.openapi import OpenApiConfigFactory @@ -60,15 +59,14 @@ def build_openapi_config( config: Config, openapi_config: Optional[OpenApiConfiguration] = None, **kwargs ) -> OpenApiConfiguration: if openapi_config: - openapi_config = copy.deepcopy(openapi_config) + openapi_config = OpenApiConfigFactory.copy(openapi_config=openapi_config, api_key=config.api_key, host=config.host) elif openapi_config is None: openapi_config = OpenApiConfigFactory.build(api_key=config.api_key, host=config.host) - openapi_config.host = config.host - openapi_config.api_key = {"ApiKeyAuth": config.api_key} - # Check if value passed before overriding any values present - # in the openapi_config + # in the openapi_config. This means if the user has passed + # an openapi_config object and a kwarg for the same setting, + # the kwarg will take precedence. if (config.proxy_url): openapi_config.proxy = config.proxy_url if (config.proxy_headers): @@ -77,5 +75,5 @@ def build_openapi_config( openapi_config.ssl_ca_cert = config.ssl_ca_certs if (config.ssl_verify != None): openapi_config.verify_ssl = config.ssl_verify - + return openapi_config \ No newline at end of file diff --git a/pinecone/config/openapi.py b/pinecone/config/openapi.py index 6c6c3c058..b6b6f6e67 100644 --- a/pinecone/config/openapi.py +++ b/pinecone/config/openapi.py @@ -3,6 +3,8 @@ import certifi import socket +import copy +import warnings from urllib3.connection import HTTPConnection @@ -17,11 +19,35 @@ class OpenApiConfigFactory: @classmethod def build(cls, api_key: str, host: Optional[str] = None, **kwargs): openapi_config = OpenApiConfiguration() + openapi_config.api_key = {"ApiKeyAuth": api_key} openapi_config.host = host openapi_config.ssl_ca_cert = certifi.where() openapi_config.socket_options = cls._get_socket_options() - openapi_config.api_key = {"ApiKeyAuth": api_key} return openapi_config + + @classmethod + def copy(cls, openapi_config: OpenApiConfiguration, api_key: str, host: str) -> OpenApiConfiguration: + ''' + Copy a user-supplied openapi configuration and update it with the user's api key and host. + If they have not specified other socket configuration, we will use the default values. + We expect these objects are being passed mainly a vehicle for proxy configuration, so + we don't modify those settings. + ''' + copied = copy.deepcopy(openapi_config) + warnings.warn("Passing openapi_config is deprecated and will be removed in a future release. Please pass settings such as proxy_url, proxy_headers, ssl_ca_certs, and ssl_verify directly to the Pinecone constructor as keyword arguments. See the README at https://github.com/pinecone-io/pinecone-python-client for examples.", DeprecationWarning) + + copied.api_key = {"ApiKeyAuth": api_key} + copied.host = host + + # Set sensible defaults if the user hasn't set them + if not copied.socket_options: + copied.socket_options = cls._get_socket_options() + + # We specifically do not modify the user's ssl_ca_cert or proxy settings, as + # they may have set them intentionally. This is the main reason somebody would + # pass an openapi_config in the first place. + + return copied @classmethod def _get_socket_options(