Пример #1
0
    }
    sleep($waiting_time);
    $children = QConf::getBatchConf($batch_path);
    var_dump($children);
    print_info($children == $cur_batch_nodes, $line);
    $keys = QConf::getBatchKeys($batch_path);
    var_dump($keys);
    print_info($keys == array_keys($cur_batch_nodes), $line);
    //print_check_script(TRUE === check_script_result($batch_path, $idc, "4", $waiting_time + 2), $line);
    echo_color("[===============================END==]", GREEN);
    echo PHP_EOL . PHP_EOL;
}
echo_color("[-- clear all services: BEGIN --]", BROWN);
assert(0 === $qzk->serviceAdd("{$prefix}{$service_path}", $skey[1], QCONF_STATUS_UP));
sleep(10);
assert(0 === $qzk->serviceClear("{$prefix}{$service_path}"));
$histroy_ops = array();
echo_color("[-- END --]", BROWN);
echo PHP_EOL . PHP_EOL;
echo_color("one service, add one", CYAN);
$ops[$skey[0]] = OP_SERV_ADD;
service_operation($ops, $history_ops, __LINE__, TRUE);
echo_color("one service, down one", CYAN);
$ops[$skey[0]] = OP_SERV_DOWN;
service_operation($ops, $history_ops, __LINE__);
echo_color("one service, up one", CYAN);
$ops[$skey[0]] = OP_SERV_UP;
service_operation($ops, $history_ops, __LINE__);
echo_color("one service, offline one", CYAN);
$ops[$skey[0]] = OP_SERV_OFFLINE;
service_operation($ops, $history_ops, __LINE__);
Пример #2
0
assert(0 !== $zk->serviceAdd($service_key, $cg_service, 3));
assert(0 !== $zk->serviceAdd($service_key, $cg_service, -1));
assert(0 !== $zk->serviceAdd($service_key, $cg_service, 1.111111111111111E+19));
$services[$cg_service] = QCONF_STATUS_OFFLINE;
assert($services === $zk->servicesGetWithStatus($service_key));
assert(array_keys($services) === $zk->servicesGet($service_key));
//serviceDelete
$cg_service = "10.16.15.235:87";
assert(0 !== $zk->serviceDelete("", $cg_service));
assert(0 !== $zk->serviceDelete("/", $cg_service));
assert(0 === $zk->serviceDelete($service_key, $cg_service));
unset($services[$cg_service]);
assert($services === $zk->servicesGetWithStatus($service_key));
assert(array_keys($services) === $zk->servicesGet($service_key));
//serviceClear
assert(0 !== $zk->serviceClear(""));
assert(0 !== $zk->serviceClear("/"));
assert(0 === $zk->serviceClear($service_key));
assert($services_empty == $zk->servicesGetWithStatus($service_key));
//list listWithValue
$children = array("child1" => "value1", "child2" => "value2", "child3" => "value3", "child4" => "value4", "child5" => "value5");
$parent_path = "qconf_manager/demo/1";
foreach ($children as $c_key => $c_val) {
    assert(0 === $zk->nodeSet("{$parent_path}/{$c_key}", $c_val));
}
assert($children === $zk->listWithValue($parent_path));
assert(array_keys($children) === $zk->list($parent_path));
$children = array("child1" => "value1", "child2" => 1, "child3" => "value3", "child4" => "value4", "child5" => "value5");
$parent_path = "qconf_manager/demo/1";
foreach ($children as $c_key => $c_val) {
    assert(0 === $zk->nodeSet("{$parent_path}/{$c_key}", $c_val));