Skip to content

Commit

Permalink
Issue 5738 - RFE - UI - Read/write replication monitor info to .dsrc …
Browse files Browse the repository at this point in the history
…file

Description:

Allow UI to use the .dsrc replication monitor info, and also allow the UI to
write new report configurations.  This prevents an admin from having to enter
this information every time they want to run a report

relates: 389ds#5738

Reviewed by: spichugi(Thanks!)
  • Loading branch information
mreynolds389 committed May 8, 2023
1 parent ea0ed1f commit 3dd9bd3
Show file tree
Hide file tree
Showing 14 changed files with 2,661 additions and 944 deletions.
152 changes: 135 additions & 17 deletions dirsrvtests/tests/suites/clu/dsrc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,39 @@
import os
from os.path import expanduser
from lib389.cli_base import FakeArgs
from lib389.cli_ctl.dsrc import create_dsrc, modify_dsrc, delete_dsrc, display_dsrc
from lib389.cli_ctl.dsrc import create_dsrc, modify_dsrc, delete_dsrc, display_dsrc, replmon_dsrc
from lib389._constants import DEFAULT_SUFFIX, DN_DM
from lib389.topologies import topology_st as topo

log = logging.getLogger(__name__)


def get_fake_args():
# Setup our args
args = FakeArgs()
args.basedn = DEFAULT_SUFFIX
args.groups_rdn = None
args.people_rdn = None
args.binddn = DN_DM
args.json = None
args.uri = None
args.saslmech = None
args.tls_cacertdir = None
args.tls_cert = None
args.tls_key = None
args.tls_reqcert = None
args.starttls = None
args.cancel_starttls = None
args.pwdfile = None
args.do_it = True
args.add_conn = None
args.del_conn = None
args.add_alias = None
args.del_alias = None

return args


@pytest.fixture(scope="function")
def setup(topo, request):
"""Preserve any existing .dsrc file"""
Expand Down Expand Up @@ -65,22 +91,7 @@ def test_dsrc(topo, setup):
different_suffix = "o=different"

# Setup our args
args = FakeArgs()
args.basedn = DEFAULT_SUFFIX
args.groups_rdn = None
args.people_rdn = None
args.binddn = DN_DM
args.json = None
args.uri = None
args.saslmech = None
args.tls_cacertdir = None
args.tls_cert = None
args.tls_key = None
args.tls_reqcert = None
args.starttls = None
args.cancel_starttls = None
args.pwdfile = None
args.do_it = True
args = get_fake_args()

# Create a dsrc configuration entry
create_dsrc(inst, log, args)
Expand Down Expand Up @@ -138,6 +149,113 @@ def test_dsrc(topo, setup):
display_dsrc(inst, log, args)


def test_dsrc_repl_mon(topo, setup):
"""Test "dsctl dsrc repl-mon" command, add & remove creds and aliases
:id: 33007d01-f11c-456b-bb16-fcd7920c9fc8
:setup: Standalone Instance
:steps:
1. Add connection
2. Add same connection - should fail
3. Delete connection
4. Delete same connection - should fail
5. Add alias
6. Add same alias - should fail
7. Delete alias
8. Delete same alias again 0 should fail
:expectedresults:
1. Success
2. Success
3. Success
4. Success
5. Success
6. Success
7. Success
8. Success
"""

inst = topo.standalone
args = get_fake_args()
create_dsrc(inst, log, args)

# Add replica connection
assert not topo.logcap.contains("repl-monitor-connections")
repl_conn = "replica_1:localhost:5555:cn=directory manager:password"
args.add_conn = [repl_conn,]
replmon_dsrc(inst, log, args)
display_dsrc(inst, topo.logcap.log, args)
assert topo.logcap.contains("repl-monitor-connections")
assert topo.logcap.contains("replica_1 = localhost:5555:cn=directory manager:password")
topo.logcap.flush()
args.add_conn = None

# Add duplicate replica connection
args.add_conn = [repl_conn, ]
try:
replmon_dsrc(inst, log, args)
assert False
except ValueError:
pass
args.add_conn = None

# Delete replica connection
args.del_conn = ["replica_1"]
replmon_dsrc(inst, log, args)
display_dsrc(inst, topo.logcap.log, args)
assert not topo.logcap.contains("replica_1 = localhost:5555:cn=directory manager:password")
assert not topo.logcap.contains("repl-monitor-connections")
topo.logcap.flush()
args.del_conn = None

# Delete replica connection (already deleted)
args.del_conn = ["replica_1"]
try:
replmon_dsrc(inst, log, args)
assert False
except ValueError:
pass
args.del_conn = None

# Add Alias
assert not topo.logcap.contains("repl-monitor-aliases")
repl_alias = "my_alias:localhost:4444"
args.add_alias = [repl_alias,]
replmon_dsrc(inst, log, args)
display_dsrc(inst, topo.logcap.log, args)
assert topo.logcap.contains("repl-monitor-aliases")
assert topo.logcap.contains("my_alias = localhost:4444")
topo.logcap.flush()
args.add_alias = None

# Add Duplicate Alias
args.add_alias = [repl_alias,]
try:
replmon_dsrc(inst, log, args)
assert False
except ValueError:
pass
args.add_alias = None

# Delete Alias
args.del_alias = ["my_alias",]
replmon_dsrc(inst, log, args)
display_dsrc(inst, topo.logcap.log, args)
assert not topo.logcap.contains("my_alias = localhost:4444")
assert not topo.logcap.contains("repl-monitor-aliases")
topo.logcap.flush()
args.del_alias = None

# Delete alias (already deleted)
args.del_alias = ["my_alias", ]
try:
replmon_dsrc(inst, log, args)
assert False
except ValueError:
pass
args.del_alias = None


if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
Expand Down
1 change: 1 addition & 0 deletions dirsrvtests/tests/suites/webui/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To run locally you need to set WEBUI=1 and PASSWD=<password> env variables. You also need to remove "root" from /etc/cockpit/disallowed-users
20 changes: 5 additions & 15 deletions dirsrvtests/tests/suites/webui/monitoring/monitoring_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,14 @@ def test_replication_visibility(topology_st, page, browser_name):
log.info('Click on Monitoring tab and then on Replication in the menu and check if element is loaded.')
frame.get_by_role('tab', name='Monitoring', exact=True).click()
frame.locator('#replication-monitor').click()
frame.get_by_role('button', name='Synchronization Report').wait_for()
frame.locator('#sync-report').click()
frame.get_by_role('tab', name='Prepare New Report').click()
frame.get_by_role('button', name='Generate Report').wait_for()
assert frame.get_by_role('button', name='Generate Report').is_visible()

log.info('Click on Agreements tab and check if element is loaded.')
frame.get_by_role('tab', name='Agreements').click()
assert frame.get_by_role('columnheader', name='Replication Agreements').is_visible()

log.info('Click on Winsync tab and check if element is loaded.')
frame.get_by_role('tab', name='Winsync').click()
assert frame.get_by_role('columnheader', name='Winsync Agreements').is_visible()

log.info('Click on Tasks tab and check if element is loaded.')
frame.get_by_role('tab', name='Tasks').click()
assert frame.get_by_role('columnheader', name='CleanAllRUV Tasks').is_visible()

log.info('Click on Conflict Entries tab and check if element is loaded.')
frame.get_by_role('tab', name='Conflict Entries').click()
assert frame.get_by_role('columnheader', name='Replication Conflict Entries').is_visible()
assert frame.locator('#replication-suffix-dc\\=example\\,dc\\=com').is_visible()


def test_database_visibility(topology_st, page, browser_name):
Expand All @@ -169,7 +159,7 @@ def test_database_visibility(topology_st, page, browser_name):

log.info('Click on Monitoring tab, then click on database button and check if element is loaded.')
frame.get_by_role('tab', name='Monitoring', exact=True).click()
frame.locator('#dc\=example\,dc\=com').click()
frame.locator('#dc\\=example\\,dc\\=com').click()
frame.get_by_text('Entry Cache Hit Ratio').wait_for()
assert frame.get_by_text('Entry Cache Hit Ratio').is_visible()

Expand Down
Loading

0 comments on commit 3dd9bd3

Please sign in to comment.