Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TFS
controller
Commits
58fd9bb7
Commit
58fd9bb7
authored
2 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
DLT component:
- added simple test script
parent
88be1334
No related branches found
No related tags found
2 merge requests
!54
Release 2.0.0
,
!16
DLT component (and related) improvements
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dlt/connector/main_test.py
+35
-7
35 additions, 7 deletions
src/dlt/connector/main_test.py
with
35 additions
and
7 deletions
src/dlt/connector/main_test.py
+
35
−
7
View file @
58fd9bb7
import
sys
# pip install grpcio==1.47.0 grpcio-tools==1.47.0 protobuf==3.20.1
# PYTHONPATH=/home/cttc/teraflow/src python -m dlt.connector.main_test
import
logging
,
sys
,
time
from
common.proto.dlt_gateway_pb2
import
DLTRECORDOPERATION_ADD
,
DLTRECORDTYPE_DEVICE
,
DltRecord
from
common.tools.object_factory.Device
import
json_device
from
common.tools.grpc.Tools
import
grpc_message_to_json_string
from
src.common.proto.context_pb2
import
DEVICEOPERATIONALSTATUS_ENABLED
,
Device
from
.client.DltGatewayClient
import
DltGatewayClient
from
.client.DltEventsCollector
import
DltEventsCollector
logging
.
basicConfig
(
level
=
logging
.
INFO
)
LOGGER
=
logging
.
getLogger
(
__name__
)
def
main
():
dltgateway_client_1
=
DltGatewayClient
(
host
=
''
,
port
=
0
)
dltgateway_client_2
=
DltGatewayClient
(
host
=
''
,
port
=
0
)
dltgateway_client_3
=
DltGatewayClient
(
host
=
''
,
port
=
0
)
dltgateway_client
=
DltGatewayClient
(
host
=
'
127.0.0.1
'
,
port
=
50051
)
dltgateway_collector
=
DltEventsCollector
(
dltgateway_client
,
log_events_received
=
True
)
dltgateway_collector
.
start
()
time
.
sleep
(
3
)
device
=
Device
(
**
json_device
(
'
dev-1
'
,
'
packet-router
'
,
DEVICEOPERATIONALSTATUS_ENABLED
))
r2dlt_req
=
DltRecord
()
r2dlt_req
.
record_id
.
domain_uuid
.
uuid
=
'
tfs-a
'
r2dlt_req
.
record_id
.
type
=
DLTRECORDTYPE_DEVICE
r2dlt_req
.
record_id
.
record_uuid
.
uuid
=
device
.
device_id
.
device_uuid
.
uuid
r2dlt_req
.
operation
=
DLTRECORDOPERATION_ADD
r2dlt_req
.
data_json
=
grpc_message_to_json_string
(
device
)
LOGGER
.
info
(
'
r2dlt_req = {:s}
'
.
format
(
grpc_message_to_json_string
(
r2dlt_req
)))
r2dlt_rep
=
dltgateway_client
.
RecordToDlt
(
r2dlt_req
)
LOGGER
.
info
(
'
r2dlt_rep = {:s}
'
.
format
(
grpc_message_to_json_string
(
r2dlt_rep
)))
dlt2r_req
=
r2dlt_req
.
record_id
LOGGER
.
info
(
'
dlt2r_req = {:s}
'
.
format
(
grpc_message_to_json_string
(
dlt2r_req
)))
dlt2r_rep
=
dltgateway_client
.
RecordToDlt
(
dlt2r_req
)
LOGGER
.
info
(
'
dlt2r_rep = {:s}
'
.
format
(
grpc_message_to_json_string
(
dlt2r_rep
)))
dltgateway_collector_1
=
DltEventsCollector
(
dltgateway_client_1
,
log_events_received
=
True
)
dltgateway_collector_2
=
DltEventsCollector
(
dltgateway_client_2
,
log_events_received
=
True
)
dltgateway_collector_3
=
DltEventsCollector
(
dltgateway_client_3
,
log_events_received
=
True
)
dltgateway_collector
.
stop
()
return
0
if
__name__
==
'
__main__
'
:
sys
.
exit
(
main
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment