INFRA-236 selectel cdn smoke tests

This commit is contained in:
anastasia prasolova 2020-11-30 13:33:05 +03:00
parent 1498089c1f
commit 0c4a035e22
9 changed files with 253 additions and 148 deletions

View file

@ -0,0 +1,41 @@
#!/usr/bin/python3
import logging
import os
import requests
from robot.api.deco import keyword
from robot.api import logger
import robot.errors
from robot.libraries.BuiltIn import BuiltIn
ROBOT_AUTO_KEYWORDS = False
if os.getenv('ROBOT_PROFILE') == 'selectel_smoke':
from selectelcdn_smoke_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT, HTTP_GATE)
else:
from neofs_int_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT, HTTP_GATE)
@keyword('Get via HTTP Gate')
def get_via_http_gate(cid: str, oid: str):
"""
This function gets given object from HTTP gate
:param cid: CID to get object from
:param oid: object OID
"""
resp = requests.get(f'{HTTP_GATE}/get/{cid}/{oid}')
if not resp.ok:
logger.info(f"""Failed to get object via HTTP gate:
request: {resp.request.path_url},
response: {resp.text},
status code: {resp.status_code} {resp.reason}""")
return
filename = os.path.curdir + f"/{cid}_{oid}"
with open(filename, "w+") as f:
f.write(resp.text)
return filename

View file

@ -9,10 +9,15 @@ import hashlib
from robot.api.deco import keyword
from robot.api import logger
if os.getenv('ROBOT_PROFILE') == 'selectel_smoke':
from selectelcdn_smoke_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT)
else:
from neofs_int_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT)
ROBOT_AUTO_KEYWORDS = False
NEOFS_ENDPOINT = "s01.neofs.devenv:8080"
CLI_PREFIX = ""
@keyword('Form WIF from String')
@ -230,7 +235,7 @@ def generate_file_of_bytes(size):
fout.write(os.urandom(size))
logger.info("Random binary file with size %s bytes has been generated." % str(size))
return filename
return os.path.abspath(os.getcwd()) + '/' + filename
@keyword('Search object')
@ -607,7 +612,6 @@ def get_range_hash(private_key: str, cid: str, oid: str, bearer_token: str, rang
except subprocess.CalledProcessError as e:
raise Exception("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
@keyword('Get object from NeoFS')
def get_object(private_key: str, cid: str, oid: str, bearer_token: str, read_object: str):

View file

@ -0,0 +1,9 @@
#!/usr/bin/python3
import os
NEOFS_ENDPOINT = "s01.neofs.devenv:8080"
NEOGO_CLI_PREFIX = "docker exec -it main_chain neo-go"
NEO_MAINNET_ENDPOINT = "main_chain.neofs.devenv:30333"
NEOFS_NEO_API_ENDPOINT = 'http://main_chain.neofs.devenv:30333'
HTTP_GATE = ''

View file

@ -4,15 +4,14 @@ import subprocess
import pexpect
import re
import uuid
import logging
import requests
import json
import os
from robot.api.deco import keyword
from robot.api import logger
import logging
import robot.errors
import requests
import json
from robot.libraries.BuiltIn import BuiltIn
from neocore.KeyPair import KeyPair
@ -20,11 +19,15 @@ from Crypto import Random
ROBOT_AUTO_KEYWORDS = False
if os.getenv('ROBOT_PROFILE') == 'selectel_smoke':
from selectelcdn_smoke_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT)
else:
from neofs_int_vars import (NEOGO_CLI_PREFIX, NEO_MAINNET_ENDPOINT,
NEOFS_NEO_API_ENDPOINT, NEOFS_ENDPOINT)
NEOFS_CONTRACT = "5f490fbd8010fd716754073ee960067d28549b7d"
NEOGO_CLI_PREFIX = "docker exec -it main_chain neo-go"
NEO_MAINNET_ENDPOINT = "main_chain.neofs.devenv:30333"
@keyword('Init wallet')
def init_wallet():
@ -80,10 +83,7 @@ def dump_privkey(wallet: str, address: str):
return out
@keyword('Transfer Mainnet Gas')
# docker cp wallets/wallet.json main_chain:/wallets/
def transfer_mainnet_gas(wallet: str, address: str, address_to: str, amount: int):
cmd = ( f"{NEOGO_CLI_PREFIX} wallet nep5 transfer -w {wallet} -r http://main_chain.neofs.devenv:30333 --from {address} "
f"--to {address_to} --token gas --amount {amount}" )
@ -98,8 +98,6 @@ def transfer_mainnet_gas(wallet: str, address: str, address_to: str, amount: int
return out
@keyword('Withdraw Mainnet Gas')
# docker cp wallets/wallet.json main_chain:/wallets/
def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int):
cmd = ( f"{NEOGO_CLI_PREFIX} contract invokefunction -w {wallet} -a {address} -r http://main_chain.neofs.devenv:30333 "
f"{NEOFS_CONTRACT} withdraw {scripthash} int:{amount} -- {scripthash}" )
@ -113,10 +111,6 @@ def withdraw_mainnet_gas(wallet: str, address: str, scripthash: str, amount: int
return out
# neo-go contract invokefunction -w wallets/deploy_wallet.json -a NTrezR3C4X8aMLVg7vozt5wguyNfFhwuFx -r http://main_chain.neofs.devenv:30333
# 5f490fbd8010fd716754073ee960067d28549b7d withdraw 12b97a2206ae4b10c7e0194b7b655c32cc912057 int:10 -- 12b97a2206ae4b10c7e0194b7b655c32cc912057
@keyword('Mainnet Balance')
def mainnet_balance(address: str):
request = 'curl -X POST '+NEO_MAINNET_ENDPOINT+' --cacert ca/nspcc-ca.pem -H \'Content-Type: application/json\' -d \'{ "jsonrpc": "2.0", "id": 5, "method": "getnep5balances", "params": [\"'+address+'\"] }\''
@ -145,21 +139,15 @@ def expected_mainnet_balance(address: str, expected: int):
raise Exception(f"Expected amount ({expected}) of GAS has not been found. Found {amount}.")
return True
# balance":[{"assethash":"668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","amount":"50"
#curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "getnep5balances", "params": ["NTrezR3C4X8aMLVg7vozt5wguyNfFhwuFx"] }' main_chain.neofs.devenv:30333
#{"id":1,"jsonrpc":"2.0","result":{"balance":[{"assethash":"668e0c1f9d7b70a99dd9e06eadd4c784d641afbc","amount":"9237.47595500","lastupdatedblock":158}],"address":"NTrezR3C4X8aMLVg7vozt5wguyNfFhwuFx"}}
@keyword('NeoFS Deposit')
def neofs_deposit(wallet: str, address: str, scripthash: str, amount: int):
def neofs_deposit(wallet: str, address: str, scripthash: str, amount: int, wallet_pass:str=''):
cmd = ( f"{NEOGO_CLI_PREFIX} contract invokefunction -w {wallet} -a {address} "
f"-r http://main_chain.neofs.devenv:30333 {NEOFS_CONTRACT} "
f"-r {NEOFS_NEO_API_ENDPOINT} {NEOFS_CONTRACT} "
f"deposit {scripthash} int:{amount} bytes: -- {scripthash}")
logger.info(f"Executing command: {cmd}")
out = run_sh_with_passwd('', cmd)
out = run_sh_with_passwd(wallet_pass, cmd)
logger.info(f"Command completed with output: {out}")
m = re.match(r'^Sent invocation transaction (\w{64})$', out)
@ -172,32 +160,6 @@ def neofs_deposit(wallet: str, address: str, scripthash: str, amount: int):
return tx
#docker exec -it main_chain \
# neo-go contract invokefunction \
# -w wallets/wallet.json \
# -a NTrezR3C4X8aMLVg7vozt5wguyNfFhwuFx \
# -r http://main_chain.${LOCAL_DOMAIN}:30333 \
# ${NEOFS_CONTRACT_MAINCHAIN} \
# deposit \
# 12b97a2206ae4b10c7e0194b7b655c32cc912057 \
# int:500 \
# bytes: \
# -- 12b97a2206ae4b10c7e0194b7b655c32cc912057
#neo-go contract invokefunction -w wallets/wallet.json -a NTrezR3C4X8aMLVg7vozt5wguyNfFhwuFx
#-r <http://main_chain.neofs.devenv:30333> af5dc5f7e6a6efc64d679098f328027591a2e518
#deposit 12b97a2206ae4b10c7e0194b7b655c32cc912057 int:60 bytes: --
#12b97a2206ae4b10c7e0194b7b655c32cc912057
# wallet nep5 transfer -w wallets/wallet.json -r http://main_chain.neofs.devenv:30333 --from NTrezR3C4X8aMLVg7vozt5wguyNfFhwuFx
# --to NULwe3UAHckN2fzNdcVg31tDiaYtMDwANt --token gas --amount 50
@keyword('Transaction accepted in block')
def transaction_accepted_in_block(tx_id):
"""
@ -209,14 +171,10 @@ def transaction_accepted_in_block(tx_id):
logger.info("Transaction id: %s" % tx_id)
# curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "getnep5transfers", "params": ["NULwe3UAHckN2fzNdcVg31tDiaYtMDwANt"] }' main_chain.neofs.devenv:30333
TX_request = 'curl -X POST '+NEO_MAINNET_ENDPOINT+' --cacert ca/nspcc-ca.pem -H \'Content-Type: application/json\' -d \'{ "jsonrpc": "2.0", "id": 5, "method": "gettransactionheight", "params": [\"'+ tx_id +'\"] }\''
logger.info(f"Executing command: {TX_request}")
complProc = subprocess.run(TX_request, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True)
logger.info(complProc.stdout)
@ -228,7 +186,6 @@ def transaction_accepted_in_block(tx_id):
logger.info("Transaction has been found in the block %s." % response['result'] )
return response['result']
@keyword('Get Transaction')
def get_transaction(tx_id: str):
"""
@ -242,15 +199,6 @@ def get_transaction(tx_id: str):
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=15, shell=True)
logger.info(complProc.stdout)
def run_sh(args):
complProc = subprocess.run(args, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
@ -301,13 +249,6 @@ def run_sh_with_passwd(passwd, cmd):
logger.info("Output: %s" % output)
#from subprocess import Popen, PIPE
#p = Popen(['python test_enter.py'], stdin=PIPE, shell=True)
#p.communicate(input='\n')
@keyword('Request NeoFS Deposit')
def request_neofs_deposit(public_key: str):
"""
@ -354,12 +295,11 @@ def expected_balance(privkey: str, init_amount: float, deposit_size: float):
return deposit_change
def _get_balance_request(privkey: str):
'''
Internal method.
'''
Cmd = f'neofs-cli --key {privkey} --rpc-endpoint s01.neofs.devenv:8080 accounting balance'
Cmd = f'neofs-cli --key {privkey} --rpc-endpoint {NEOFS_ENDPOINT} accounting balance'
logger.info("Cmd: %s" % Cmd)
complProc = subprocess.run(Cmd, check=True, universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=150, shell=True)
@ -375,12 +315,3 @@ def _get_balance_request(privkey: str):
logger.info("Balance for '%s' is '%s'" % (privkey, balance) )
return balance
# {"id":5,"jsonrpc":"2.0","result":{"txid":"0x02c178803258a9dbbcce80acfece2f6abb4f51c122e7ce2ddcad332d6a810e5f","trigger":"Application",
# !!!!!!!!!!!
#"vmstate":"FAULT"
# !!!!!!!!!!!
#,"gasconsumed":"11328110","stack":[],"notifications":[]}}

View file

@ -0,0 +1,9 @@
#!/usr/bin/python3
NEOFS_ENDPOINT = "92.53.71.51:18080"
NEOGO_CLI_PREFIX = "neo-go"
NEO_MAINNET_ENDPOINT = "http://92.53.71.51:20332"
# selectel main chain on lobachevsky-1
NEOFS_NEO_API_ENDPOINT = "http://92.53.71.51:20332"
HTTP_GATE = 'http://92.53.71.51:38080'

View file

@ -0,0 +1,33 @@
# -*- coding: robot -*-
*** Settings ***
Variables ../../variables/common.py
Variables ../../variables/selectelcdn_smoke.py
Library ${RESOURCES}/neofs.py
Library ${RESOURCES}/payment_neogo.py
Library ${RESOURCES}/gates.py
*** Test cases ***
NeoFS Storage Smoke
[Documentation] Creates container and does PUT, GET and LIST on it via CLI and via HTTP Gate
[Timeout] 5 min
${TX_DEPOSIT} = NeoFS Deposit ${WALLET} ${ADDR} ${SCRIPT_HASH} 50 one
Wait Until Keyword Succeeds 1 min 15 sec
... Transaction accepted in block ${TX_DEPOSIT}
Get Transaction ${TX_DEPOSIT}
${CID} = Create container ${PRIV_KEY} public
Wait Until Keyword Succeeds 2 min 30 sec
... Container Existing ${PRIV_KEY} ${CID}
${FILE} = Generate file of bytes 1024
${S_OID} = Put object to NeoFS ${PRIV_KEY} ${FILE} ${CID} ${EMPTY} ${EMPTY}
Get object from NeoFS ${PRIV_KEY} ${CID} ${S_OID} ${EMPTY} s_file_read
${FILEPATH} = Get via HTTP Gate ${CID} ${S_OID}

View file

@ -12,8 +12,6 @@ ABSOLUTE_FILE_PATH="/robot/testsuites/integration"
JF_TOKEN = os.getenv('JF_TOKEN')
REG_USR = os.getenv('REG_USR')
REG_PWD = os.getenv('REG_PWD')
NEOFS_ENDPOINT = "s01.fs.localtest.nspcc.ru:8080"
NEOFS_NEO_API_ENDPOINT = "https://fs.localtest.nspcc.ru/neo_rpc/"
MORPH_BLOCK_TIMEOUT = "10sec"
NEOFS_EPOCH_TIMEOUT = "30sec"

View file

@ -0,0 +1,8 @@
#!/usr/bin/python3
# wallet that has assets in selectel mainnet
WALLET = 'wallets/selectel_mainnet_wallet.json'
# address from this wallet anf its representations
ADDR = 'NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc'
SCRIPT_HASH = 'eb88a496178256213f674eb302e44f9d85cf8aaa'
PRIV_KEY = 'KxyjQ8eUa4FHt3Gvioyt1Wz29cTUrE4eTqX3yFSk1YFCsPL8uNsY'

View file

@ -0,0 +1,72 @@
{
"version": "3.0",
"accounts": [
{
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
"label": "",
"contract": {
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
"parameters": [
{
"name": "parameter0",
"type": "Signature"
}
],
"deployed": false
},
"lock": false,
"isdefault": false
},
{
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
"label": "",
"contract": {
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
"parameters": [
{
"name": "parameter0",
"type": "Signature"
},
{
"name": "parameter1",
"type": "Signature"
},
{
"name": "parameter2",
"type": "Signature"
}
],
"deployed": false
},
"lock": false,
"isdefault": false
},
{
"address": "NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK",
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
"label": "",
"contract": {
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEQtBE43vrw==",
"parameters": [
{
"name": "parameter0",
"type": "Signature"
}
],
"deployed": false
},
"lock": false,
"isdefault": false
}
],
"scrypt": {
"n": 16384,
"r": 8,
"p": 8
},
"extra": {
"Tokens": null
}
}