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

(WIP) Add retry of EVE image update to API #562

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
129 changes: 129 additions & 0 deletions tests/update_eve_image/testdata/reupdate_eve_image.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
[!exec:sleep] stop
[!exec:bash] stop
[!exec:jq] stop

# Default EVE version to update
{{$eve_ver := "6.0.0"}}

# Obtain EVE version from environment variable EVE_VERSION
{{$env := EdenGetEnv "EVE_VERSION"}}

# If environment variable EVE_VERSION set, use it instead of default
{{if $env}}{{$eve_ver = $env}}{{end}}

# Obtain eve.hv from config
{{$eve_hv := EdenConfig "eve.hv"}}

# Obtain eve.arch from config
{{$eve_arch := EdenConfig "eve.arch"}}

# Combine variables into $short_version
{{$short_version := printf "%s-%s-%s" $eve_ver $eve_hv $eve_arch}}

# Use eden.lim.test for access Infos with timewait 30m
{{$test := "eden.lim.test -test.v -timewait 30m -test.run TestInfo"}}

# Decrease update testing time
eden controller edge-node update --config timer.test.baseimage.update=30

# Download EVE rootfs into eve-dist
message 'EVE image download'
eden -t 10m utils download eve-rootfs --eve-tag={{$eve_ver}} --eve-hv={{EdenConfig "eve.hv"}} --downloader-dist={{EdenConfigPath "eve.dist"}} -v debug

# Check stdout of previous command. Expected to get full path to squashfs
stdout '{{EdenConfigPath "eve.dist"}}/rootfs-{{ $short_version }}.squashfs'

eden eve version
# Send command to update eveimage
message 'EVE update request'
eden -t 10m controller edge-node eveimage-update file://{{EdenConfigPath "eve.dist"}}/rootfs-{{ $short_version }}.squashfs -m adam://

# Check stderr, it must be empty
! stderr .

eden eve version
! stdout '{{ $short_version }}'

# Run monitoring of Info messages to obtain info with PartitionState active and previously defined ShortVersion
message 'Waiting for EVE update...'
test {{$test}} -out InfoContent.dinfo.SwList[0].ShortVersion 'InfoContent.dinfo.SwList[0].PartitionState:inprogress InfoContent.dinfo.SwList[0].ShortVersion:{{ $short_version }}'

# Check stdout of previous command. Expected to get previously defined ShortVersion
stdout '{{ $short_version }}'

eden eve version
stdout '{{ $short_version }}'

eden eve stop
exec sleep 30
eden eve status
! stdout 'EVE on Qemu status: running with pid'
eden eve start

eden eve version
stdout '{{ $short_version }}'

test eden.reboot.test -timewait 10m -reboot=0 -test.v &

# Waiting of eden.reboot.test result
wait
stdout 'Number of reboots:'
! stdout 'FAIL'

eden eve version
! stdout '{{ $short_version }}'

# Resetting of BaseOS
eden controller edge-node get-config --file eve.cfg
exec bash clean_baseos.sh
cp stdout eve_new.cfg
eden controller edge-node set-config --file eve_new.cfg

test eden.reboot.test -timewait 10m -reboot=0 -test.v &

# Waiting of eden.reboot.test result
wait
stdout 'Number of reboots:'
! stdout 'FAIL'

exec -t 30m bash clean_wait.sh
eden eve version

eden controller edge-node set-config --file eve.cfg
eden eve version

test eden.reboot.test -timewait 10m -reboot=0 -test.v &

# Waiting of eden.reboot.test result
wait
stdout 'Number of reboots:'
! stdout 'FAIL'

eden eve version

# Reset EVE version
#test eden.escript.test -test.run TestEdenScripts/revert_eve_image_update -test.v -testdata {{EdenConfig "eden.tests"}}/update_eve_image/testdata/

# Reset EVE config
#eden eve reset

-- clean_baseos.sh --
jq '.base = []' < eve.cfg

-- clean_wait.sh --
for i in `seq 20`
do
echo {{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{$test}} -out InfoContent.dinfo.SwList 'InfoContent.dinfo.SwList:.* | grep -v swErr'
{{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{$test}} -out InfoContent.dinfo.SwList 'InfoContent.dinfo.SwList:.*' | grep -v swErr && break
sleep 20
done

-- eden-config.yml --
# Test's config file
test:
controller: adam://{{EdenConfig "adam.ip"}}:{{EdenConfig "adam.port"}}
eve:
{{EdenConfig "eve.name"}}:
onboard-cert: {{EdenConfigPath "eve.cert"}}
serial: "{{EdenConfig "eve.serial"}}"
model: {{EdenConfig "eve.devmodel"}}
122 changes: 122 additions & 0 deletions tests/update_eve_image/testdata/reupdate_eve_image_oci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[!exec:sleep] stop
[!exec:bash] stop
[!exec:jq] stop

# Default EVE version to update
{{$eve_ver := "6.0.0"}}

# Obtain EVE version from environment variable EVE_VERSION
{{$env := EdenGetEnv "EVE_VERSION"}}

# If environment variable EVE_VERSION set, use it instead of default
{{if $env}}{{$eve_ver = $env}}{{end}}

# Obtain eve.hv from config
{{$eve_hv := EdenConfig "eve.hv"}}

# Obtain eve.arch from config
{{$eve_arch := EdenConfig "eve.arch"}}

# Combine variables into $short_version
{{$short_version := printf "%s-%s-%s" $eve_ver $eve_hv $eve_arch}}

# Use eden.lim.test for access Infos with timewait 30m
{{$test := "eden.lim.test -test.v -timewait 30m -test.run TestInfo"}}

# Decrease update testing time
eden controller edge-node update --config timer.test.baseimage.update=30

eden eve version
# Send command to update eveimage from OCI image
message 'EVE update request'
eden -t 10m controller edge-node eveimage-update oci://docker.io/lfedge/eve:{{$eve_ver}}-{{$eve_hv}}-{{$eve_arch}} -m adam://

# Check stderr, it must be empty
! stderr .

eden eve version
! stdout '{{ $short_version }}'

# Run monitoring of Info messages to obtain info with PartitionState active and previously defined ShortVersion
message 'Waiting for EVE update...'
test {{$test}} -out InfoContent.dinfo.SwList[0].ShortVersion 'InfoContent.dinfo.SwList[0].PartitionState:inprogress InfoContent.dinfo.SwList[0].ShortVersion:{{ $short_version }}'

# Check stdout of previous command. Expected to get previously defined ShortVersion
stdout '{{ $short_version }}'

eden eve version
stdout '{{ $short_version }}'

eden eve stop
exec sleep 30
eden eve status
! stdout 'EVE on Qemu status: running with pid'
eden eve start

eden eve version
stdout '{{ $short_version }}'

test eden.reboot.test -timewait 10m -reboot=0 -test.v &

# Waiting of eden.reboot.test result
wait
stdout 'Number of reboots:'
! stdout 'FAIL'

eden eve version
! stdout '{{ $short_version }}'

# Resetting of BaseOS
eden controller edge-node get-config --file eve.cfg
exec bash clean_baseos.sh
cp stdout eve_new.cfg
eden controller edge-node set-config --file eve_new.cfg

test eden.reboot.test -timewait 10m -reboot=0 -test.v &

# Waiting of eden.reboot.test result
wait
stdout 'Number of reboots:'
! stdout 'FAIL'

exec -t 30m bash clean_wait.sh
eden eve version

eden controller edge-node set-config --file eve.cfg
eden eve version

test eden.reboot.test -timewait 10m -reboot=0 -test.v &

# Waiting of eden.reboot.test result
wait
stdout 'Number of reboots:'
! stdout 'FAIL'

eden eve version

# Reset EVE version
#test eden.escript.test -test.run TestEdenScripts/revert_eve_image_update -test.v -testdata {{EdenConfig "eden.tests"}}/update_eve_image/testdata/

# Reset EVE config
#eden eve reset

-- clean_baseos.sh --
jq '.base = []' < eve.cfg

-- clean_wait.sh --
for i in `seq 20`
do
echo {{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{$test}} -out InfoContent.dinfo.SwList 'InfoContent.dinfo.SwList:.* | grep -v swErr'
{{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{$test}} -out InfoContent.dinfo.SwList 'InfoContent.dinfo.SwList:.*' | grep -v swErr && break
sleep 20
done

-- eden-config.yml --
# Test's config file
test:
controller: adam://{{EdenConfig "adam.ip"}}:{{EdenConfig "adam.port"}}
eve:
{{EdenConfig "eve.name"}}:
onboard-cert: {{EdenConfigPath "eve.cert"}}
serial: "{{EdenConfig "eve.serial"}}"
model: {{EdenConfig "eve.devmodel"}}