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

Test replacement of one application with another #891

Merged
merged 1 commit into from
Oct 18, 2023
Merged
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
2 changes: 1 addition & 1 deletion pkg/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
DefaultRegistryPort = 5050

//tags, versions, repos
DefaultEVETag = "10.9.0" // DefaultEVETag tag for EVE image
DefaultEVETag = "10.10.0" // DefaultEVETag tag for EVE image
DefaultAdamTag = "0.0.43"
DefaultRedisTag = "7"
DefaultRegistryTag = "2.7"
Expand Down
73 changes: 73 additions & 0 deletions tests/app/testdata/app_replace_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Here we test two application configurations that cannot coexist at the same time.
# First, we deploy application app1 into network with only one free IP address
# and then try to deploy another application into the same network. The second
# application should stay in the error state as long as the first app exist.
# However, once the first application is deleted, the second application should be
# automatically deployed and take the IP of the removed first app.
# In the second part of the test we replace application with another within the same
# config iteration. EVE should first remove the obsolete application before deploying
# the new one, otherwise it will fail to allocate IP address (since only one IP address
# is available at a time).

[!exec:jq] stop
[!exec:grep] stop
[!exec:bash] stop
[!exec:uuidgen] stop

# Starting of reboot detector with a 1 reboot limit
! test eden.reboot.test -test.v -timewait=0 -reboot=0 -count=1 &

message 'Resetting of EVE'
eden eve reset
exec sleep 30

# Create network with only single IP address left for allocation for applications.
# Note that one IP is used for the bridge.
eden -t 1m network create 10.11.12.0/30 -n n1
test eden.network.test -test.v -timewait 10m ACTIVATED n1

# Deploy application that will use the only IP address available
eden -t 1m pod deploy -n app1 -p 8027:80 docker://nginx --networks=n1 --memory 512MB
test eden.app.test -test.v -timewait 10m RUNNING app1

# Try to deploy another application, but there is no free IP left.
eden -t 1m pod deploy -n app2 -p 8028:80 docker://nginx --networks=n1 --memory 512MB
exec -t 5m bash wait_for_app_error.sh app2 'no free IP addresses in DHCP range'

# Now undeploy the first app and the second one should come up.
eden pod delete app1
test eden.app.test -test.v -timewait 10m - app1
test eden.app.test -test.v -timewait 10m RUNNING app2

# Change the second app UUID which is effectively the same as replacing
# one application with another in one config iteration.
exec -t 5m bash change-app-uuid.sh app2
test eden.app.test -test.v -timewait 5m RUNNING app2

# Cleanup.
eden pod delete app2
test eden.app.test -test.v -timewait 10m - app2
eden -t 1m network delete n1
test eden.network.test -test.v -timewait 2m - n1

-- wait_for_app_error.sh --
#!/bin/sh

APP="$1"
ERR="$2"

EDEN={{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{EdenConfig "eden.eden-bin"}}
until $EDEN pod ps | grep "^$APP" | grep "$ERR"; do sleep 3; done

-- change-app-uuid.sh --
#!/bin/sh

APP="$1"
NEW_UUID="$(uuidgen)"

EDEN={{EdenConfig "eden.root"}}/{{EdenConfig "eden.bin-dist"}}/{{EdenConfig "eden.eden-bin"}}
$EDEN controller edge-node get-config --file device.cfg
UUID=$(jq -r '.apps[] | select(.displayname == "'$APP'") | .uuidandversion.uuid' < device.cfg)
sed -i "s/\"uuid\": \"$UUID\"/\"uuid\": \"$NEW_UUID\"/" device.cfg
$EDEN controller edge-node set-config --file device.cfg
while $EDEN pod ps | grep $UUID; do sleep 3; done
4 changes: 3 additions & 1 deletion tests/workflow/eden.workflow.tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ eden.escript.test -testdata ../registry/testdata/ -test.run TestEdenScripts/regi
eden.escript.test -testdata ../eclient/testdata/ -test.run TestEdenScripts/air-gapped-switch
/bin/echo Eden 2 dockers test (26/{{$tests}})
eden.escript.test -testdata ../docker/testdata/ -test.run TestEdenScripts/2dockers_test
/bin/echo Eden 2 dockers test with app state detector (27/{{$tests}})
/bin/echo Eden 2 dockers test with app state detector (27.1/{{$tests}})
eden.escript.test -testdata ../app/testdata/ -test.run TestEdenScripts/2dockers_test
/bin/echo Testing replacement of one application with another (27.2/{{$tests}})
eden.escript.test -testdata ../app/testdata/ -test.run TestEdenScripts/app_replace_test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but just to mention: test located here will run only on EdenGCP workflow for now, as we have {{ if or (eq $workflow "large") (eq $workflow "gcp") }} above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and we need to add this tests to new workflows, because EVE is using them. I suggest to put this in user app

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already put this to user-apps.tests.txt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, didn't see it :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@giggsoff I didn't realize that the test would be skipped in the old workflow, but since we are going to move to the new workflow soon, I'm going to keep it as it is.

/bin/echo Eden Nginx (28/{{$tests}})
eden.escript.test -testdata ../eclient/testdata/ -test.run TestEdenScripts/ngnix

Expand Down
9 changes: 6 additions & 3 deletions tests/workflow/user-apps.tests.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Number of tests
{{$tests := 8}}
{{$tests := 9}}
# EDEN_TEST_SETUP env. var. -- "y"(default) performs the EDEN setup steps
{{$setup := "y"}}
{{$setup_env := EdenGetEnv "EDEN_TEST_SETUP"}}
Expand Down Expand Up @@ -38,8 +38,11 @@ eden.escript.test -testdata ../docker/testdata/ -test.run TestEdenScripts/2docke
/bin/echo Eden 2 dockers test with app state detector (6/{{$tests}})
eden.escript.test -testdata ../app/testdata/ -test.run TestEdenScripts/2dockers_test

/bin/echo Eden Mariadb (7/{{$tests}})
/bin/echo Testing replacement of one application with another (7/{{$tests}})
eden.escript.test -testdata ../app/testdata/ -test.run TestEdenScripts/app_replace_test

/bin/echo Eden Mariadb (8/{{$tests}})
eden.escript.test -testdata ../eclient/testdata/ -test.run TestEdenScripts/maridb

/bin/echo Eden nodered (8/{{$tests}})
/bin/echo Eden nodered (9/{{$tests}})
eden.escript.test -testdata ../eclient/testdata/ -test.run TestEdenScripts/nodered
Loading