From 49b3cc889f06005b6ac66e399a614ed3c4aaa9a1 Mon Sep 17 00:00:00 2001 From: Vladimir Gurevich Date: Tue, 16 Feb 2016 13:19:45 -0800 Subject: [PATCH] Added test-specific parameters: sai_thrift_ip="ip-address or host name" sai_thrift_port=thrift-port-number They can be passed when calling ptf, like so --test-params="sai_thrift_ip=\"10.10.2.1\";sai_thrift_port=9092" --- tests/ptf-tests/sai-tests/sai_base_test.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/ptf-tests/sai-tests/sai_base_test.py b/tests/ptf-tests/sai-tests/sai_base_test.py index 1facd30..17ae934 100644 --- a/tests/ptf-tests/sai-tests/sai_base_test.py +++ b/tests/ptf-tests/sai-tests/sai_base_test.py @@ -13,6 +13,7 @@ from ptf.base_tests import BaseTest from ptf import config import ptf.dataplane as dataplane +import ptf.testutils as testutils ################################################################ # @@ -31,7 +32,22 @@ def setUp(self): BaseTest.setUp(self) # Set up thrift client and contact server - self.transport = TSocket.TSocket('localhost', 9092) + test_params = testutils.test_params_get() + print "Test Params: ", test_params + + try: + sai_thrift_ip = test_params['sai_thrift_ip'] + except KeyError: + sai_thrift_ip = 'localhost' + + try: + sai_thrift_port = test_params['sai_thrift_port'] + except KeyError: + sai_thrift_port = 9092 + + print "Connecting to %s:%d" % (sai_thrift_ip, sai_thrift_port) + + self.transport = TSocket.TSocket(sai_thrift_ip, sai_thrift_port) self.transport = TTransport.TBufferedTransport(self.transport) self.protocol = TBinaryProtocol.TBinaryProtocol(self.transport)