Skip to content

Commit

Permalink
Applying Variable changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vvoluom committed Apr 13, 2020
1 parent a5e5fad commit f68fe4e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ WORKDIR ./src

RUN go build -o main .

EXPOSE 8080
EXPOSE 8686

CMD ["./main"]
12 changes: 6 additions & 6 deletions config/example_user_config_nodes.ini
Original file line number Diff line number Diff line change
@@ -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/
isocket_path = unix:/serverdir/nodes/internal.sock
prometheus_url = http://127.0.0.1:3001/
10 changes: 5 additions & 5 deletions setup/setup_user_config_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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:
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions setup/utils/config_parsers/node.py
Original file line number Diff line number Diff line change
@@ -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
self.isocket_path = isocket_path
self.prometheus_url = prometheus_url
4 changes: 2 additions & 2 deletions src/handlers/general_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
}

Expand All @@ -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"]
}
}

Expand Down
28 changes: 14 additions & 14 deletions src/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
}

0 comments on commit f68fe4e

Please sign in to comment.