GNUnet  0.11.x
Public Member Functions | Data Fields
gnunet_testing.Peer Class Reference
Inheritance diagram for gnunet_testing.Peer:
[legend]
Collaboration diagram for gnunet_testing.Peer:
[legend]

Public Member Functions

def __init__ (self, test, cfg_file)
 
def __del__ (self)
 
def start (self)
 
def stop (self)
 
def get_statistics_value (self, subsystem, name)
 

Data Fields

 id
 
 test
 
 started
 
 cfg
 

Detailed Description

Definition at line 278 of file gnunet_testing.py.

Constructor & Destructor Documentation

◆ __init__()

def gnunet_testing.Peer.__init__ (   self,
  test,
  cfg_file 
)

Definition at line 279 of file gnunet_testing.py.

279  def __init__(self, test, cfg_file):
280  if (False == os.path.isfile(cfg_file)):
281  # print(("Peer cfg " + cfg_file + ": FILE NOT FOUND"))
282  logger.debug('Peer cfg %s : FILE NOT FOUND', cfg_file)
283  self.id = "<NaN>"
284  self.test = test
285  self.started = False
286  self.cfg = cfg_file
287 
def __init__(self, test, cfg_file)

◆ __del__()

def gnunet_testing.Peer.__del__ (   self)

Definition at line 288 of file gnunet_testing.py.

References GNUNET_CORE_MonitorHandle.cfg, GNUNET_GNS_Handle.cfg, Speaker.cfg, Microphone.cfg, GNUNET_CONSENSUS_Handle.cfg, GNUNET_DATACACHE_Handle.cfg, GNUNET_ARM_MonitorHandle.cfg, GNUNET_CADET_ChannelMonitor.cfg, GNUNET_CADET_PeersLister.cfg, GNUNET_CADET_GetPath.cfg, GNUNET_CADET_ListTunnels.cfg, GNUNET_CADET_Handle.cfg, GNUNET_ATS_ConnectivityHandle.cfg, GNUNET_DNS_Handle.cfg, GNUNET_BLOCK_Context.cfg, GNUNET_DATACACHE_PluginEnvironment.cfg, GNUNET_DATASTORE_PluginEnvironment.cfg, PeerCmdState.cfg, Plugin.cfg, GNUNET_CORE_Handle.cfg, GNUNET_CONVERSATION_Call.cfg, GNUNET_TESTING_SharedService.cfg, GNUNET_IDENTITY_Handle.cfg, GNUNET_ABD_Handle.cfg, GNUNET_ATS_SchedulingHandle.cfg, GNUNET_ARM_Handle.cfg, ControllerState.cfg, GNUNET_ATS_PerformanceHandle.cfg, GNUNET_CONVERSATION_Phone.cfg, GNUNET_DATASTORE_Handle.cfg, GNUNET_DHT_Handle.cfg, GNUNET_TRANSPORT_PluginEnvironment.cfg, Experiment.cfg, gnunet_testing.Peer.cfg, GNUNET_ATS_PluginEnvironment.cfg, GNUNET_TESTBED_PeerInformation.cfg, GNUNET_FS_Handle.cfg, gnunet_testing.Peer.started, RecursionContext.stop, gnunet_testing.Peer.stop(), and GNUNET_FS_QueueEntry.stop.

288  def __del__(self):
289  if (self.started == True):
290  # print('ERROR! Peer using cfg ' + self.cfg + ' was not stopped')
291  logger.debug('ERROR! Peer using cfg %s was not stopped', self.cfg)
292  ret = self.stop()
293  if (False == ret):
294  # print('ERROR! Peer using cfg ' +
295  # self.cfg +
296  # ' could not be stopped')
297  logger.debug(
298  'ERROR! Peer using cfg %s could not be stopped', self.cfg
299  )
300  self.started = False
301  return ret
302  else:
303  return False
304 
Here is the call graph for this function:

Member Function Documentation

◆ start()

def gnunet_testing.Peer.start (   self)

Definition at line 305 of file gnunet_testing.py.

References GNUNET_CORE_MonitorHandle.cfg, GNUNET_GNS_Handle.cfg, Speaker.cfg, Microphone.cfg, GNUNET_CONSENSUS_Handle.cfg, GNUNET_ARM_MonitorHandle.cfg, GNUNET_DATACACHE_Handle.cfg, GNUNET_CADET_ChannelMonitor.cfg, GNUNET_CADET_ListTunnels.cfg, GNUNET_CADET_GetPath.cfg, GNUNET_CADET_PeersLister.cfg, GNUNET_CADET_Handle.cfg, GNUNET_ATS_ConnectivityHandle.cfg, GNUNET_DNS_Handle.cfg, GNUNET_BLOCK_Context.cfg, GNUNET_DATACACHE_PluginEnvironment.cfg, GNUNET_DATASTORE_PluginEnvironment.cfg, PeerCmdState.cfg, Plugin.cfg, GNUNET_CORE_Handle.cfg, GNUNET_CONVERSATION_Call.cfg, GNUNET_TESTING_SharedService.cfg, GNUNET_IDENTITY_Handle.cfg, GNUNET_ABD_Handle.cfg, GNUNET_ATS_SchedulingHandle.cfg, GNUNET_ARM_Handle.cfg, ControllerState.cfg, GNUNET_ATS_PerformanceHandle.cfg, GNUNET_CONVERSATION_Phone.cfg, GNUNET_DATASTORE_Handle.cfg, GNUNET_DHT_Handle.cfg, GNUNET_TRANSPORT_PluginEnvironment.cfg, Experiment.cfg, gnunet_testing.Peer.cfg, GNUNET_ATS_PluginEnvironment.cfg, GNUNET_TESTBED_PeerInformation.cfg, GNUNET_FS_Handle.cfg, NamespaceUpdateNode.id, LookupMessage.id, WorkItem.id, GNUNET_CADET_GetPath.id, CollectMessage.id, GNUNET_CADET_Port.id, Request.id, GNUNET_ARM_Operation.id, GNUNET_RECLAIM_Attribute.id, GNUNET_RECLAIM_Identifier.id, LookupResultMessage.id, CadetPeer.id, CadetClient.id, VerifyMessage.id, LoggingPeer.id, BenchmarkPeer.id, DelegationChainResultMessage.id, GNUNET_ATS_AddressListHandle.id, GNUNET_RECLAIM_Credential.id, TestPeer.id, DelegationChainIntermediateMessage.id, GNUNET_ATS_PerformanceHandle.id, Episode.id, GNUNET_MESSENGER_MessageId.id, GNUNET_IDENTITY_Ego.id, gnunet_testing.Peer.id, PeerInfo.id, PeerInformationMessage.id, GNUNET_ATS_ConnectivitySuggestHandle.id, AddressListRequestMessage.id, GNUNET_MESSENGER_MessageBody.id, GNUNET_TUN_DnsHeader.id, AddressIteration.id, GNUNET_DNSPARSER_Packet.id, FindTreeClosure.id, GNUNET_TESTBED_PeerInformation.id, p, gnunet_testing.Peer.started, gnunet_testing.Check.test, and gnunet_testing.Peer.test.

305  def start(self):
306  os.unsetenv("XDG_CONFIG_HOME")
307  os.unsetenv("XDG_DATA_HOME")
308  os.unsetenv("XDG_CACHE_HOME")
309  self.test.p("Starting peer using cfg " + self.cfg)
310  try:
311  server = subprocess.Popen([
312  self.test.gnunetarm, '-sq', '-c', self.cfg
313  ])
314  server.communicate()
315  except OSError:
316  # print("Can not start peer")
317  logger.debug('Can not start peer')
318  self.started = False
319  return False
320  self.started = True
321  test = ''
322  try:
323  server = pexpect()
324  server.spawn(
325  None, [self.test.gnunetpeerinfo, '-c', self.cfg, '-s'],
326  stdout=subprocess.PIPE,
327  stderr=subprocess.STDOUT
328  )
329  test = server.read("stdout", 1024)
330  except OSError:
331  # print("Can not get peer identity")
332  logger.debug('Can not get peer identity')
333  test = (test.split(b'`')[1])
334  self.id = test.split(b'\'')[0]
335  return True
336 
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59

◆ stop()

def gnunet_testing.Peer.stop (   self)

Definition at line 337 of file gnunet_testing.py.

References GNUNET_CORE_MonitorHandle.cfg, GNUNET_GNS_Handle.cfg, Speaker.cfg, Microphone.cfg, GNUNET_CONSENSUS_Handle.cfg, GNUNET_ARM_MonitorHandle.cfg, GNUNET_DATACACHE_Handle.cfg, GNUNET_CADET_ChannelMonitor.cfg, GNUNET_CADET_PeersLister.cfg, GNUNET_CADET_ListTunnels.cfg, GNUNET_CADET_GetPath.cfg, GNUNET_CADET_Handle.cfg, GNUNET_ATS_ConnectivityHandle.cfg, GNUNET_DNS_Handle.cfg, GNUNET_DATACACHE_PluginEnvironment.cfg, GNUNET_BLOCK_Context.cfg, GNUNET_DATASTORE_PluginEnvironment.cfg, PeerCmdState.cfg, Plugin.cfg, GNUNET_CORE_Handle.cfg, GNUNET_CONVERSATION_Call.cfg, GNUNET_TESTING_SharedService.cfg, GNUNET_IDENTITY_Handle.cfg, GNUNET_ABD_Handle.cfg, GNUNET_ATS_SchedulingHandle.cfg, GNUNET_ARM_Handle.cfg, ControllerState.cfg, GNUNET_ATS_PerformanceHandle.cfg, GNUNET_CONVERSATION_Phone.cfg, GNUNET_DATASTORE_Handle.cfg, GNUNET_DHT_Handle.cfg, GNUNET_TRANSPORT_PluginEnvironment.cfg, Experiment.cfg, gnunet_testing.Peer.cfg, GNUNET_ATS_PluginEnvironment.cfg, GNUNET_TESTBED_PeerInformation.cfg, GNUNET_FS_Handle.cfg, p, gnunet_testing.Peer.started, gnunet_testing.Check.test, and gnunet_testing.Peer.test.

Referenced by gnunet_testing.Peer.__del__().

337  def stop(self):
338  if (self.started == False):
339  return False
340  self.test.p("Stopping peer using cfg " + self.cfg)
341  try:
342  server = subprocess.Popen([
343  self.test.gnunetarm, '-eq', '-c', self.cfg
344  ])
345  server.communicate()
346  except OSError:
347  # print("Can not stop peer")
348  logger.debug('Can not stop peer')
349  return False
350  self.started = False
351  return True
352 
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
Here is the caller graph for this function:

◆ get_statistics_value()

def gnunet_testing.Peer.get_statistics_value (   self,
  subsystem,
  name 
)

Definition at line 353 of file gnunet_testing.py.

References GNUNET_CORE_MonitorHandle.cfg, GNUNET_GNS_Handle.cfg, Speaker.cfg, Microphone.cfg, GNUNET_CONSENSUS_Handle.cfg, GNUNET_ARM_MonitorHandle.cfg, GNUNET_DATACACHE_Handle.cfg, GNUNET_CADET_ChannelMonitor.cfg, GNUNET_CADET_GetPath.cfg, GNUNET_CADET_PeersLister.cfg, GNUNET_CADET_ListTunnels.cfg, GNUNET_CADET_Handle.cfg, GNUNET_ATS_ConnectivityHandle.cfg, GNUNET_DNS_Handle.cfg, GNUNET_DATACACHE_PluginEnvironment.cfg, GNUNET_BLOCK_Context.cfg, GNUNET_DATASTORE_PluginEnvironment.cfg, PeerCmdState.cfg, Plugin.cfg, GNUNET_CORE_Handle.cfg, GNUNET_CONVERSATION_Call.cfg, GNUNET_TESTING_SharedService.cfg, GNUNET_IDENTITY_Handle.cfg, GNUNET_ABD_Handle.cfg, GNUNET_ATS_SchedulingHandle.cfg, GNUNET_ARM_Handle.cfg, ControllerState.cfg, GNUNET_ATS_PerformanceHandle.cfg, GNUNET_CONVERSATION_Phone.cfg, GNUNET_DATASTORE_Handle.cfg, GNUNET_DHT_Handle.cfg, GNUNET_TRANSPORT_PluginEnvironment.cfg, Experiment.cfg, gnunet_testing.Peer.cfg, GNUNET_ATS_PluginEnvironment.cfg, GNUNET_TESTBED_PeerInformation.cfg, GNUNET_FS_Handle.cfg, gnunet_testing.Check.test, and gnunet_testing.Peer.test.

353  def get_statistics_value(self, subsystem, name):
354  server = pexpect()
355  server.spawn(
356  None, [
357  self.test.gnunetstatistics, '-c', self.cfg, '-q', '-n', name,
358  '-s', subsystem
359  ],
360  stdout=subprocess.PIPE,
361  stderr=subprocess.STDOUT
362  )
363  # server.expect ("stdout", re.compile (r""))
364  test = server.read("stdout", 10240)
365  tests = test.partition(b'\n')
366  # On W32 GNUnet outputs with \r\n, rather than \n
367  if os.name == 'nt' and tests[1] == b'\n' and tests[0][-1] == b'\r':
368  tests = (tests[0][:-1], tests[1], tests[2])
369  tests = tests[0]
370  result = tests.decode("utf-8").strip()
371  logger.debug(
372  'running gnunet-statistics %s for %s "/" %s yields %s', self.cfg,
373  name, subsystem, result
374  )
375  if (result.isdigit() == True):
376  return result
377  else:
378  logger.debug(
379  'Invalid statistics value: %s is not a number!', result
380  )
381  return -1
382 
def get_statistics_value(self, subsystem, name)

Field Documentation

◆ id

gnunet_testing.Peer.id

Definition at line 283 of file gnunet_testing.py.

Referenced by gnunet_testing.Peer.start().

◆ test

gnunet_testing.Peer.test

◆ started

gnunet_testing.Peer.started

◆ cfg


The documentation for this class was generated from the following file: