Skip to content

Commit adf841f

Browse files
authored
Merge pull request #6 from sourceplusplus/dev
Dev
2 parents 32e5be6 + 44439bd commit adf841f

20 files changed

+152
-107
lines changed

.github/workflows/e2e.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,57 +36,57 @@ jobs:
3636
- name: Set SPP_PLATFORM_HOST
3737
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
3838
- name: Wait for platform
39-
run: until $(curl --insecure --output /dev/null --silent --fail https://localhost:5445/api/new-token?access_token=change-me); do printf '.'; sleep 5; done && SPP_JWT_TOKEN=$(curl --insecure https://localhost:5445/api/new-token?access_token=change-me) && echo "SPP_JWT_TOKEN=$SPP_JWT_TOKEN" >> $GITHUB_ENV
39+
run: until $(curl --insecure --output /dev/null --silent --fail https://localhost:12800/api/new-token?access_token=change-me); do printf '.'; sleep 5; done && SPP_JWT_TOKEN=$(curl --insecure https://localhost:12800/api/new-token?access_token=change-me) && echo "SPP_JWT_TOKEN=$SPP_JWT_TOKEN" >> $GITHUB_ENV
4040
- name: Wait for skywalking
4141
run: |
42-
until $(curl --header "Authorization: Bearer ${{ env.SPP_JWT_TOKEN }}" --insecure --output /dev/null --silent --fail https://localhost:5445/health); do printf '.'; sleep 5; done
42+
until $(curl --header "Authorization: Bearer ${{ env.SPP_JWT_TOKEN }}" --insecure --output /dev/null --silent --fail https://localhost:12800/health); do printf '.'; sleep 5; done
4343
- run: curl -sS https://webinstall.dev/jq | bash
4444

4545
- name: Verify probe connected
4646
run: |
47-
resp=$(curl --header "Authorization: Bearer ${{ env.SPP_JWT_TOKEN }}" --insecure https://localhost:5445/clients) && [[ $(echo $resp | jq -r ."probes"[0]."meta"."language") == "python" ]] && echo $resp || (echo $resp && exit 1)
47+
resp=$(curl --header "Authorization: Bearer ${{ env.SPP_JWT_TOKEN }}" --insecure https://localhost:12800/clients) && [[ $(echo $resp | jq -r ."probes"[0]."meta"."language") == "python" ]] && echo $resp || (echo $resp && exit 1)
4848
4949
- name: Download & install spp-cli
5050
run: |
51-
curl -O -J -L https://github.com/sourceplusplus/interface-cli/releases/download/0.2.2/spp-cli-0.2.2-linux64.zip && unzip spp-cli-0.2.2-linux64.zip && chmod +x spp-cli && mv spp-cli /usr/local/bin/spp-cli
51+
curl -O -J -L https://github.com/sourceplusplus/interface-cli/releases/download/0.5.4/spp-cli-0.5.4-linux64.zip && unzip spp-cli-0.5.4-linux64.zip && chmod +x spp-cli && mv spp-cli /usr/local/bin/spp-cli
5252
5353
- name: Live breakpoint (false condition)
5454
run: |
55-
spp-cli -a change-me add-breakpoint -c 1==2 E2ETest.py 19
56-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
55+
spp-cli -a change-me add breakpoint -c 1==2 E2ETest.py 19
56+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
5757
curl ${{ env.E2E_APP_HOST }}:5000 && sleep 35s
58-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
59-
spp-cli -a change-me clear-instruments
58+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
59+
spp-cli -a change-me remove all-instruments
6060
6161
- name: Live log (false condition)
6262
run: |
63-
spp-cli -a change-me add-log -c 1==2 -l provider E2ETest.py 19 Hello {}
64-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
63+
spp-cli -a change-me add log -c 1==2 -l provider E2ETest.py 19 Hello {}
64+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
6565
curl ${{ env.E2E_APP_HOST }}:5000 && sleep 35s
66-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
67-
spp-cli -a change-me clear-instruments
66+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
67+
spp-cli -a change-me remove all-instruments
6868
6969
- name: Live breakpoint (hit limit = 2)
7070
run: |
71-
spp-cli -a change-me add-breakpoint -hitLimit 2 E2ETest.py 19
72-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
73-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."hitLimit") == "2" ]] && echo $resp || (echo $resp && exit 1)
74-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
71+
spp-cli -a change-me add breakpoint -hitLimit 2 E2ETest.py 19
72+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
73+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."hitLimit") == "2" ]] && echo $resp || (echo $resp && exit 1)
74+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
7575
curl ${{ env.E2E_APP_HOST }}:5000 && sleep 35s
76-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "1" ]] && echo $resp || (echo $resp && exit 1)
76+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "1" ]] && echo $resp || (echo $resp && exit 1)
7777
curl ${{ env.E2E_APP_HOST }}:5000 && sleep 35s
78-
resp=$(spp-cli -a change-me get-instruments) && [[ $resp == "[]" ]] && echo $resp || (echo $resp && exit 1)
78+
resp=$(spp-cli -a change-me get instruments) && [[ $resp == "[ ]" ]] && echo $resp || (echo $resp && exit 1)
7979
8080
- name: Live log (hit limit = 2)
8181
run: |
82-
spp-cli -a change-me add-log -hitLimit 2 -l provider E2ETest.py 19 Hello {}
83-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
84-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."hitLimit") == "2" ]] && echo $resp || (echo $resp && exit 1)
85-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
82+
spp-cli -a change-me add log -hitLimit 2 -l provider E2ETest.py 19 Hello {}
83+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."applied") == "true" ]] && echo $resp || (echo $resp && exit 1)
84+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."hitLimit") == "2" ]] && echo $resp || (echo $resp && exit 1)
85+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "0" ]] && echo $resp || (echo $resp && exit 1)
8686
curl ${{ env.E2E_APP_HOST }}:5000 && sleep 35s
87-
resp=$(spp-cli -a change-me get-instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "1" ]] && echo $resp || (echo $resp && exit 1)
87+
resp=$(spp-cli -a change-me get instruments) && [[ $(echo $resp | jq -r .[0]."meta"."hit_count") == "1" ]] && echo $resp || (echo $resp && exit 1)
8888
curl ${{ env.E2E_APP_HOST }}:5000 && sleep 35s
89-
resp=$(spp-cli -a change-me get-instruments) && [[ $resp == "[]" ]] && echo $resp || (echo $resp && exit 1)
89+
resp=$(spp-cli -a change-me get instruments) && [[ $resp == "[ ]" ]] && echo $resp || (echo $resp && exit 1)
9090
9191
- run: ./gradlew composeLogs
9292
if: ${{ always() }}

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
paths-ignore:
1313
- '**.md'
1414
- '**.svg'
15+
workflow_dispatch:
1516

1617
jobs:
1718
build:

CHANGELOG.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

e2e/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ RUN pip install Flask
66
RUN pip install PyYAML
77
RUN pip install vertx-eventbus-client
88

9-
COPY sourceplusplus-0.1.5.tar.gz .
9+
COPY sourceplusplus-*.tar.gz ./sourceplusplus.tar.gz
1010

11-
RUN pip install sourceplusplus-0.1.5.tar.gz
11+
RUN pip install sourceplusplus.tar.gz
1212

1313
COPY E2ETest.py .
1414

e2e/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
ports:
2222
- "5450:5450"
2323
- "5455:5455"
24+
- "12800:12800"
2425
environment:
2526
- SPP_LOGGING_LEVEL=trace
2627
- SPP_OAP_HOST=skywalking-oap

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from setuptools import setup
33

44
setup(name='sourceplusplus',
5-
version='0.1.5',
5+
version='0.4.0',
66
description='Source++ Python Probe',
77
url='https://github.com/sourceplusplus/probe-python',
88
author='Source++',

sourceplusplus/SourcePlusPlus.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from sourceplusplus import __version__
1313
from .control.LiveInstrumentRemote import LiveInstrumentRemote
1414
from .models.command.LiveInstrumentCommand import LiveInstrumentCommand
15-
from .models.instrument.common.LiveInstrumentType import LiveInstrumentType
1615

1716

1817
class SourcePlusPlus(object):
@@ -137,28 +136,22 @@ def __send_connected(self, eb: EventBus):
137136
# send probe connected event
138137
reply_address = str(uuid.uuid4())
139138
eb.send(address="spp.platform.status.probe-connected", body={
140-
"probeId": self.probe_config["spp"]["probe_id"],
139+
"instanceId": self.probe_config["spp"]["probe_id"],
141140
"connectionTime": round(time.time() * 1000),
142141
"meta": probe_metadata
143142
}, reply_handler=lambda msg: self.__register_remotes(eb, reply_address, msg["body"]))
144143

145144
def __register_remotes(self, eb, reply_address, status):
146145
eb.unregister_handler(reply_address)
147146
eb.register_handler(
148-
address="spp.probe.command.live-breakpoint-remote:" + self.probe_config["spp"]["probe_id"],
147+
address="spp.probe.command.live-instrument-remote",
149148
handler=lambda msg: self.instrument_remote.handle_instrument_command(
150-
LiveInstrumentCommand.from_json(json.dumps(msg["body"])), LiveInstrumentType.BREAKPOINT
149+
LiveInstrumentCommand.from_json(json.dumps(msg["body"]))
151150
)
152151
)
153152
eb.register_handler(
154-
address="spp.probe.command.live-log-remote:" + self.probe_config["spp"]["probe_id"],
153+
address="spp.probe.command.live-instrument-remote:" + self.probe_config["spp"]["probe_id"],
155154
handler=lambda msg: self.instrument_remote.handle_instrument_command(
156-
LiveInstrumentCommand.from_json(json.dumps(msg["body"])), LiveInstrumentType.LOG
157-
)
158-
)
159-
eb.register_handler(
160-
address="spp.probe.command.live-meter-remote:" + self.probe_config["spp"]["probe_id"],
161-
handler=lambda msg: self.instrument_remote.handle_instrument_command(
162-
LiveInstrumentCommand.from_json(json.dumps(msg["body"])), LiveInstrumentType.METER
155+
LiveInstrumentCommand.from_json(json.dumps(msg["body"]))
163156
)
164157
)

sourceplusplus/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '0.1.5'
1+
__version__ = '0.4.0'
22
__name__ = 'Source++'
33
agent_name = 'Source++ Python Probe'

sourceplusplus/control/ContextReceiver.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def apply_log(live_log_id, globals, locals):
8484
)
8585
except Exception:
8686
pass
87-
LiveInstrumentRemote.eb.send(address="spp.platform.status.live-log-removed", body={
88-
"log": live_log.to_json(),
87+
LiveInstrumentRemote.eb.send(address="spp.processor.status.live-instrument-removed", body={
88+
"instrument": live_log.to_json(),
8989
"occurredAt": round(time.time() * 1000)
9090
})
9191

@@ -148,8 +148,8 @@ def apply_breakpoint(live_breakpoint_id, globals, locals):
148148
)
149149
except Exception:
150150
pass
151-
LiveInstrumentRemote.eb.send(address="spp.platform.status.live-breakpoint-removed", body={
152-
"breakpoint": live_breakpoint.to_json(),
151+
LiveInstrumentRemote.eb.send(address="spp.processor.status.live-instrument-removed", body={
152+
"instrument": live_breakpoint.to_json(),
153153
"occurredAt": round(time.time() * 1000)
154154
})
155155

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import json
21
import sys
32
import threading
3+
44
from nopdb import nopdb
55
from vertx import EventBus
66

77
from sourceplusplus.models.command.CommandType import CommandType
88
from sourceplusplus.models.command.LiveInstrumentCommand import LiveInstrumentCommand
9-
from sourceplusplus.models.command.LiveInstrumentContext import LiveInstrumentContext
109
from sourceplusplus.models.instrument.LiveBreakpoint import LiveBreakpoint
1110
from sourceplusplus.models.instrument.LiveLog import LiveLog
1211
from sourceplusplus.models.instrument.LiveMeter import LiveMeter
@@ -25,14 +24,15 @@ def __init__(self, eb: EventBus):
2524
LiveInstrumentRemote.dbg.start()
2625
threading.settrace(sys.gettrace())
2726

28-
def add_live_instrument(self, context: LiveInstrumentContext, instrument_type: LiveInstrumentType):
29-
for i in context.instruments:
27+
def add_live_instrument(self, command: LiveInstrumentCommand):
28+
for inst_dict in command.instruments:
29+
instrument_type: LiveInstrumentType = LiveInstrumentType.from_string(inst_dict["type"])
3030
if instrument_type == LiveInstrumentType.BREAKPOINT:
31-
live_instrument = LiveBreakpoint.from_json(i)
31+
live_instrument = LiveBreakpoint.from_dict(inst_dict)
3232
elif instrument_type == LiveInstrumentType.LOG:
33-
live_instrument = LiveLog.from_json(i)
33+
live_instrument = LiveLog.from_dict(inst_dict)
3434
else:
35-
live_instrument = LiveMeter.from_json(i)
35+
live_instrument = LiveMeter.from_dict(inst_dict)
3636
bp = LiveInstrumentRemote.dbg.breakpoint(
3737
file=live_instrument.location.source[live_instrument.location.source.rfind("/") + 1:],
3838
line=live_instrument.location.line
@@ -41,46 +41,41 @@ def add_live_instrument(self, context: LiveInstrumentContext, instrument_type: L
4141
if instrument_type == LiveInstrumentType.BREAKPOINT:
4242
bp.exec("import sourceplusplus.control.ContextReceiver as ContextReceiver\n"
4343
"ContextReceiver.apply_breakpoint('" + live_instrument.id + "',globals(),locals())")
44-
self.eb.publish(address="spp.platform.status.live-breakpoint-applied", body=json.loads(i))
44+
self.eb.publish(address="spp.processor.status.live-instrument-applied", body=live_instrument.to_dict())
4545
elif instrument_type == LiveInstrumentType.LOG:
4646
bp.exec("import sourceplusplus.control.ContextReceiver as ContextReceiver\n"
4747
"ContextReceiver.apply_log('" + live_instrument.id + "',globals(),locals())")
48-
self.eb.publish(address="spp.platform.status.live-log-applied", body=json.loads(i))
48+
self.eb.publish(address="spp.processor.status.live-instrument-applied", body=live_instrument.to_dict())
4949
else:
5050
bp.exec("import sourceplusplus.control.ContextReceiver as ContextReceiver\n"
5151
"ContextReceiver.apply_meter('" + live_instrument.id + "',globals(),locals())")
52-
self.eb.publish(address="spp.platform.status.live-meter-applied", body=json.loads(i))
52+
self.eb.publish(address="spp.processor.status.live-instrument-applied", body=live_instrument.to_dict())
5353

54-
def remove_live_instrument(self, context: LiveInstrumentContext, type: LiveInstrumentType):
54+
def remove_live_instrument(self, command: LiveInstrumentCommand):
5555
print("Removing live instrument(s)")
56-
for i in context.instruments:
56+
for inst_dict in command.instruments:
5757
if type == LiveInstrumentType.BREAKPOINT:
58-
instrument = LiveBreakpoint.from_json(i)
58+
instrument = LiveBreakpoint.from_dict(inst_dict)
5959
elif type == LiveInstrumentType.LOG:
60-
instrument = LiveLog.from_json(i)
60+
instrument = LiveLog.from_dict(inst_dict)
6161
else:
62-
instrument = LiveMeter.from_json(i)
62+
instrument = LiveMeter.from_dict(inst_dict)
6363
try:
6464
LiveInstrumentRemote.dbg.remove_callback(LiveInstrumentRemote.instruments.pop(instrument.id)[0]._handle)
6565
except KeyError:
6666
pass
67-
for i in context.locations:
68-
loc = LiveSourceLocation.from_json(i)
67+
for inst_dict in command.locations:
68+
loc = LiveSourceLocation.from_json(inst_dict)
6969
delete = []
7070
for key, val in LiveInstrumentRemote.instruments.items():
7171
if val[1].type == type and val[1].location == loc:
7272
delete.append(key)
73-
for i in delete:
74-
del LiveInstrumentRemote.instruments[i]
73+
for inst_dict in delete:
74+
del LiveInstrumentRemote.instruments[inst_dict]
7575

76-
def handle_instrument_command(self, command: LiveInstrumentCommand, instrument_type: LiveInstrumentType):
76+
def handle_instrument_command(self, command: LiveInstrumentCommand):
7777
print("Received command: " + command.command_type)
7878
if command.command_type == CommandType.ADD_LIVE_INSTRUMENT:
79-
if instrument_type == LiveInstrumentType.BREAKPOINT:
80-
self.add_live_instrument(command.context, LiveInstrumentType.BREAKPOINT)
81-
elif instrument_type == LiveInstrumentType.LOG:
82-
self.add_live_instrument(command.context, LiveInstrumentType.LOG)
83-
else:
84-
self.add_live_instrument(command.context, LiveInstrumentType.METER)
79+
self.add_live_instrument(command)
8580
elif command.command_type == CommandType.REMOVE_LIVE_INSTRUMENT:
86-
self.remove_live_instrument(command.context, instrument_type)
81+
self.remove_live_instrument(command)

0 commit comments

Comments
 (0)