Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dashboard] Supplier logs dashboard #502

Merged
merged 12 commits into from
Apr 28, 2024
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ test_e2e: test_e2e_env ## Run all E2E tests
test_e2e_app:
go test -v ./e2e/tests/... -tags=e2e,test --features-path=stake_app.feature

.PHONY: test_e2e_supplier
test_e2e_supplier:
go test -v ./e2e/tests/... -tags=e2e,test --features-path=stake_supplier.feature

.PHONY: test_e2e_gateway
test_e2e_gateway:
go test -v ./e2e/tests/... -tags=e2e,test --features-path=stake_gateway.feature
Expand Down
22 changes: 20 additions & 2 deletions e2e/tests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (s *suite) TheUserRunsTheCommand(cmd string) {
}

func (s *suite) TheUserShouldBeAbleToSeeStandardOutputContaining(arg1 string) {
fmt.Println(s.pocketd.result.Stdout, "~~~", arg1)
require.Contains(s, s.pocketd.result.Stdout, arg1)
}

Expand Down Expand Up @@ -219,14 +220,31 @@ func (s *suite) TheUserStakesAWithUpoktFromTheAccount(actorType string, amount i

func (s *suite) TheUserStakesAWithUpoktForServiceFromTheAccount(actorType string, amount int64, serviceId, accName string) {
// Create a temporary config file
configPathPattern := fmt.Sprintf("%s_stake_config_*.yaml", accName)
configPathPattern := fmt.Sprintf("%s_stake_config.yaml", accName)
configFile, err := os.CreateTemp("", configPathPattern)
require.NoError(s, err, "error creating config file in %q", path.Join(os.TempDir(), configPathPattern))

configContent := fmt.Sprintf("stake_amount: %d upokt\nservice_ids:\n - %s", amount, serviceId)
// Prepare the config content based on the actor type
var configContent string
switch actorType {
case "application":
configContent = fmt.Sprintf("stake_amount: %d upokt\nservice_ids:\n - %s", amount, serviceId)
case "supplier":
configContent = fmt.Sprintf(`stake_amount: %dupokt
services:
- service_id: %s
endpoints:
- publicly_exposed_url: http://relayminer:8545
rpc_type: json_rpc`, amount, serviceId)
default:
s.Fatalf("unknown actor type %s", actorType)
}

// Write the config content to the file
_, err = configFile.Write([]byte(configContent))
require.NoError(s, err, "error writing config file %q", configFile.Name())

// Prepare the command arguments
args := []string{
"tx",
actorType,
Expand Down
28 changes: 28 additions & 0 deletions e2e/tests/stake_supplier.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: Stake Supplier Namespace

Scenario: User can stake a Supplier
Given the user has the pocketd binary installed
And the "supplier" for account "supplier2" is not staked
# Stake with 1 uPOKT more than the current stake used in genesis to make
# the transaction succeed.
And the account "supplier2" has a balance greater than "1000070" uPOKT
When the user stakes a "supplier" with "1000070" uPOKT for "anvil" service from the account "supplier2"
Then the user should be able to see standard output containing "txhash:"
And the user should be able to see standard output containing "code: 0"
And the pocketd binary should exit without error
# TODO_TECHDEBT(@Olshansk, @red-0ne): Replace these time-based waits with event listening waits
And the user should wait for "5" seconds
And the "supplier" for account "supplier2" is staked with "1000070" uPOKT
And the account balance of "supplier2" should be "1000070" uPOKT "less" than before

Scenario: User can unstake a Supplier
Given the user has the pocketd binary installed
And the "supplier" for account "supplier2" is staked with "1000070" uPOKT
And an account exists for "supplier2"
When the user unstakes a "supplier" from the account "supplier2"
Then the user should be able to see standard output containing "txhash:"
And the user should be able to see standard output containing "code: 0"
And the pocketd binary should exit without error
And the user should wait for "5" seconds
And the "supplier" for account "supplier2" is not staked
And the account balance of "supplier2" should be "1000070" uPOKT "more" than before
114 changes: 114 additions & 0 deletions localnet/grafana-dashboards/supplier_logs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 35,
"links": [],
"panels": [
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"gridPos": {
"h": 8,
"w": 18,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"editorMode": "code",
"expr": "{container=\"poktrolld-validator\"} | json | method = `StakeSupplier`",
"queryType": "range",
"refId": "Supplier Staking"
}
],
"title": "Supplier Staking",
"type": "logs"
},
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"gridPos": {
"h": 8,
"w": 18,
"x": 0,
"y": 8
},
"id": 3,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"editorMode": "code",
"expr": "{container=\"poktrolld-validator\"} | json | method = `UnstakeSupplier`",
"queryType": "range",
"refId": "Supplier Unstaking"
}
],
"title": "Supplier Unstaking",
"type": "logs"
}
],
"schemaVersion": 39,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "Protocol / Supplier Logs",
"uid": "supplier_logs",
"version": 7,
"weekStart": ""
}
Loading