From f68fe4e8a13f9d31082d416cc510e8d9ffe13faa Mon Sep 17 00:00:00 2001 From: vvol Date: Mon, 13 Apr 2020 11:01:45 +0200 Subject: [PATCH] Applying Variable changes --- Dockerfile | 2 +- config/example_user_config_nodes.ini | 12 ++++++------ setup/setup_user_config_nodes.py | 10 +++++----- setup/utils/config_parsers/node.py | 6 +++--- src/handlers/general_handler.go | 4 ++-- src/handlers/utils.go | 4 ++-- src/rpc/rpc_test.go | 28 ++++++++++++++-------------- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Dockerfile b/Dockerfile index e54bd58..7f54924 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,6 @@ WORKDIR ./src RUN go build -o main . -EXPOSE 8080 +EXPOSE 8686 CMD ["./main"] \ No newline at end of file diff --git a/config/example_user_config_nodes.ini b/config/example_user_config_nodes.ini index a6a881c..f23cd53 100644 --- a/config/example_user_config_nodes.ini +++ b/config/example_user_config_nodes.ini @@ -1,14 +1,14 @@ [node_0] node_name = Oasis_Local -is_path = unix:/serverdir/node/internal.sock -p_url = http://127.0.0.1:3000/ +isocket_path = unix:/serverdir/node/internal.sock +prometheus_url = http://127.0.0.1:3000/ [node_1] node_name = Oasis_Local_1 -is_path = unix:/serverdir/node/internal.sock -p_url = http://127.0.0.1:3000/ +isocket_path = unix:/serverdir/node/internal.sock +prometheus_url = http://127.0.0.1:3000/ [node_2] node_name = Oasis_Local_Failure -is_path = unix:/serverdir/nodes/internal.sock -p_url = http://127.0.0.1:3001/ \ No newline at end of file +isocket_path = unix:/serverdir/nodes/internal.sock +prometheus_url = http://127.0.0.1:3001/ \ No newline at end of file diff --git a/setup/setup_user_config_nodes.py b/setup/setup_user_config_nodes.py index c79c741..1ef9e26 100644 --- a/setup/setup_user_config_nodes.py +++ b/setup/setup_user_config_nodes.py @@ -17,7 +17,7 @@ def get_node(nodes_so_far: List[NodeConfig]) -> Optional[NodeConfig]: break # Get node's internal socket path way - is_path = input('Node\'s internal socket file path which was setup during ' + isocket_path = input('Node\'s internal socket file path which was setup during ' 'the Oasis node installation (typically ' 'unix:/serverdir/nodes/internal.sock):\n') @@ -26,11 +26,11 @@ def get_node(nodes_so_far: List[NodeConfig]) -> Optional[NodeConfig]: 'to know where to find the Prometheus endpoints! ') # Get Prometheus's URL of the Node - p_url = input('Prometheus Node\'s localhost url ' + prometheus_url = input('Prometheus Node\'s localhost url ' '(typically http://127.0.0.1:3000):\n') # Return node - return NodeConfig(node_name, is_path, p_url) + return NodeConfig(node_name, isocket_path, prometheus_url) def setup_nodes(cp: ConfigParser) -> None: @@ -75,5 +75,5 @@ def setup_nodes(cp: ConfigParser) -> None: section = 'node_' + str(i) cp.add_section(section) cp[section]['node_name'] = node.node_name - cp[section]['is_path'] = node.is_path - cp[section]['p_url'] = node.p_url + cp[section]['isocket_path'] = node.isocket_path + cp[section]['prometheus_url'] = node.prometheus_url diff --git a/setup/utils/config_parsers/node.py b/setup/utils/config_parsers/node.py index 01d7366..53b70ef 100644 --- a/setup/utils/config_parsers/node.py +++ b/setup/utils/config_parsers/node.py @@ -1,6 +1,6 @@ class NodeConfig: - def __init__(self, node_name: str, is_path: str, p_url : str) -> None: + def __init__(self, node_name: str, isocket_path: str, prometheus_url : str) -> None: self.node_name = node_name - self.is_path = is_path - self.p_url = p_url \ No newline at end of file + self.isocket_path = isocket_path + self.prometheus_url = prometheus_url \ No newline at end of file diff --git a/src/handlers/general_handler.go b/src/handlers/general_handler.go index 55165d0..a07d37f 100644 --- a/src/handlers/general_handler.go +++ b/src/handlers/general_handler.go @@ -31,8 +31,8 @@ func GetConnections(w http.ResponseWriter, r *http.Request) { lgr.Info.Println("Iterating through all socket connections.") for _, socket := range allSockets { - lgr.Info.Println("Node : ", socket["node_name"], " has socket at : ", socket["is_path"]) - connectionsResponse = append(connectionsResponse, socket["is_path"]) + lgr.Info.Println("Node : ", socket["node_name"], " has socket at : ", socket["isocket_path"]) + connectionsResponse = append(connectionsResponse, socket["isocket_path"]) } // Encode object and send it using predefind response json.NewEncoder(w).Encode(responses.ConnectionsResponse{ diff --git a/src/handlers/utils.go b/src/handlers/utils.go index 44a580b..8bd0a28 100644 --- a/src/handlers/utils.go +++ b/src/handlers/utils.go @@ -37,7 +37,7 @@ func checkNodeName(nodeName string) (bool, string) { // If nodeName is in configuration reply with it's websocket if socket["node_name"] == nodeName { lgr.Info.Println("Requested node ", nodeName, "was found!") - return true, socket["is_path"] + return true, socket["isocket_path"] } } @@ -57,7 +57,7 @@ func checkNodeNamePrometheus(nodeName string) (bool, string) { // If nodeName is in configuration reply with it's prometheus url if node["node_name"] == nodeName { lgr.Info.Println("Requested node ", nodeName, "was found!") - return true, node["p_url"] + return true, node["prometheus_url"] } } diff --git a/src/rpc/rpc_test.go b/src/rpc/rpc_test.go index 03ea72b..47a9650 100644 --- a/src/rpc/rpc_test.go +++ b/src/rpc/rpc_test.go @@ -11,8 +11,8 @@ import ( var ( ctx context.Context - is_path = "unix:/home/vvol/serverdir/node/internal.sock" - is_path_Invalid = "unix:/home/vvol/serverdir/nodes/internal.sock" + isocket_path = "unix:/home/vvol/serverdir/node/internal.sock" + isocket_path_Invalid = "unix:/home/vvol/serverdir/nodes/internal.sock" ) func TestMain(m *testing.M) { @@ -36,48 +36,48 @@ func teardown() { // Testing if Scheduler Client Connects func TestSchedulerClient_Success(t *testing.T) { - _, _, err := rpc.SchedulerClient(is_path) + _, _, err := rpc.SchedulerClient(isocket_path) if err != nil { - t.Errorf("Failed to create SchedulerClient for socket %v got %v", is_path, err) + t.Errorf("Failed to create SchedulerClient for socket %v got %v", isocket_path, err) } } // Testing if Node Controller Client Connects func TestNodeControllerClient_Success(t *testing.T) { - _, _, err := rpc.NodeControllerClient(is_path) + _, _, err := rpc.NodeControllerClient(isocket_path) if err != nil { - t.Errorf("Failed to create SchedulerClient for socket %v got %v", is_path, err) + t.Errorf("Failed to create SchedulerClient for socket %v got %v", isocket_path, err) } } // Testing if Registry Client Connects func TestRegistryClient_Success(t *testing.T) { - _, _, err := rpc.RegistryClient(is_path) + _, _, err := rpc.RegistryClient(isocket_path) if err != nil { - t.Errorf("Failed to create RegistryClient for socket %v got %v", is_path, err) + t.Errorf("Failed to create RegistryClient for socket %v got %v", isocket_path, err) } } // Testing if Registry Client Connects func TestStakingClient_Success(t *testing.T) { - _, _, err := rpc.StakingClient(is_path) + _, _, err := rpc.StakingClient(isocket_path) if err != nil { - t.Errorf("Failed to create StakingClient for socket %v got %v", is_path, err) + t.Errorf("Failed to create StakingClient for socket %v got %v", isocket_path, err) } } // Testing if Registry Client Connects func TestConsensusClient_Success(t *testing.T) { - _, _, err := rpc.ConsensusClient(is_path) + _, _, err := rpc.ConsensusClient(isocket_path) if err != nil { - t.Errorf("Failed to create ConsensusClient for socket %v got %v", is_path, err) + t.Errorf("Failed to create ConsensusClient for socket %v got %v", isocket_path, err) } } // Testing connection function func TestConnect_Success(t *testing.T) { - _, err := rpc.Connect(is_path) + _, err := rpc.Connect(isocket_path) if err != nil { - t.Errorf("Failed to create connection for socket %v got %v", is_path, err) + t.Errorf("Failed to create connection for socket %v got %v", isocket_path, err) } }