Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Sync tests against last master update #152

Merged
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
63 changes: 36 additions & 27 deletions tests/influxdb/client_test_with_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class InfluxDbInstance(object):
in a temporary place, using a config file template.
'''

def __init__(self, conf_template):
def __init__(self, conf_template, udp_enabled=False):
# create a temporary dir to store all needed files
# for the influxdb server instance :
self.temp_dir_base = tempfile.mkdtemp()
Expand All @@ -142,28 +142,28 @@ def __init__(self, conf_template):
tempdir = self.temp_dir_influxdb = tempfile.mkdtemp(
dir=self.temp_dir_base)
# we need some "free" ports :
self.broker_port = get_free_port()
self.admin_port = get_free_port()
self.udp_port = get_free_port()
self.snapshot_port = get_free_port()

self.logs_file = os.path.join(self.temp_dir_base, 'logs.txt')

with open(conf_template) as fh:
conf = fh.read().format(
broker_port=self.broker_port,
admin_port=self.admin_port,
udp_port=self.udp_port,
broker_raft_dir=os.path.join(tempdir, 'raft'),
broker_node_dir=os.path.join(tempdir, 'db'),
cluster_dir=os.path.join(tempdir, 'state'),
logfile=self.logs_file,
snapshot_port=self.snapshot_port,
)

ports = dict(
broker_port=get_free_port(),
webui_port=get_free_port(),
admin_port=get_free_port(),
udp_port=get_free_port() if udp_enabled else -1,
)

conf_data = dict(
broker_raft_dir=os.path.join(tempdir, 'raft'),
broker_node_dir=os.path.join(tempdir, 'db'),
cluster_dir=os.path.join(tempdir, 'state'),
logs_file=os.path.join(self.temp_dir_base, 'logs.txt'),
udp_enabled='true' if udp_enabled else 'false',
)
conf_data.update(ports)
self.__dict__.update(conf_data)

conf_file = os.path.join(self.temp_dir_base, 'influxdb.conf')
with open(conf_file, "w") as fh:
fh.write(conf)
with open(conf_template) as fh_template:
fh.write(fh_template.read().format(**conf_data))

# now start the server instance:
proc = self.proc = subprocess.Popen(
Expand All @@ -182,8 +182,13 @@ def __init__(self, conf_template):
# or you run a 286 @ 1Mhz ?
try:
while time.time() < timeout:
if (is_port_open(self.broker_port)
if (is_port_open(self.webui_port)
and is_port_open(self.admin_port)):
# it's hard to check if a UDP port is open..
if udp_enabled:
# so let's just sleep 0.5 sec in this case
# to be sure that the server has open the port
time.sleep(0.5)
break
time.sleep(0.5)
if proc.poll() is not None:
Expand All @@ -192,13 +197,13 @@ def __init__(self, conf_template):
proc.terminate()
proc.wait()
raise RuntimeError('Timeout waiting for influxdb to listen'
' on its broker port')
' on its ports (%s)' % ports)
except RuntimeError as err:
data = self.get_logs_and_output()
data['reason'] = str(err)
data['now'] = datetime.datetime.now()
raise RuntimeError("%(now)s > %(reason)s. RC=%(rc)s\n"
"stdout=%(out)r\nstderr=%(err)r\nlogs=%(logs)r"
"stdout=%(out)s\nstderr=%(err)s\nlogs=%(logs)r"
% data)

def get_logs_and_output(self):
Expand All @@ -225,9 +230,11 @@ def close(self, remove_tree=True):


def _setup_influxdb_server(inst):
inst.influxd_inst = InfluxDbInstance(inst.influxdb_template_conf)
inst.influxd_inst = InfluxDbInstance(
inst.influxdb_template_conf,
udp_enabled=getattr(inst, 'influxdb_udp_enabled', False))
inst.cli = InfluxDBClient('localhost',
inst.influxd_inst.broker_port,
inst.influxd_inst.webui_port,
'root', '', database='db')


Expand Down Expand Up @@ -653,12 +660,14 @@ def test_tags_json_order(self):
class UdpTests(ManyTestCasesWithServerMixin,
unittest.TestCase):

influxdb_udp_enabled = True

influxdb_template_conf = os.path.join(THIS_DIR,
'influxdb.udp_conf.template')
'influxdb.conf.template')

def test_write_points_udp(self):
cli = InfluxDBClient(
'localhost', self.influxd_inst.broker_port,
'localhost', self.influxd_inst.webui_port,
'dont', 'care',
database='db',
use_udp=True, udp_port=self.influxd_inst.udp_port
Expand Down
59 changes: 30 additions & 29 deletions tests/influxdb/influxdb.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# that can be resolved here.
# hostname = ""
bind-address = "0.0.0.0"
port = {webui_port}

# Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com
# The data includes raft id (random 8 bytes), os, arch and version
Expand All @@ -14,11 +15,6 @@ bind-address = "0.0.0.0"
# Change this option to true to disable reporting.
reporting-disabled = false

# Controls settings for initial start-up. Once a node a successfully started,
# these settings are ignored.
[initialization]
join-urls = "" # Comma-delimited URLs, in the form http://host:port, for joining another cluster.

# Control authentication
# If not set authetication is DISABLED. Be sure to explicitly set this flag to
# true if you want authentication.
Expand Down Expand Up @@ -53,52 +49,57 @@ enabled = false
#database = "collectd_database"
#typesdb = "types.db"

# Configure the OpenTSDB input.
[opentsdb]
enabled = false
#address = "0.0.0.0" # If not set, is actually set to bind-address.
#port = 4242
#database = "opentsdb_database"

# Configure UDP listener for series data.
[udp]
enabled = false
enabled = {udp_enabled}
#bind-address = "0.0.0.0"
#port = 4444
port = {udp_port}

# Broker configuration. Brokers are nodes which participate in distributed
# consensus.
[broker]
enabled = true
# Where the Raft logs are stored. The user running InfluxDB will need read/write access.
#dir = "/var/opt/influxdb/raft"
dir = "{broker_raft_dir}"
port = {broker_port}

# Data node configuration. Data nodes are where the time-series data, in the form of
# shards, is stored.
[data]
dir = "{broker_node_dir}"
port = {broker_port}
enabled = true
#dir = "/var/opt/influxdb/db"
dir = "{broker_node_dir}"

# Auto-create a retention policy when a database is created. Defaults to true.
retention-auto-create = true
# Auto-create a retention policy when a database is created. Defaults to true.
retention-auto-create = true

# Control whether retention policies are enforced and how long the system waits between
# enforcing those policies.
retention-check-enabled = true
retention-check-period = "10m"
# Control whether retention policies are enforced and how long the system waits between
# enforcing those policies.
retention-check-enabled = true
retention-check-period = "10m"

[cluster]
# Location for cluster state storage. For storing state persistently across restarts.
dir = "{cluster_dir}"
# Configuration for snapshot endpoint.
[snapshot]
enabled = false # Enabled by default if not set.
bind-address = "127.0.0.1"
port = 8087

[logging]
file = "{logfile}" # Leave blank to redirect logs to stderr.
write-tracing = false # If true, enables detailed logging of the write system.
raft-tracing = false # If true, enables detailed logging of Raft consensus.

# InfluxDB can store statistics about itself. This is useful for monitoring purposes.
# This feature is disabled by default, but if enabled, these statistics can be queried
# as any other data.
[statistics]
# InfluxDB can store statistical and diagnostic information about itself. This is useful for
# monitoring purposes. This feature is disabled by default, but if enabled, these data can be
# queried like any other data.
[monitoring]
enabled = false
database = "internal" # The database to which the data is written.
retention-policy = "default" # The retention policy within the database.
write-interval = "1m" # Period between writing the data.


[snapshot]
bind-address = "127.0.0.1"
port = {snapshot_port}
103 changes: 0 additions & 103 deletions tests/influxdb/influxdb.udp_conf.template

This file was deleted.

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy