Skip to content

Commit

Permalink
Merge pull request #1511 from area363/update-240315
Browse files Browse the repository at this point in the history
update internal chain test script
  • Loading branch information
area363 authored Mar 15, 2024
2 parents 45871c2 + f5d1af5 commit d909a00
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test-internal-chain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
limit:
required: true
description: 'Insert how many blocks from the mainnet to test (e.g. 100)'
delay_interval:
required: false
default: 0
description: 'Insert the delay interval(sec) when staging the mainnet txs to the internal network per block (default: 0)'

jobs:
test-internal-chain:
Expand All @@ -38,7 +42,9 @@ jobs:
- name: Test internal chain
run: |
python cli.py test-internal-chain ${{ github.event.inputs.network }} ${{ github.event.inputs.offset }} ${{ github.event.inputs.limit }}
python cli.py test-internal-chain ${{ github.event.inputs.network }} ${{ github.event.inputs.offset }} ${{ github.event.inputs.limit }} ${{ github.event.inputs.delay_interval }}
working-directory: ./scripts
env:
GITHUB_TOKEN: ${{ secrets.P_GITHUB_TOKEN }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
6 changes: 6 additions & 0 deletions scripts/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class Config(NamedTuple):
key_passphrase: Optional[str] = None
# signer key address
key_address: Optional[str] = None
# slack token
slack_token: Optional[str] = None
# slack channel
slack_channel: Optional[str] = None

@classmethod
def init(self):
Expand All @@ -26,6 +30,8 @@ def init(self):
for v in [
"KEY_PASSPHRASE",
"KEY_ADDRESS",
"SLACK_TOKEN",
"SLACK_CHANNEL"
]:
try:
setattr(self, v.lower(), os.environ[v])
Expand Down
14 changes: 11 additions & 3 deletions scripts/app/test_internal_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Network = "odin-internal"
Offset = 0
Limit = 10
Delay = 0

class InternalChainTester:
def __init__(self) -> None:
Expand All @@ -22,19 +23,20 @@ def test(
self,
network: Network,
offset: Offset,
limit: Limit
limit: Limit,
delay: Delay
):
# mainnet headless URL and initial setup
mainnet_headless = "odin-full-state.nine-chronicles.com"
internal_target_validator = "odin-internal-validator-5.nine-chronicles.com"
sleep_time = 5
sleep_time = delay
if network == "heimdall-internal":
mainnet_headless = "heimdall-full-state.nine-chronicles.com"
internal_target_validator = "heimdall-internal-validator-1.nine-chronicles.com"
sleep_time = 0
mainnet_headless_url = urljoin(f"http://{mainnet_headless}", "graphql")
target_validator_url = urljoin(f"http://{internal_target_validator}", "graphql")

original_offset = offset
tip_index = offset + limit
print(tip_index)

Expand Down Expand Up @@ -87,3 +89,9 @@ async def process_block(blocks):

# Increment the offset for the next query
offset += current_limit

if hasattr(config, 'slack_token') and config.slack_token:
url = f'https://planetariumhq.slack.com/services/hooks/slackbot?token={config.slack_token}&channel=%23{config.slack_channel}'
data = f"[9C-INFRA] Finished testing `{network}` network from `#{original_offset}` to `#{tip_index}`."
headers = {'Content-Type': 'text/plain'}
response = requests.post(url, data=data, headers=headers)
5 changes: 4 additions & 1 deletion scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ def test_internal_chain(
limit: int = typer.Argument(
...,
),
delay_interval: int = typer.Argument(
...,
),
):
"""
Run post deploy script
"""

InternalChainTester().test(network, offset, limit) # type:ignore
InternalChainTester().test(network, offset, limit, delay_interval) # type:ignore

@k8s_app.command()
def update_apv(
Expand Down

0 comments on commit d909a00

Please sign in to comment.