Skip to content

Commit

Permalink
Add corresponding test
Browse files Browse the repository at this point in the history
  • Loading branch information
Phoebus Mak authored and Phoebus Mak committed Sep 19, 2023
1 parent ed13084 commit 00a65b6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
21 changes: 19 additions & 2 deletions python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import numpy as np
import pandas as pd
import random
from datetime import datetime
from datetime import datetime, timezone, timedelta
from typing import Optional, Any, Dict
import subprocess
from pathlib import Path
Expand All @@ -52,7 +52,7 @@
from arcticdb.version_store._normalization import MsgPackNormalizer
from arcticdb.options import LibraryOptions
from arcticdb_ext.storage import Library
from azure.storage.blob import BlobServiceClient
from azure.storage.blob import BlobServiceClient, generate_account_sas, ResourceTypes, AccountSasPermissions

configure_test_logger()

Expand Down Expand Up @@ -100,6 +100,23 @@ def azure_client_and_create_container(azurite_container, azurite_azure_uri):
return client


@pytest.fixture(scope="function")
def azure_account_sas_token(azure_client_and_create_container, azurite_azure_test_connection_setting):
start_time = datetime.now(timezone.utc)
expiry_time = start_time + timedelta(days=1)
_, _, credential_name, credential_key, _ = azurite_azure_test_connection_setting

sas_token = generate_account_sas(
account_key=credential_key,
account_name=credential_name,
resource_types=ResourceTypes.from_string("sco"),
permission=AccountSasPermissions.from_string("rwdlacup"),
expiry=expiry_time,
start=start_time,
)
return sas_token


@pytest.fixture(scope="function")
def boto_client(_moto_s3_uri_module):
endpoint = _moto_s3_uri_module
Expand Down
19 changes: 17 additions & 2 deletions python/tests/integration/arcticdb/test_arctic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,12 +1040,27 @@ def test_get_uri(object_storage_uri_incl_bucket):


def test_azure_no_ca_path(azurite_azure_test_connection_setting):
(endpoint, container, credential_name, credential_key, ca_cert_path) = azurite_azure_test_connection_setting
ac = Arctic(
endpoint, container, credential_name, credential_key, _ = azurite_azure_test_connection_setting
Arctic(
f"azure://DefaultEndpointsProtocol=http;AccountName={credential_name};AccountKey={credential_key};BlobEndpoint={endpoint}/{credential_name};Container={container}"
)


def test_azure_sas_token(azure_account_sas_token, azurite_azure_test_connection_setting):
endpoint, container, credential_name, _, _ = azurite_azure_test_connection_setting
ac = Arctic(
f"azure://DefaultEndpointsProtocol=http;SharedAccessSignature={azure_account_sas_token};BlobEndpoint={endpoint}/{credential_name};Container={container}"
)
expected = pd.DataFrame({"col1": [1, 2, 3], "col2": [4, 5, 6]})
sym = "test"
lib = "lib"
ac.create_library(lib)
ac[lib].write(sym, expected)
assert_frame_equal(expected, ac[lib].read(sym).data)

assert ac.list_libraries() == [lib]


def test_s3_force_uri_lib_config_handling(moto_s3_uri_incl_bucket):
# force_uri_lib_config is a obsolete configuration. However, user still includes this option in their setup. For backward compatitbility, we need to make sure such setup will still work
# Why it becomes obsolete: https://github.com/man-group/ArcticDB/pull/803
Expand Down

0 comments on commit 00a65b6

Please sign in to comment.