Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
- run: |
PROBE_VERSION="$(python setup.py --version)"
echo "SPP_PROBE_VERSION=$PROBE_VERSION" >> $GITHUB_ENV
- run: python setup.py sdist
- run: cp dist/sourceplusplus-${{ env.SPP_PROBE_VERSION }}.tar.gz e2e
- run: cd e2e && docker-compose up -d

- run: ./gradlew assembleUp

- name: Docker IPs
run: docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
- name: Set E2E_APP_HOST
run: E2E_APP_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aqf "name=e2e_e2e-test_1")) && echo "E2E_APP_HOST=$E2E_APP_HOST" >> $GITHUB_ENV
run: E2E_APP_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aqf "name=e2e-test")) && echo "E2E_APP_HOST=$E2E_APP_HOST" >> $GITHUB_ENV
- name: Set SPP_PLATFORM_HOST
run: SPP_PLATFORM_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aqf "name=spp-platform")) && echo "SPP_PLATFORM_HOST=$SPP_PLATFORM_HOST" >> $GITHUB_ENV
- name: Wait for platform
Expand Down
24 changes: 24 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
plugins {
id("ru.vyarus.use-python") version "2.3.0"
id("com.avast.gradle.docker-compose")
}

python {
pip("apache-skywalking:0.7.0")
pip("vertx-eventbus-client:1.0.0")
}

tasks {
register<Exec>("buildDist") {
commandLine("sh", "-c", "python setup.py sdist")
}

register<Copy>("updateDockerFiles") {
dependsOn("buildDist")
from("dist/")
into("e2e/")
}

register("assembleUp") {
dependsOn("updateDockerFiles", "composeUp")
}
getByName("composeUp").mustRunAfter("updateDockerFiles")
}

dockerCompose {
dockerComposeWorkingDirectory.set(File("./e2e"))
removeVolumes.set(true)
waitForTcpPorts.set(false)
}
4 changes: 2 additions & 2 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ RUN pip install Flask
RUN pip install PyYAML
RUN pip install vertx-eventbus-client

COPY sourceplusplus-0.1.2.tar.gz .
COPY sourceplusplus-0.1.3.tar.gz .

RUN pip install sourceplusplus-0.1.2.tar.gz
RUN pip install sourceplusplus-0.1.3.tar.gz

COPY E2ETest.py .

Expand Down
1 change: 1 addition & 0 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: '3.3'
services:
e2e-test:
container_name: e2e-test
build:
context: .
depends_on:
Expand Down
5 changes: 5 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pluginManagement {
plugins {
id 'com.avast.gradle.docker-compose' version "0.14.9" apply false
}
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup

setup(name='sourceplusplus',
version='0.1.2',
version='0.1.3',
description='Source++ Python Probe',
url='https://github.com/sourceplusplus/probe-python',
author='Source++',
Expand Down
43 changes: 33 additions & 10 deletions sourceplusplus/SourcePlusPlus.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,25 @@ def get_config_value(self, env, default, true_default):
else:
return true_default

def __init__(self, **kwargs):
def __init__(self, args: dict = None):
if args is None:
args = {}
probe_config_file = os.getenv("SPP_PROBE_CONFIG_FILE", "spp-probe.yml")
probe_config = {}
if os.path.exists(probe_config_file):
probe_config = yaml.full_load(open(probe_config_file, "r"))
else:

# ensure probe_config has required keys
if probe_config.get("spp") is None:
probe_config["spp"] = {}
if probe_config.get("skywalking") is None:
probe_config["skywalking"] = {}
if probe_config["skywalking"].get("collector") is None:
probe_config["skywalking"]["collector"] = {}
if probe_config["skywalking"].get("agent") is None:
probe_config["skywalking"]["agent"] = {}

# set default values
probe_config["spp"]["probe_id"] = self.get_config_value(
"SPP_PROBE_ID", probe_config["spp"].get("probe_id"), str(uuid.uuid4())
)
Expand All @@ -46,12 +54,12 @@ def __init__(self, **kwargs):
probe_config["spp"]["platform_port"] = self.get_config_value(
"SPP_PLATFORM_PORT", probe_config["spp"].get("platform_port"), 5450
)
probe_config["spp"]["verify_host"] = self.get_config_value(
probe_config["spp"]["verify_host"] = str(self.get_config_value(
"SPP_TLS_VERIFY_HOST", probe_config["spp"].get("verify_host"), True
)
probe_config["spp"]["disable_tls"] = self.get_config_value(
)).lower() == "true"
probe_config["spp"]["disable_tls"] = str(self.get_config_value(
"SPP_DISABLE_TLS", probe_config["spp"].get("disable_tls"), False
)
)).lower() == "true"
probe_config["skywalking"]["agent"]["service_name"] = self.get_config_value(
"SPP_SERVICE_NAME", probe_config["skywalking"]["agent"].get("service_name"), "spp"
)
Expand All @@ -63,11 +71,20 @@ def __init__(self, **kwargs):
probe_config["skywalking"]["collector"].get("backend_service"),
skywalking_host + ":" + str(skywalking_port)
)
self.probe_config = probe_config

for key, val in args.items():
tmp_config = probe_config
loc = key.split(".")
for i in range(len(loc)):
if tmp_config.get(loc[i]) is None:
tmp_config[loc[i]] = {}
if i == len(loc) - 1:
tmp_config[loc[i]] = val
else:
tmp_config = tmp_config[loc[i]]

self.probe_config = probe_config
self.instrument_remote = None
for key, val in kwargs.items():
self.__dict__[key] = val

def attach(self):
config.init(
Expand All @@ -88,7 +105,13 @@ def attach(self):

ssl_ctx = ssl.create_default_context(cadata=ca_data)
ssl_ctx.check_hostname = self.probe_config["spp"]["verify_host"]
ssl_ctx.verify_mode = ssl.CERT_NONE # todo: CERT_REQUIRED / load_verify_locations ?
if self.probe_config["spp"]["disable_tls"] is True:
ssl_ctx = None
elif ssl_ctx.check_hostname is True:
ssl_ctx.verify_mode = ssl.CERT_REQUIRED
else:
ssl_ctx.verify_mode = ssl.CERT_NONE

eb = EventBus(
host=self.probe_config["spp"]["platform_host"], port=self.probe_config["spp"]["platform_port"],
ssl_context=ssl_ctx
Expand Down
6 changes: 1 addition & 5 deletions sourceplusplus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
__version__ = '0.1.2'
__version__ = '0.1.3'
__name__ = 'Source++'
agent_name = 'Source++ Python Probe'

__version_major__ = '0'
__version_minor__ = '1'
__version_micro__ = '2'