Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable container log for unready integration tests #394

Merged
merged 6 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tests/connectors/kube_metrics_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import pathlib
import urllib3.exceptions

import freezegun
import kubetest.client
Expand Down Expand Up @@ -50,7 +51,11 @@ async def test_describe(kube_metrics_connector: KubeMetricsConnector):
@pytest.mark.minikube_profile.with_args("metrics-server")
@pytest.mark.applymanifests("../manifests", files=["fiber-http-opsani-dev.yaml"])
async def test_periodic_measure(kubeconfig: str, minikube: str, kube: kubetest.client.TestClient, servo_runner: ServoRunner):
kube.wait_for_registered()
try:
kube.wait_for_registered()
except urllib3.exceptions.MaxRetryError as e:
pytest.xfail(f"Connection refused: {e}")

datapoints_dicts: Dict[str, Dict[str, List[DataPoint]]] = defaultdict(lambda: defaultdict(list))
connector = KubeMetricsConnector(config=KubeMetricsConfiguration(
name="fiber-http",
Expand All @@ -74,13 +79,13 @@ async def wait_for_scrape():
**METRICS_CUSTOM_OJBECT_CONST_ARGS
)
if result.get('items'): # items present and non-empty
break
if any(any(c['name'] == "fiber-http" for c in i["containers"]) for i in result['items'] ):
break
except kubernetes_asyncio.client.exceptions.ApiException as e:
if e.status == 503:
continue # Takes a bit to start in GH runners???
raise
await asyncio.wait_for(wait_for_scrape(), timeout=60)
await asyncio.sleep(1) # sometimes only one container has been scraped, add a bit of buffer to prevent this

await connector.periodic_measure(
target_resource=deployment,
Expand Down
5 changes: 5 additions & 0 deletions tests/connectors/kubernetes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,11 @@ class TestKubernetesConnectorIntegrationUnreadyCmd:
def namespace(self, kube: kubetest.client.TestClient) -> str:
return kube.namespace

@pytest.fixture
def config(self, config: KubernetesConfiguration) -> KubernetesConfiguration:
config.container_logs_in_error_status = True
return config

@pytest.fixture
def kubetest_deployment(self, kube: kubetest.client.TestClient, rootpath: pathlib.Path) -> KubetestDeployment:
deployment = kube.load_deployment(rootpath.joinpath("tests/manifests/fiber-http-opsani-dev.yaml"))
Expand Down