Skip to content

Commit

Permalink
Merge branch 'main' into dk-ollama
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Apr 29, 2024
2 parents f8b01ea + 1b08c30 commit 664ab9b
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 55 deletions.
72 changes: 37 additions & 35 deletions .github/workflows-helpers/run-e2e-test-job-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,44 @@ spec:
pokt.network/purpose: e2e-tests
spec:
containers:
- name: e2e-tests
image: ghcr.io/pokt-network/poktrolld:${IMAGE_TAG}
command: ["/bin/sh"]
args:
- "-c"
- |
poktrolld q gateway list-gateway --node=$POCKET_NODE && \
poktrolld q application list-application --node=$POCKET_NODE && \
poktrolld q supplier list-supplier --node=$POCKET_NODE && \
make acc_initialize_pubkeys && \
go test -v ./e2e/tests/... -tags=e2e
env:
- name: POCKET_NODE
value: tcp://${NAMESPACE}-validator-poktrolld:36657
- name: VALIDATOR_RPC_ENDPOINT
value: ${NAMESPACE}-validator-poktrolld:36657
- name: E2E_DEBUG_OUTPUT
value: "false" # Flip to true to see the command and result of the execution
- name: POKTROLLD_HOME
value: /root/.poktroll
- name: APPGATE_SERVER_URL
value: http://${NAMESPACE}-appgate-server:80
volumeMounts:
- mountPath: /root/.poktroll/keyring-test/
name: keys-volume
- mountPath: /root/.poktroll/config/
name: configs-volume
restartPolicy: Never
volumes:
- secret:
defaultMode: 420
secretName: keys-${IMAGE_TAG}
- name: e2e-tests
image: ghcr.io/pokt-network/poktrolld:${IMAGE_TAG}
command: ["/bin/sh"]
args:
- "-c"
- |
poktrolld q gateway list-gateway --node=$POCKET_NODE && \
poktrolld q application list-application --node=$POCKET_NODE && \
poktrolld q supplier list-supplier --node=$POCKET_NODE && \
make acc_initialize_pubkeys && \
go test -v ./e2e/tests/... -tags=e2e
env:
- name: POCKET_NODE
value: tcp://${NAMESPACE}-validator-poktrolld:36657
- name: VALIDATOR_RPC_ENDPOINT
value: ${NAMESPACE}-validator-poktrolld:36657
- name: E2E_DEBUG_OUTPUT
value: "false" # Flip to true to see the command and result of the execution
- name: POKTROLLD_HOME
value: /root/.poktroll
- name: APPGATE_SERVER_URL
value: http://${NAMESPACE}-appgate-server:80
- name: GATEWAY_URL
value: http://${NAMESPACE}-gateway:80
volumeMounts:
- mountPath: /root/.poktroll/keyring-test/
name: keys-volume
- configMap:
defaultMode: 420
name: configs-${IMAGE_TAG}
- mountPath: /root/.poktroll/config/
name: configs-volume
restartPolicy: Never
volumes:
- secret:
defaultMode: 420
secretName: keys-${IMAGE_TAG}
name: keys-volume
- configMap:
defaultMode: 420
name: configs-${IMAGE_TAG}
name: configs-volume
serviceAccountName: default
backoffLimit: 0
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SHELL = /bin/sh
POKTROLLD_HOME ?= ./localnet/poktrolld
POCKET_NODE ?= tcp://127.0.0.1:36657 # The pocket node (validator in the localnet context)
APPGATE_SERVER ?= http://localhost:42069
GATEWAY_URL ?= http://localhost:42079
POCKET_ADDR_PREFIX = pokt
CHAIN_ID = poktroll

Expand Down Expand Up @@ -322,6 +323,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 Expand Up @@ -467,7 +472,7 @@ gateway3_stake: ## Stake gateway3

.PHONY: gateway_unstake
gateway_unstake: ## Unstake an gateway (must specify the GATEWAY env var)
poktrolld --home=$(POKTROLLD_HOME) tx gateway unstake-gateway --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)
poktrolld --home=$(POKTROLLD_HOME) tx gateway unstake-gateway -y --keyring-backend test --from $(GATEWAY) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)

.PHONY: gateway1_unstake
gateway1_unstake: ## Unstake gateway1
Expand Down Expand Up @@ -507,7 +512,7 @@ app3_stake: ## Stake app3

.PHONY: app_unstake
app_unstake: ## Unstake an application (must specify the APP env var)
poktrolld --home=$(POKTROLLD_HOME) tx application unstake-application --keyring-backend test --from $(APP) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)
poktrolld --home=$(POKTROLLD_HOME) tx application unstake-application -y --keyring-backend test --from $(APP) --node $(POCKET_NODE) --chain-id $(CHAIN_ID)

.PHONY: app1_unstake
app1_unstake: ## Unstake app1
Expand Down
32 changes: 30 additions & 2 deletions e2e/tests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/pokt-network/poktroll/app"
"github.com/pokt-network/poktroll/testutil/testclient"
"github.com/pokt-network/poktroll/testutil/yaml"
apptypes "github.com/pokt-network/poktroll/x/application/types"
prooftypes "github.com/pokt-network/poktroll/x/proof/types"
sessiontypes "github.com/pokt-network/poktroll/x/session/types"
Expand Down Expand Up @@ -219,14 +220,16 @@ 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)
// Write the config content to the file
configContent := s.getConfigFileContent(amount, actorType, serviceId)
_, 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 All @@ -248,6 +251,31 @@ func (s *suite) TheUserStakesAWithUpoktForServiceFromTheAccount(actorType string
s.pocketd.result = res
}

func (s *suite) getConfigFileContent(amount int64, actorType, serviceId string) string {
var configContent string
switch actorType {
case "application":
configContent = fmt.Sprintf(`
stake_amount: %dupokt
service_ids:
- %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)
}
fmt.Println(yaml.NormalizeYAMLIndentation(configContent))
return yaml.NormalizeYAMLIndentation(configContent)
}

func (s *suite) TheUserUnstakesAFromTheAccount(actorType string, accName string) {
args := []string{
"tx",
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
28 changes: 28 additions & 0 deletions localnet/grafana-dashboards/cometbft.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@
"type": "dashboards",
"url": ""
},
{
"asDropdown": false,
"icon": "external link",
"includeVars": false,
"keepTime": false,
"tags": [
"gateway_logs"
],
"targetBlank": false,
"title": "Gateway Logs",
"tooltip": "",
"type": "dashboards",
"url": ""
},
{
"asDropdown": false,
"icon": "external link",
"includeVars": false,
"keepTime": false,
"tags": [
"supplier_logs"
],
"targetBlank": false,
"title": "Supplier Logs",
"tooltip": "",
"type": "dashboards",
"url": ""
},
{
"asDropdown": false,
"icon": "external link",
Expand Down
118 changes: 118 additions & 0 deletions localnet/grafana-dashboards/gateway_logs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"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": 30,
"links": [],
"panels": [
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"editorMode": "builder",
"expr": "{container=\"poktrolld-validator\"} | json | method = `StakeGateway`",
"queryType": "range",
"refId": "Gateway Staking"
}
],
"title": "Gateway Staking",
"type": "logs"
},
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"gridPos": {
"h": 10,
"w": 24,
"x": 0,
"y": 10
},
"id": 1,
"options": {
"dedupStrategy": "none",
"enableLogDetails": true,
"prettifyLogMessage": false,
"showCommonLabels": false,
"showLabels": false,
"showTime": false,
"sortOrder": "Descending",
"wrapLogMessage": false
},
"pluginVersion": "10.4.0",
"targets": [
{
"datasource": {
"type": "loki",
"uid": "P8E80F9AEF21F6940"
},
"editorMode": "code",
"expr": "{container=\"poktrolld-validator\"} | json | method = `UnstakeGateway`",
"queryType": "range",
"refId": "Gateway Unstaking"
}
],
"title": "Gateway Unstaking",
"type": "logs"
}
],
"refresh": "5s",
"schemaVersion": 39,
"tags": [
"gateway_logs"
],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"timepicker": {},
"timezone": "browser",
"title": "Protocol / Gateway Logs",
"uid": "gateway_logs",
"version": 2,
"weekStart": ""
}
Loading

0 comments on commit 664ab9b

Please sign in to comment.