Skip to content

Commit

Permalink
updating docker compose by remove kibana and adding grafana; misc tes…
Browse files Browse the repository at this point in the history
…ts fixes
  • Loading branch information
travishathaway committed Jan 20, 2025
1 parent 7e0fa45 commit 066570a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 48 deletions.
2 changes: 1 addition & 1 deletion conda_anaconda_telemetry/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ def conda_post_commands() -> Iterator[CondaPostCommand]:
yield CondaPostCommand(
name="post-command-submit-telemetry-data",
action=submit_telemetry_data,
run_for=["install", "remove", "update", "create"],
run_for=["install", "remove", "update", "create", "list", "search"],
)
56 changes: 15 additions & 41 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
services:
grafana:
# Default username and password for Grafana are admin/admin
image: grafana/grafana-enterprise
container_name: grafana
restart: unless-stopped
ports:
- 3000:3000
volumes:
- grafana-data:/var/lib/grafana

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${ES_LOCAL_VERSION}
container_name: ${ES_LOCAL_CONTAINER_NAME}
volumes:
- dev-elasticsearch:/usr/share/elasticsearch/data
- elasticsearch-data:/usr/share/elasticsearch/data
ports:
- 127.0.0.1:${ES_LOCAL_PORT}:9200
environment:
- discovery.type=single-node
- ELASTIC_PASSWORD=${ES_LOCAL_PASSWORD}
- xpack.security.enabled=true
- xpack.security.enabled=false
- xpack.security.http.ssl.enabled=false
- xpack.license.self_generated.type=trial
- xpack.license.self_generated.type=basic
- xpack.ml.use_auto_machine_memory_percent=true
- ES_JAVA_OPTS=-Xms${ES_LOCAL_HEAP_INIT} -Xmx${ES_LOCAL_HEAP_MAX}
ulimits:
Expand All @@ -24,42 +34,6 @@ services:
timeout: 5s
retries: 10

kibana_settings:
depends_on:
elasticsearch:
condition: service_healthy
image: docker.elastic.co/elasticsearch/elasticsearch:${ES_LOCAL_VERSION}
container_name: ${KIBANA_SETTINGS_LOCAL_CONTAINER_NAME}
restart: no
command: >
bash -c '
echo "Setup the kibana_system password";
until curl -s -u "elastic:${ES_LOCAL_PASSWORD}" -X POST http://elasticsearch:${ES_LOCAL_PORT}/_security/user/kibana_system/_password -d "{\"password\":\"'${KIBANA_LOCAL_PASSWORD}'\"}" -H "Content-Type: application/json" | grep -q "^{}"; do sleep 5; done;
'
kibana:
depends_on:
kibana_settings:
condition: service_completed_successfully
image: docker.elastic.co/kibana/kibana:${ES_LOCAL_VERSION}
container_name: ${KIBANA_LOCAL_CONTAINER_NAME}
volumes:
- dev-kibana:/usr/share/kibana/data
ports:
- 127.0.0.1:${KIBANA_LOCAL_PORT}:5601
environment:
- SERVER_NAME=kibana
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${KIBANA_LOCAL_PASSWORD}
- XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY=${KIBANA_ENCRYPTION_KEY}
- ELASTICSEARCH_PUBLICBASEURL=http://localhost:${ES_LOCAL_PORT}
healthcheck:
test: [CMD-SHELL, curl -s -I http://kibana:5601 | grep -q 'HTTP/1.1 302 Found']
interval: 10s
timeout: 10s
retries: 20

otel_collector:
image: otel/opentelemetry-collector-contrib:latest@sha256:631637f7b33668eda594011d5f173100a3fe245da7fa8dae0885b368da4d0a6e
container_name: ${OTEL_LOCAL_CONTAINER_NAME}
Expand All @@ -73,5 +47,5 @@ services:
command: --config /etc/otel/config.yaml

volumes:
dev-elasticsearch:
dev-kibana:
elasticsearch-data:
grafana-data:
12 changes: 6 additions & 6 deletions tests/backends/test_request_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def packages(mocker: MockerFixture) -> list:
return TEST_PACKAGES


def testget_conda_request_header_default_headers(mocker: MockerFixture) -> None:
def test_get_conda_request_header_default_headers(mocker: MockerFixture) -> None:
"""
Ensure default headers are returned
"""
Expand All @@ -77,7 +77,7 @@ def testget_conda_request_header_default_headers(mocker: MockerFixture) -> None:
)


def testget_conda_request_header_with_search(
def test_get_conda_request_header_with_search(
monkeypatch: MonkeyPatch, mocker: MockerFixture
) -> None:
"""
Expand All @@ -103,7 +103,7 @@ def testget_conda_request_header_with_search(
)


def testget_conda_request_header_with_install(
def test_get_conda_request_header_with_install(
monkeypatch: MonkeyPatch, mocker: MockerFixture
) -> None:
"""
Expand All @@ -129,7 +129,7 @@ def testget_conda_request_header_with_install(
)


def testget_conda_request_header_when_disabled(mocker: MockerFixture) -> None:
def test_get_conda_request_header_when_disabled(mocker: MockerFixture) -> None:
"""
Make sure that nothing is returned when the plugin is disabled via settings
"""
Expand Down Expand Up @@ -190,8 +190,8 @@ def test_conda_session_headers_with_exception(

def test_conda_session_headers_with_non_matching_url() -> None:
"""
When any exception is encountered, ``conda_session_headers`` should return nothing
and log a debug message.
When the host is not in the list of hosts that require telemetry data nothing should
be returned.
"""
assert list(conda_session_headers("https://example.com")) == []

Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# Copyright (C) 2024 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
import pytest
from conda.base.context import context


@pytest.fixture(autouse=True, scope="session")
def reset_context() -> None:
"""
We reset the context to ignore local configuration
"""

context.__init__(search_path=())

0 comments on commit 066570a

Please sign in to comment.