Skip to content

Commit

Permalink
chore(integration-tests): fix trigger tests [NET-517] (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
justprosh authored Aug 10, 2023
1 parent cd877ab commit 0d224ba
Show file tree
Hide file tree
Showing 8 changed files with 2,865 additions and 3,187 deletions.
117 changes: 0 additions & 117 deletions .github/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,123 +24,6 @@ services:
# - --bootstraps=/dns/nox-1/tcp/7771
# 12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR
- -k=hK62afickoeP2uZbmSkAYXxxqP8ozq16VRN7qfTP719EHC5V5tjrtW57BSjUr8GvsEXmJRbtejUWyPZ2rZMyQdq
volumes:
- ../../registry:/.nox/v1/builtins/registry
networks:
nox:
ipv4_address: 10.50.10.10

nox-2:
image: ${NOX_IMAGE}
ports:
- 7772:7772
- 9992:9992
command:
- --aqua-pool-size=2
- -t=7772
- -w=9992
- -x=10.50.10.20
- --external-maddrs
- /dns4/nox-2/tcp/7772
- /dns4/nox-2/tcp/9992/ws
- --allow-private-ips
- --bootstraps=/dns/nox-1/tcp/7771
# 12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK
- -k=2WijTVdhVRzyZamWjqPx4V4iNMrajegNMwNa2PmvPSZV6RRpo5M2fsPWdQr22HVRubuJhhSw8BrWiGt6FPhFAuXy
volumes:
- ../../registry:/.nox/v1/builtins/registry
networks:
nox:
ipv4_address: 10.50.10.20

nox-3:
image: ${NOX_IMAGE}
ports:
- 7773:7773
- 9993:9993
command:
- --aqua-pool-size=2
- -t=7773
- -w=9993
- -x=10.50.10.30
- --external-maddrs
- /dns4/nox-3/tcp/7773
- /dns4/nox-3/tcp/9993/ws
- --allow-private-ips
- --bootstraps=/dns/nox-1/tcp/7771
# 12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ
- -k=2n2wBVanBeu2GWtvKBdrYK9DJAocgG3PrTUXMharq6TTfxqTL4sLdXL9BF23n6rsnkAY5pR9vBtx2uWYDQAiZdrX
volumes:
- ../../registry:/.nox/v1/builtins/registry
networks:
nox:
ipv4_address: 10.50.10.30

nox-4:
image: ${NOX_IMAGE}
ports:
- 7774:7774
- 9994:9994
command:
- --aqua-pool-size=2
- -t=7774
- -w=9994
- -x=10.50.10.40
- --external-maddrs
- /dns4/nox-4/tcp/7774
- /dns4/nox-4/tcp/9994/ws
- --allow-private-ips
- --bootstraps=/dns/nox-1/tcp/7771
# 12D3KooWBzLSu9RL7wLP6oUowzCbkCj2AGBSXkHSJKuq4wwTfwof
- -k=4zp8ucAikkjB8CmkufYiFBW4QCDUCbQG7yMjviX7W8bMyN5rfChQ2Pi5QCWThrCTbAm9uq5nbFbxtFcNZq3De4dX
volumes:
- ../../registry:/.nox/v1/builtins/registry
networks:
nox:
ipv4_address: 10.50.10.40

nox-5:
image: ${NOX_IMAGE}
ports:
- 7775:7775
- 9995:9995
command:
- --aqua-pool-size=2
- -t=7775
- -w=9995
- -x=10.50.10.50
- --external-maddrs
- /dns4/nox-5/tcp/7775
- /dns4/nox-5/tcp/9995/ws
- --allow-private-ips
- --bootstraps=/dns/nox-1/tcp/7771
# 12D3KooWBf6hFgrnXwHkBnwPGMysP3b1NJe5HGtAWPYfwmQ2MBiU
- -k=3ry26rm5gkJXvdqRH4FoM3ezWq4xVVsBQF7wtKq4E4pbuaa6p1F84tNqifUS7DdfJL9hs2gcdW64Wc342vHZHMUp
volumes:
- ../../registry:/.nox/v1/builtins/registry
networks:
nox:
ipv4_address: 10.50.10.50

nox-6:
image: ${NOX_IMAGE}
ports:
- 7776:7776
- 9996:9996
command:
- --aqua-pool-size=2
- -t=7776
- -w=9996
- --bootstraps=/dns/nox-1/tcp/7771
- -x=10.50.10.60
- --external-maddrs
- /dns4/nox-6/tcp/7776
- /dns4/nox-6/tcp/9996/ws
- --allow-private-ips
# 12D3KooWPisGn7JhooWhggndz25WM7vQ2JmA121EV8jUDQ5xMovJ
- -k=5Qh8bB1sF28uLPwr3HTvEksCeC6mAWQvebCfcgv9y6j4qKwSzNKm2tzLUg4nACUEo2KZpBw11gNCnwaAdM7o1pEn
volumes:
- ../../registry:/.nox/v1/builtins/registry
networks:
nox:
ipv4_address: 10.50.10.60
32 changes: 31 additions & 1 deletion integration-tests/aqua/lib.aqua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
aqua Lib declares *

export list, install, remove, update, get_config, get_script, get_counter, get_string, is_spell_absent, remove_service, get_location, get_spell_errors, noop
export list, install, remove, update, get_config, get_script, get_counter, get_string, is_spell_absent, get_trigger_event, get_all_trigger_events, remove_service, get_location, get_spell_errors, noop

import "../../src/aqua/spell/api.aqua"
import "../../src/aqua/spell/trigger.aqua"
Expand Down Expand Up @@ -124,6 +124,36 @@ func remove_service(id: string) -> Result:
result <<- Result(success = false, error = err.message)
<- result[0]

func get_trigger_event(spell_id: string) -> ?TriggerEvent, ?string:
error: ?string
trigger: ?TriggerEvent
on HOST_PEER_ID:
Spell spell_id
result <- Spell.get_string("trigger")
if result.success:
if result.absent == false:
trigger <- TriggerEventJson.parse(result.str)
else:
error <<- result.error

<- trigger, error

-- you should store triggers in KV;
-- to achieve this you can use store_triggers_script from test_aqua.py
func get_all_trigger_events(spell_id: string) -> []TriggerEvent, ?string:
error: ?string
triggers: *TriggerEvent
on HOST_PEER_ID:
Spell spell_id
result <- Spell.list_get_strings("triggers")
if result.success:
for trigger <- result.strings:
triggers <- TriggerEventJson.parse(trigger)
else:
error <<- result.error

<- triggers, error

func get_spell_errors(spell_id: string) -> AllErrorsResult:
on HOST_PEER_ID:
Spell spell_id
Expand Down
5 changes: 0 additions & 5 deletions integration-tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
def get_local():
return [
'/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWBM3SdXWqGaawQDGQ6JprtwswEg3FWGvGhmgmMez1vRbR',
'/ip4/127.0.0.1/tcp/9992/ws/p2p/12D3KooWQdpukY3p2DhDfUfDgphAqsGu5ZUrmQ4mcHSGrRag6gQK',
'/ip4/127.0.0.1/tcp/9993/ws/p2p/12D3KooWRT8V5awYdEZm6aAV9HWweCEbhWd7df4wehqHZXAB7yMZ',
'/ip4/127.0.0.1/tcp/9994/ws/p2p/12D3KooWBzLSu9RL7wLP6oUowzCbkCj2AGBSXkHSJKuq4wwTfwof',
'/ip4/127.0.0.1/tcp/9995/ws/p2p/12D3KooWBf6hFgrnXwHkBnwPGMysP3b1NJe5HGtAWPYfwmQ2MBiU',
'/ip4/127.0.0.1/tcp/9996/ws/p2p/12D3KooWPisGn7JhooWhggndz25WM7vQ2JmA121EV8jUDQ5xMovJ'
]
2 changes: 1 addition & 1 deletion integration-tests/fluence.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# yaml-language-server: $schema=.fluence/schemas/fluence.yaml.json
# yaml-language-server: $schema=.fluence/schemas/fluence.json
version: 2
aquaInputPath: aqua/*
6 changes: 3 additions & 3 deletions integration-tests/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ def update_spell_ok(key_pair_name, spell_id, config):


def get_trigger_event_ok(key_pair_name, spell_id):
[triggers, error] = run_aqua(key_pair_name, "get_all_trigger_events", [spell_id])
assert error is None, f"get_all_trigger_events: got error while retrieving triggers for spell {spell_id}: {error}"
return triggers[-1]
[trigger, error] = run_aqua(key_pair_name, "get_trigger_event", [spell_id])
assert error is None, f"get_trigger_event: got error while retrieving triggers for spell {spell_id}: {error}"
return trigger


def get_counter_ok(key_pair_name, spell_id):
Expand Down
Loading

0 comments on commit 0d224ba

Please sign in to comment.