Skip to content

Commit

Permalink
Fix telemetry tests
Browse files Browse the repository at this point in the history
Signed-off-by: Willem Pienaar <git@willem.co>
  • Loading branch information
woop committed Apr 13, 2021
1 parent e759ee3 commit 4bbbeb6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 28 deletions.
2 changes: 2 additions & 0 deletions sdk/python/feast/infra/local.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sqlite3
from datetime import datetime
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union

import pandas as pd
Expand Down Expand Up @@ -35,6 +36,7 @@ def __init__(self, config: RepoConfig):
self._db_path = local_online_store_config.path

def _get_conn(self):
Path(self._db_path).parent.mkdir(exist_ok=True)
return sqlite3.connect(
self._db_path, detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES
)
Expand Down
Empty file.
78 changes: 50 additions & 28 deletions sdk/python/telemetry_tests/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import tempfile
import uuid
from datetime import datetime

Expand All @@ -21,7 +22,8 @@
from time import sleep
from importlib import reload

from feast import Client, Entity, ValueType, FeatureStore
from feast import Client, Entity, ValueType, FeatureStore, RepoConfig
from feast.repo_config import SqliteOnlineStoreConfig

TELEMETRY_BIGQUERY_TABLE = (
"kf-feast.feast_telemetry.cloudfunctions_googleapis_com_cloud_functions"
Expand Down Expand Up @@ -91,19 +93,29 @@ def test_telemetry_on():
os.environ["FEAST_IS_TELEMETRY_TEST"] = "True"
os.environ["FEAST_TELEMETRY"] = "True"

test_feature_store = FeatureStore()
entity = Entity(
name="driver_car_id",
description="Car driver id",
value_type=ValueType.STRING,
labels={"team": "matchmaking"},
)

test_feature_store.apply([entity])

os.environ.clear()
os.environ.update(old_environ)
ensure_bigquery_telemetry_id_with_retry(test_telemetry_id)
with tempfile.TemporaryDirectory() as temp_dir:
test_feature_store = FeatureStore(
config=RepoConfig(
registry=os.path.join(temp_dir, "registry.db"),
project="fake_project",
provider="local",
online_store=SqliteOnlineStoreConfig(
path=os.path.join(temp_dir, "online.db")
),
)
)
entity = Entity(
name="driver_car_id",
description="Car driver id",
value_type=ValueType.STRING,
labels={"team": "matchmaking"},
)

test_feature_store.apply([entity])

os.environ.clear()
os.environ.update(old_environ)
ensure_bigquery_telemetry_id_with_retry(test_telemetry_id)


def test_telemetry_off():
Expand All @@ -113,20 +125,30 @@ def test_telemetry_off():
os.environ["FEAST_TELEMETRY"] = "False"
os.environ["FEAST_FORCE_TELEMETRY_UUID"] = test_telemetry_id

test_feature_store = FeatureStore()
entity = Entity(
name="driver_car_id",
description="Car driver id",
value_type=ValueType.STRING,
labels={"team": "matchmaking"},
)
test_feature_store.apply([entity])

os.environ.clear()
os.environ.update(old_environ)
sleep(30)
rows = read_bigquery_telemetry_id(test_telemetry_id)
assert rows.total_rows == 0
with tempfile.TemporaryDirectory() as temp_dir:
test_feature_store = FeatureStore(
config=RepoConfig(
registry=os.path.join(temp_dir, "registry.db"),
project="fake_project",
provider="local",
online_store=SqliteOnlineStoreConfig(
path=os.path.join(temp_dir, "online.db")
),
)
)
entity = Entity(
name="driver_car_id",
description="Car driver id",
value_type=ValueType.STRING,
labels={"team": "matchmaking"},
)
test_feature_store.apply([entity])

os.environ.clear()
os.environ.update(old_environ)
sleep(30)
rows = read_bigquery_telemetry_id(test_telemetry_id)
assert rows.total_rows == 0


@retry(wait=wait_exponential(multiplier=1, min=1, max=10), stop=stop_after_attempt(5))
Expand Down

0 comments on commit 4bbbeb6

Please sign in to comment.