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

ci: Execute interactive installer test [DEV-1944] #460

Merged
merged 157 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
ba1e524
remove configureCmd
benyam7 Nov 16, 2022
bf88839
remove post_install method from installer.py
benyam7 Nov 16, 2022
5814e4c
remove add-observer.sh from upgrade/cosmovisor
benyam7 Nov 16, 2022
e945df9
remove add-observer.sh from interactive-install
benyam7 Nov 16, 2022
9808070
remove post_install method usage
benyam7 Nov 17, 2022
8a7e3ad
Merge branch 'develop' into remove-configure-cmd
askolesov Nov 17, 2022
9e09598
keep post_install method empty
benyam7 Nov 17, 2022
d31e86e
Merge branch 'remove-configure-cmd' of github.com:cheqd/cheqd-node in…
benyam7 Nov 17, 2022
b88b038
Merge branch 'develop' into remove-configure-cmd
askolesov Nov 17, 2022
5ee5c71
Merge branch 'develop' into remove-configure-cmd
benyam7 Dec 1, 2022
8997cba
Merge branch 'develop' into remove-configure-cmd
ankurdotb Dec 1, 2022
e741cc4
Update config.toml and app.toml defaults
ankurdotb Dec 1, 2022
2c83eac
Bump alpine image version to latest
ankurdotb Dec 1, 2022
568d43d
Update default persistent flags
ankurdotb Dec 1, 2022
53c1b5c
Set --gas flag correctly
ankurdotb Dec 1, 2022
6a4d3e9
Delete legacy interactive test folder
ankurdotb Dec 2, 2022
daec57a
Add installer test to workflow
ankurdotb Dec 2, 2022
5252018
Merge branch 'develop' into remove-configure-cmd
ankurdotb Dec 2, 2022
a83c457
Update package-lock.json
ankurdotb Dec 2, 2022
b02b229
Fix workflow syntax error in interactive-installer job
ankurdotb Dec 2, 2022
6c8481a
add questionary to bump cosmovisor
benyam7 Dec 2, 2022
f2e481c
move bump logic to setup_cosmovisor
benyam7 Dec 2, 2022
b1ec9c3
Check for success
ankurdotb Dec 2, 2022
75f60ed
Change existing install check
ankurdotb Dec 2, 2022
dea5ab2
Update existing installation check
ankurdotb Dec 2, 2022
af50f09
Merge branch 'develop' into remove-configure-cmd
ankurdotb Dec 2, 2022
49af690
Update installer check
ankurdotb Dec 2, 2022
cf902cd
Fix linter issue
ankurdotb Dec 2, 2022
00666a9
Update test.yml
ankurdotb Dec 2, 2022
088c9ba
Fix linter error
ankurdotb Dec 2, 2022
f4c2e93
Update test.yml
ankurdotb Dec 2, 2022
e75f77c
Merge branch 'develop' into remove-configure-cmd
ankurdotb Dec 3, 2022
960a1f9
Debugging installer flow
ankurdotb Dec 3, 2022
997c67d
Update build.yml
ankurdotb Dec 3, 2022
69c645b
Set up tmate on failure
ankurdotb Dec 3, 2022
7af692b
Try Andrew's technique
ankurdotb Dec 3, 2022
5dba0f0
Change home path
ankurdotb Dec 3, 2022
0ea42af
Fix home path
ankurdotb Dec 3, 2022
a334ceb
Merge branch 'develop' into bump-cosmovisor
ankurdotb Dec 5, 2022
4372daa
Merge branch 'develop' into remove-configure-cmd
ankurdotb Dec 5, 2022
22adf96
Update installer.py
ankurdotb Dec 6, 2022
3e98cb3
auto detect os arch for cosmovisor binary
benyam7 Dec 6, 2022
fb4cae0
set default bump cosmovisor to yes
benyam7 Dec 6, 2022
99bc5e7
set correct OS arch
benyam7 Dec 6, 2022
084522a
keep first install steps only in setup_cosmovisor
benyam7 Dec 6, 2022
13a7997
set cosmovisor ENV vars
benyam7 Dec 6, 2022
d85bde1
remove sudo from export
benyam7 Dec 6, 2022
22721f6
write to .profile using python
benyam7 Dec 6, 2022
3d33e0e
Move filesx
ankurdotb Dec 6, 2022
b4ae27b
fix path to .profile
benyam7 Dec 6, 2022
e217c49
log cosmovisor version when upgrade
benyam7 Dec 6, 2022
fee4de6
update .profile for current session
benyam7 Dec 6, 2022
62f61aa
exec source ~/.profile without stdout
benyam7 Dec 6, 2022
4670ecb
add execute permission
benyam7 Dec 6, 2022
f389faa
Update installer.py
ankurdotb Dec 6, 2022
7acbf37
add try/except
benyam7 Dec 6, 2022
2360288
get version anyway
benyam7 Dec 6, 2022
b7b9594
suppress err in bash
benyam7 Dec 6, 2022
04ece90
add new line
benyam7 Dec 6, 2022
c7c610c
Delete outdated Cosmovisor check
ankurdotb Dec 6, 2022
a962cde
Create answers.txt
ankurdotb Dec 6, 2022
eaafcda
Disable tmate
ankurdotb Dec 6, 2022
03dd8b1
use v1.2.0 instead
benyam7 Dec 7, 2022
8565ca1
try appending to .bashrc
benyam7 Dec 7, 2022
96fd6ff
try with os.environ
benyam7 Dec 7, 2022
28fbab0
compare version and ask for bump
benyam7 Dec 7, 2022
dc353ef
rename function
benyam7 Dec 7, 2022
4a63042
suppress error
benyam7 Dec 7, 2022
4274cff
wrap std output in triple quotes
benyam7 Dec 7, 2022
3b86371
add logs
benyam7 Dec 7, 2022
3599052
fix getting current version
benyam7 Dec 7, 2022
271eb00
handle edge case
benyam7 Dec 7, 2022
70b091f
add more info
benyam7 Dec 7, 2022
fda1a8b
fix typo
benyam7 Dec 7, 2022
8dc2d98
remove logs
benyam7 Dec 7, 2022
dc6ab93
semantics
benyam7 Dec 7, 2022
9556ef5
add bump logic
benyam7 Dec 7, 2022
6fd6be4
avoid fresh install during upgrade
benyam7 Dec 7, 2022
602414d
Debug only
ankurdotb Dec 7, 2022
1a6cb27
Update build.yml
ankurdotb Dec 7, 2022
b08ebd9
move new binary to installation directory
benyam7 Dec 7, 2022
6c2fd48
try cosmovisor init
benyam7 Dec 7, 2022
bdd10cd
extract to methods
benyam7 Dec 7, 2022
91ddfcd
set ENV vars right after cosmovisor install
benyam7 Dec 7, 2022
8d581f6
edit upgrade steps
benyam7 Dec 7, 2022
113a664
add logs
benyam7 Dec 7, 2022
c4b2e33
keep only interview logic at ask
benyam7 Dec 7, 2022
73daee4
add fixes
benyam7 Dec 7, 2022
5c6ed0d
move info log
benyam7 Dec 7, 2022
d89a7d9
minor fix
benyam7 Dec 7, 2022
430dae2
stop and reload cosmovisor systemd during bump
benyam7 Dec 7, 2022
1c59fcf
fix fresh install
benyam7 Dec 7, 2022
211fc69
add logs
benyam7 Dec 7, 2022
8755ef5
more logs
benyam7 Dec 7, 2022
be8dded
more log
benyam7 Dec 7, 2022
db0d768
logs
benyam7 Dec 7, 2022
502f3d2
more logs
benyam7 Dec 7, 2022
2f8f93d
add try except
benyam7 Dec 7, 2022
709bea6
logs
benyam7 Dec 7, 2022
5d8a225
fix
benyam7 Dec 7, 2022
a7646ce
logs
benyam7 Dec 7, 2022
1416a46
logs
benyam7 Dec 7, 2022
4776980
logs
benyam7 Dec 7, 2022
ef1f4ec
logs
benyam7 Dec 7, 2022
2b0f8b8
logs
benyam7 Dec 7, 2022
548d039
fix
benyam7 Dec 7, 2022
c63618a
fix
benyam7 Dec 7, 2022
4d9c351
fix env var check
benyam7 Dec 7, 2022
31c53d5
Merge branch 'develop' into bump-cosmovisor
ankurdotb Dec 7, 2022
5ce2ffe
remove unused function
benyam7 Dec 12, 2022
7ae80b6
Merge branch 'bump-cosmovisor' of https://github.com/cheqd/cheqd-node…
benyam7 Dec 12, 2022
756103a
move getting cosmovisor download url to its own function
benyam7 Dec 12, 2022
77de20c
check if .bashrc is writable or not
benyam7 Dec 12, 2022
3d7122f
fix syntax issues
benyam7 Dec 12, 2022
932adcb
Merge branch 'develop' into bump-cosmovisor
benyam7 Dec 12, 2022
5148126
change ~ ownership to cheqd
benyam7 Dec 12, 2022
5050157
Merge branch 'bump-cosmovisor' of https://github.com/cheqd/cheqd-node…
benyam7 Dec 12, 2022
6ba738f
fix quotes syntax
benyam7 Dec 12, 2022
95de8a4
temporarily disable editing current user .bashrc
benyam7 Dec 12, 2022
d1f5746
remove is_file_writable
benyam7 Dec 12, 2022
b037d90
write to file and read version for it
benyam7 Dec 12, 2022
9e21959
remove using os
benyam7 Dec 12, 2022
4c511eb
add logs
benyam7 Dec 12, 2022
709bc66
use tee
benyam7 Dec 12, 2022
1ada418
remove debug logs
benyam7 Dec 12, 2022
83a9f07
Merge branch 'main' into bump-cosmovisor
ankurdotb Dec 13, 2022
b083d28
write to bashrc python way
benyam7 Dec 13, 2022
359e365
Merge branch 'bump-cosmovisor' of https://github.com/cheqd/cheqd-node…
benyam7 Dec 13, 2022
350cd55
add fix
benyam7 Dec 13, 2022
6947d28
update installer.py
filipdjokic Dec 13, 2022
21fd055
Merge branch 'bump-cosmovisor' of github.com:cheqd/cheqd-node into bu…
filipdjokic Dec 13, 2022
31bb5ff
Check default shell
filipdjokic Dec 13, 2022
beeb179
Merge branch 'main' into remove-configure-cmd
ankurdotb Dec 13, 2022
05c17c4
Merge branch 'main' into bump-cosmovisor
ankurdotb Dec 13, 2022
58e9b4e
extract download and unzip to its own method
benyam7 Dec 14, 2022
4f6c773
reuse download_and_unzip
benyam7 Dec 14, 2022
3d599de
add logs
benyam7 Dec 14, 2022
98a2ea4
revert changes
benyam7 Dec 14, 2022
f33cb41
fix wrap in directory issue for versions lower than 1.0.1
benyam7 Dec 14, 2022
3f09bc6
Merge branch 'main' into bump-cosmovisor
ankurdotb Dec 14, 2022
e03b6f8
Merge branch 'bump-cosmovisor' into remove-configure-cmd
ankurdotb Dec 15, 2022
71b4833
Update build.yml
ankurdotb Dec 15, 2022
23fd6e2
First we should check all existing different OS release,
Dec 15, 2022
708f56f
Add cosmovisor path to default PATH
Dec 15, 2022
7936cbf
Remove previous commit code
Dec 15, 2022
cad1ca6
Merge branch 'develop' into remove-configure-cmd
abdulla-ashurov Dec 15, 2022
2040420
Reverse code
Dec 15, 2022
4a378cc
Change runner from ubuntu-latest to ubuntu-20.04
Dec 15, 2022
d154b9f
Fix linter mistakes
Dec 15, 2022
29c97a1
Reset to version in develop
ankurdotb Dec 15, 2022
d77df2c
Reset more correctly to develop branch
ankurdotb Dec 15, 2022
6723b06
Fix merge errors
ankurdotb Dec 15, 2022
eb18edb
Delete Dockerfile approach
ankurdotb Dec 15, 2022
f2ddc92
Move installer test to test pipeline
ankurdotb Dec 15, 2022
77f3fe0
Rename to install from scratch
ankurdotb Dec 15, 2022
b36b9db
Create upgrade-existing.txt
ankurdotb Dec 15, 2022
ac209b2
Add upgrade path test
ankurdotb Dec 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ permissions:

jobs:

interactive-installer:
name: "Interactive Installer"
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3

- name: "Fresh install"
working-directory: ./installer
run: |
sudo bash -c "python3 installer.py < install-from-scratch.txt"

- name: "Upgrade existing installation"
working-directory: ./installer
run: |
sudo bash -c "python3 installer.py < upgrade-existing.txt"

- name: Debugging with tmate
if: ${{ failure() }}
uses: mxschmitt/[email protected]
with:
timeout-minutes: 15

unit-tests:
name: "Unit Tests"
runs-on: ubuntu-20.04
Expand Down
14 changes: 14 additions & 0 deletions installer/install-from-scratch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
2
/home/runner/.local/cheqd
yes
mainnet
yes
no
test-install
1.1.1.1
27657
27656
100ncheq
[email protected]:26656,[email protected]:26656
debug
plain
95 changes: 51 additions & 44 deletions installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import signal
import platform
import copy
import re
import shutil


###############################################################
### Installer defaults ###
Expand Down Expand Up @@ -77,8 +80,9 @@
DEFAULT_LOG_LEVEL = "error"
DEFAULT_LOG_FORMAT = "json"

def sigint_handler(signal, frame):
print ('Exiting from cheqd-node installer')

def sigint_handler (signal, frame):
print('Exiting from cheqd-node installer')
sys.exit(0)

signal.signal(signal.SIGINT, sigint_handler)
Expand All @@ -92,8 +96,7 @@ def search_and_replace(search_text, replace_text, file_path):
data = file.read()
data = data.replace(line, replace_text)
with open(file_path, 'w') as file:
file.write(data)

file.write(data)
file.close()

class Release:
Expand All @@ -109,10 +112,11 @@ def get_release_url(self):
os_name = platform.system()
for _url_item in self.assets:
_url = _url_item["browser_download_url"]
version_without_v_prefix = self.version.replace('v','',1)
version_without_v_prefix = self.version.replace('v', '' ,1)
if os.path.basename(_url) == f"cheqd-noded-{version_without_v_prefix}-{os_name}-{os_arch}.tar.gz" or \
os.path.basename(_url) == "cheqd-noded":
return _url
return _url

else:
failure_exit(f"No asset found to download for release: {self.version}")
except:
Expand Down Expand Up @@ -182,7 +186,7 @@ def cosmovisor_service_cfg(self):
f.read()
)
self.remove_safe(fname)
return s
return s

@property
def logrotate_cfg(self):
Expand All @@ -203,9 +207,9 @@ def rsyslog_cfg(self):
fname = os.path.basename(RSYSLOG_TEMPLATE)
self.exec(f"wget -c {RSYSLOG_TEMPLATE}")
with open(fname) as f:
s =re.sub(
s = re.sub(
r'({BINARY_FOR_LOGGING}|{CHEQD_LOG_DIR})',
lambda m:{'{BINARY_FOR_LOGGING}': binary_name,
lambda m: {'{BINARY_FOR_LOGGING}': binary_name,
'{CHEQD_LOG_DIR}': self.cheqd_log_dir}[m.group()],
f.read()
)
Expand Down Expand Up @@ -263,7 +267,10 @@ def get_binary(self):
try:
self.exec(f"wget -c {binary_url}")
if fname.find(".tar.gz") != -1:
self.exec(f"tar -xzf {fname} -C . --strip-components=1")
if self.version.replace('v', '') >= '1.0.1':
self.exec(f"tar -xzf {fname} -C .")
else:
self.exec(f"tar -xzf {fname} -C . --strip-components=1")
self.remove_safe(fname)
self.exec(f"chmod +x {DEFAULT_BINARY_NAME}")
except:
Expand All @@ -277,15 +284,13 @@ def is_user_exists(self, username) -> bool:
except KeyError:
self.log(f"User {username} does not exist")
return False


def remove_safe(self, path, is_dir=False):
if is_dir and os.path.exists(path):
shutil.rmtree(path)
if os.path.exists(path):
os.remove(path)


def pre_install(self):
if self.interviewer.is_from_scratch:
self.log("Removing user's data and configs")
Expand Down Expand Up @@ -432,23 +437,23 @@ def install(self):
def post_install(self):
# Init the node with provided moniker
if not os.path.exists(os.path.join(self.cheqd_config_dir, 'genesis.json')):
self.exec(f"""sudo su -c 'cheqd-noded init "{self.interviewer.moniker}"' {DEFAULT_CHEQD_USER}""")
self.exec(f"""sudo su -c 'cheqd-noded init {self.interviewer.moniker}' {DEFAULT_CHEQD_USER}""")

# Downloading genesis file
self.exec(f"curl {GENESIS_FILE.format(self.interviewer.chain)} > {os.path.join(self.cheqd_config_dir, 'genesis.json')}")
shutil.chown(os.path.join(self.cheqd_config_dir, 'genesis.json'),
DEFAULT_CHEQD_USER,
DEFAULT_CHEQD_USER)

# Replace the default RCP port to listen to anyone
rpc_default_value= 'laddr = "tcp://127.0.0.1:{}"'.format(DEFAULT_RPC_PORT)
new_rpc_default_value = 'laddr = "tcp://0.0.0.0:{}"'.format(DEFAULT_RPC_PORT)
search_and_replace(rpc_default_value,new_rpc_default_value, os.path.join(self.cheqd_config_dir, "config.toml"))
search_and_replace(rpc_default_value, new_rpc_default_value, os.path.join(self.cheqd_config_dir, "config.toml"))

# Set create empty blocks to false by default
create_empty_blocks_search_text = 'create_empty_blocks = true'
create_empty_blocks_replace_text = 'create_empty_blocks = false'
search_and_replace(create_empty_blocks_search_text,create_empty_blocks_replace_text, os.path.join(self.cheqd_config_dir, "config.toml"))
search_and_replace(create_empty_blocks_search_text, create_empty_blocks_replace_text, os.path.join(self.cheqd_config_dir, "config.toml"))

# Setting up the external_address
if self.interviewer.external_address:
Expand All @@ -461,7 +466,7 @@ def post_install(self):
seeds_search_text = 'seeds = ""'
seeds_replace_text= 'seeds = "{}"'.format(seeds)
search_and_replace(seeds_search_text, seeds_replace_text, os.path.join(self.cheqd_config_dir, "config.toml"))

# Setting up the RPC port
if self.interviewer.rpc_port:
rpc_laddr_search_text= 'laddr = "tcp://0.0.0.0:{}"'.format(DEFAULT_RPC_PORT)
Expand All @@ -471,20 +476,20 @@ def post_install(self):
if self.interviewer.p2p_port:
p2p_laddr_search_text='laddr = "tcp://0.0.0.0:{}"'.format(DEFAULT_P2P_PORT)
p2p_laddr_replace_text='laddr = "tcp://0.0.0.0:{}"'.format(self.interviewer.p2p_port)
search_and_replace(p2p_laddr_search_text,p2p_laddr_replace_text, os.path.join(self.cheqd_config_dir, "config.toml"))
search_and_replace(p2p_laddr_search_text, p2p_laddr_replace_text, os.path.join(self.cheqd_config_dir, "config.toml"))

# Setting up min gas-price
if self.interviewer.gas_price:
min_gas_price_search_text='minimum-gas-prices = '
min_gas_price_replace_text = 'minimum-gas-prices = "{}"'.format(self.interviewer.gas_price)
search_and_replace(min_gas_price_search_text, min_gas_price_replace_text, os.path.join(self.cheqd_config_dir, "app.toml"))

# Setting up persistent peers
if self.interviewer.persistent_peers:
persistent_peers_search_text='persistent_peers = ""'
persistent_peers_replace_text='persistent_peers = "{}"'.format(self.interviewer.persistent_peers)
search_and_replace(persistent_peers_search_text,persistent_peers_replace_text, os.path.join(self.cheqd_config_dir, "config.toml"))
search_and_replace(persistent_peers_search_text, persistent_peers_replace_text, os.path.join(self.cheqd_config_dir, "config.toml"))

# Setting up log level
if self.interviewer.log_level:
log_level_search_text = 'log_level'
Expand Down Expand Up @@ -542,10 +547,12 @@ def setup_cosmovisor(self):
self.remove_safe("CHANGELOG.md")
self.remove_safe("README.md")
self.remove_safe("LICENSE")

self.mkdir_p(self.cosmovisor_root_dir)
self.mkdir_p(os.path.join(self.cosmovisor_root_dir, "genesis"))
self.mkdir_p(os.path.join(self.cosmovisor_root_dir, "genesis/bin"))
self.mkdir_p(os.path.join(self.cosmovisor_root_dir, "upgrades"))

if not os.path.exists(os.path.join(DEFAULT_INSTALL_PATH, DEFAULT_COSMOVISOR_BINARY_NAME)):
self.log(f"Moving Cosmovisor binary to installation directory")
shutil.move("./cosmovisor", DEFAULT_INSTALL_PATH)
Expand Down Expand Up @@ -573,7 +580,7 @@ def setup_cosmovisor(self):
os.path.join(self.cosmovisor_root_dir, "current"))
self.log(f"Changing owner to {DEFAULT_CHEQD_USER} user")
self.exec(f"chown -R {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER} {self.cosmovisor_root_dir}")

self.log(f"Changing directory ownership for Cosmovisor to {DEFAULT_CHEQD_USER} user")
self.exec(f"chown -R {DEFAULT_CHEQD_USER}:{DEFAULT_CHEQD_USER} {self.cosmovisor_root_dir}")
except:
Expand Down Expand Up @@ -623,12 +630,12 @@ def download_snapshot(self):
self.log(f"Snapshot download was successful but checksums do not match.")
failure_exit(f"Snapshot download was successful but checksums do not match.")
elif int(archive_size) > int(free_disk_space):
failure_exit (f"Snapshot archive is too large to fit in free disk space. Please free up some space and try again.")
failure_exit(f"Snapshot archive is too large to fit in free disk space. Please free up some space and try again.")
else:
failure_exit (f"Error encountered when downloading snapshot archive.")
failure_exit(f"Error encountered when downloading snapshot archive.")
except:
failure_exit(f"Failed to download snapshot")

def untar_from_snapshot(self):
try:
archive_path = os.path.join(self.cheqd_root_dir, os.path.basename(self.interviewer.snapshot_url))
Expand All @@ -638,7 +645,7 @@ def untar_from_snapshot(self):

# Extract to cheqd node data directory EXCEPT for validator state
self.exec(f"sudo su -c 'pv {archive_path} | tar --use-compress-program=lz4 -xf - -C {self.cheqd_root_dir} --exclude priv_validator_state.json' {DEFAULT_CHEQD_USER}")

# Delete snapshot archive file
self.log(f"Snapshot extraction was successful. Deleting snapshot archive.")
self.remove_safe(archive_path)
Expand All @@ -655,8 +662,8 @@ def untar_from_snapshot(self):
failure_exit(f"Failed to extract snapshot")

def print_success(self):
self.log("The cheqd-noded has been successfully installed")
self.log("The cheqd-noded binary has been successfully installed")


class Interviewer:
def __init__(self,
Expand Down Expand Up @@ -688,7 +695,6 @@ def __init__(self,
def cheqd_root_dir(self):
return os.path.join(self.home_dir, ".cheqdnode")


@property
def cheqd_config_dir(self):
return os.path.join(self.cheqd_root_dir, "config")
Expand Down Expand Up @@ -764,15 +770,15 @@ def p2p_port(self) -> str:
@property
def gas_price(self) -> str:
return self._gas_price

@property
def persistent_peers(self) -> str:
return self._persistent_peers

@property
def log_level(self) -> str:
return self._log_level

@property
def log_format(self) -> str:
return self._log_format
Expand Down Expand Up @@ -844,11 +850,11 @@ def p2p_port(self, p2p_port):
@gas_price.setter
def gas_price(self, gas_price):
self._gas_price = gas_price

@persistent_peers.setter
def persistent_peers(self, persistent_peers):
self._persistent_peers = persistent_peers

@log_level.setter
def log_level(self, log_level):
self._log_level = log_level
Expand Down Expand Up @@ -918,7 +924,7 @@ def ask_for_version(self):
all_releases.insert(0, default)
for i, release in enumerate(all_releases[0: LAST_N_RELEASES]):
print(f"{i + 1}) {release.version}")
release_num = int(self.ask("Choose list option number above to select version of cheqd-node to install",
release_num = int(self.ask("Choose list option number above to select version of cheqd-node to install",
default=1))
if release_num >= 1 and release_num <= len(all_releases):
self.release = all_releases[release_num - 1]
Expand Down Expand Up @@ -1061,14 +1067,14 @@ def ask_for_persistent_peers(self):
f"INFO: Persistent peers are nodes that you want to always keep connected to. "
f"Values for persistent peers should be specified in format: <nodeID>@<IP>:<port>,<nodeID>@<IP>:<port>... "
f"Specify persistent peers [default: none]: {os.linesep}")

def ask_for_log_level(self):
self.log_level = self.ask(
f"Specify log level (error | info | debug)", default=DEFAULT_LOG_LEVEL)
f"Specify log level (trace|debug|info|warn|error|fatal|panic)", default=DEFAULT_LOG_LEVEL)

def ask_for_log_format(self):
self.log_format = self.ask(
f"Specify log format (plain | json)", default=DEFAULT_LOG_FORMAT)
f"Specify log format (json|plain)", default=DEFAULT_LOG_FORMAT)

def prepare_url_for_latest(self) -> str:
template = TESTNET_SNAPSHOT if self.chain == "testnet" else MAINNET_SNAPSHOT
Expand All @@ -1094,8 +1100,9 @@ def is_url_exists(self, url):
self.verbose = curr_verbose
return False


if __name__ == '__main__':

# Steps to execute if installing from scratch
def install_steps():
interviewer.ask_for_setup()
Expand All @@ -1121,15 +1128,15 @@ def upgrade_steps():
interviewer.ask_for_rewrite_rsyslog()
if os.path.exists(DEFAULT_LOGROTATE_FILE):
interviewer.ask_for_rewrite_logrotate()

# Ask user for information
interviewer = Interviewer()
interviewer.ask_for_version()
interviewer.ask_for_home_directory(default=DEFAULT_HOME)

# Check if cheqd configuration directory exists
is_installed = interviewer.is_already_installed()

# First-time new node setup
if is_installed is False:
install_steps()
Expand Down
7 changes: 7 additions & 0 deletions installer/upgrade-existing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
2
/home/runner/.local/cheqd
yes
yes
yes
yes
yes
9 changes: 0 additions & 9 deletions tests/legacy/interactive-install/.answers

This file was deleted.

Loading