def test_syslog_server_tc1_add_init(duthost, setup_env, op, dummy_syslog_server_v4, dummy_syslog_server_v6): """ Add v4 and v6 syslog server to config Sample output admin@vlab-01:~$ show runningconfiguration syslog Syslog Servers ---------------- [10.0.0.5] [cc98:2008::1] """ json_patch = [{ "op": "{}".format(op), "path": "/SYSLOG_SERVER", "value": { "{}".format(dummy_syslog_server_v4): {}, "{}".format(dummy_syslog_server_v6): {} } }] tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) expect_op_success_and_reset_check(duthost, output, 'rsyslog-config', SYSLOG_TIMEOUT, SYSLOG_INTERVAL, 0) expected_content_list = [ "[{}]".format(dummy_syslog_server_v4), "[{}]".format(dummy_syslog_server_v6) ] expect_res_success_syslog(duthost, expected_content_list, []) delete_tmpfile(duthost, tmpfile)
def test_syslog_server_tc4_remove(duthost, setup_env, op, dummy_syslog_server_v4, dummy_syslog_server_v6): """ Remove v4 and v6 syslog server admin@vlab-01:~$ show runningconfiguration syslog Sample output: Syslog Servers ---------------- """ json_patch = [{"op": "{}".format(op), "path": "/SYSLOG_SERVER"}] tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) expect_op_success_and_reset_check(duthost, output, 'rsyslog-config', SYSLOG_TIMEOUT, SYSLOG_INTERVAL, 0) unexpected_content_list = [ "[{}]".format(dummy_syslog_server_v4), "[{}]".format(dummy_syslog_server_v6) ] expect_res_success_syslog(duthost, [], unexpected_content_list) delete_tmpfile(duthost, tmpfile)
def test_dhcp_relay_tc7_add_rm(duthost, setup_vlan, init_dhcp_server_config, vlan_intfs_list): """Test mixed add and rm ops for dhcp server on default setup This VLAN detail should show below after test +-----------+------------------+-----------+----------------+-------------+-----------------------+ | VLAN ID | IP Address | Ports | Port Tagging | Proxy ARP | DHCP Helper Address | +===========+==================+===========+================+=============+=======================+ | 108 | 192.168.108.1/24 | Ethernet4 | tagged | disabled | 192.0.108.1 | | | | | | | 192.0.108.2 | | | | | | | 192.0.108.3 | | | | | | | 192.0.108.4 | +-----------+------------------+-----------+----------------+-------------+-----------------------+ | 109 | 192.168.109.1/24 | Ethernet4 | tagged | disabled | 192.0.109.1 | | | | | | | 192.0.109.2 | | | | | | | 192.0.109.3 | | | | | | | 192.0.109.4 | +-----------+------------------+-----------+----------------+-------------+-----------------------+ """ if init_dhcp_server_config != "default_setup": pytest.skip("Unsupported init config") dhcp_add_rm_json = [{ "op": "remove", "path": "/VLAN/Vlan" + str(vlan_intfs_list[1]) + "/dhcp_servers/4" }, { "op": "add", "path": "/VLAN/Vlan" + str(vlan_intfs_list[0]) + "/dhcp_servers/3", "value": "192.0." + str(vlan_intfs_list[0]) + ".4" }] tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) output = apply_patch(duthost, json_data=dhcp_add_rm_json, dest_file=tmpfile) expect_op_success_and_reset_check(duthost, output, 'dhcp_relay', DHCP_RELAY_TIMEOUT, DHCP_RELAY_INTERVAL, 0) pytest_assert(duthost.is_service_fully_started('dhcp_relay'), "dhcp_relay service is not running") expected_content_list = ["192.0." + str(vlan_intfs_list[0]) + ".4"] unexpected_content_list = ["192.0." + str(vlan_intfs_list[1]) + ".5"] expect_res_success_by_vlanid(duthost, vlan_intfs_list[0], expected_content_list, []) expect_res_success_by_vlanid(duthost, vlan_intfs_list[1], [], unexpected_content_list) delete_tmpfile(duthost, tmpfile)
def test_syslog_server_tc5_add_to_max(duthost, setup_env): """ Test syslog server max admin@vlab-01:~$ show runningconfiguration syslog Sample output: Syslog Servers ---------------- [10.0.0.1] ... [10.0.0.SYSLOG_MAX_SERVER] """ if SYSLOG_MAX_SERVER == -1 or SYSLOG_MAX_SERVER > SYSLOG_TEST_MAX_UPPER_LIMIT: pytest.skip( "SYSLOG_MAX_SERVER is not set or is over the test max upper limit") syslog_servers = [ "10.0.0.{}".format(i) for i in range(1, SYSLOG_MAX_SERVER + 1) ] json_patch = [{ "op": "add", "path": "/SYSLOG_SERVER", "value": {"{}".format(syslog_server): {} for syslog_server in syslog_servers} }] tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile) expect_op_success_and_reset_check(duthost, output, 'rsyslog-config', SYSLOG_TIMEOUT, SYSLOG_INTERVAL, 0) status = duthost.get_service_props('rsyslog-config')["ActiveState"] logger.info("rsyslog-config status {}".format(status)) pytest_assert( duthost.get_service_props('rsyslog-config')["ActiveState"] == "active", "rsyslog-config service is not active") expected_content_list = [ "[{}]".format(syslog_server) for syslog_server in syslog_servers ] expect_res_success_syslog(duthost, expected_content_list, []) delete_tmpfile(duthost, tmpfile)
def test_dhcp_relay_tc1_apply_empty(duthost, setup_vlan, init_dhcp_server_config): """Test apply empty JSON file to see if apply-patch command work as expected """ dhcp_apply_empty_json = [] tmpfile = generate_tmpfile(duthost) logger.info("tmpfile {}".format(tmpfile)) output = apply_patch(duthost, json_data=dhcp_apply_empty_json, dest_file=tmpfile) expect_op_success_and_reset_check(duthost, output, 'dhcp_relay', DHCP_RELAY_TIMEOUT, DHCP_RELAY_INTERVAL, 0) pytest_assert(duthost.is_service_fully_started('dhcp_relay'), "dhcp_relay service is not running") delete_tmpfile(duthost, tmpfile)