2020-04-16 07:44:34 -07:00
|
|
|
# Copyright 2020 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2021-03-17 12:57:21 -07:00
|
|
|
import json
|
|
|
|
|
2020-04-16 07:44:34 -07:00
|
|
|
|
|
|
|
testinfra_hosts = ['zk01.opendev.org']
|
|
|
|
|
|
|
|
|
|
|
|
def test_id_file(host):
|
|
|
|
# Test that wacky hostname regex works
|
|
|
|
myid = host.file('/var/zookeeper/data/myid')
|
|
|
|
assert myid.content == b'1\n'
|
|
|
|
|
|
|
|
def test_zk_listening(host):
|
2021-03-12 09:12:05 -08:00
|
|
|
zk = host.socket("tcp://0.0.0.0:2181")
|
2020-04-16 07:44:34 -07:00
|
|
|
assert zk.is_listening
|
2020-06-17 10:32:17 -07:00
|
|
|
|
|
|
|
def test_zk_listening_ssl(host):
|
|
|
|
zk = host.socket("tcp://0.0.0.0:2281")
|
|
|
|
assert zk.is_listening
|
2021-03-12 09:12:05 -08:00
|
|
|
|
|
|
|
def test_l4_commands(host):
|
|
|
|
cmd = host.run("echo srvr | nc localhost 2181")
|
|
|
|
assert "Zookeeper version" in cmd.stdout
|
|
|
|
assert "not executed because it is not in the whitelist" not in cmd.stdout
|
|
|
|
|
|
|
|
cmd = host.run("echo stat | nc localhost 2181")
|
|
|
|
assert "Zookeeper version" in cmd.stdout
|
|
|
|
assert "not executed because it is not in the whitelist" not in cmd.stdout
|
|
|
|
|
|
|
|
cmd = host.run("echo dump | nc localhost 2181")
|
|
|
|
assert "SessionTracker dump" in cmd.stdout
|
|
|
|
assert "not executed because it is not in the whitelist" not in cmd.stdout
|
2021-03-17 12:57:21 -07:00
|
|
|
|
|
|
|
cmd = host.run("echo mntr | nc localhost 2181")
|
|
|
|
assert "zk_version" in cmd.stdout
|
|
|
|
assert "not executed because it is not in the whitelist" not in cmd.stdout
|
|
|
|
|
|
|
|
def test_zookeeper_statsd_running(host):
|
|
|
|
cmd = host.run("docker inspect zookeeper-compose_zookeeper-statsd_1")
|
|
|
|
out = json.loads(cmd.stdout)
|
|
|
|
assert out[0]["State"]["Status"] == "running"
|
|
|
|
assert out[0]["RestartCount"] == 0
|