@@ -43,6 +43,8 @@ groups:
4343
4444 tests :
4545 help : Test commands
46+ env :
47+ SUGAR_SWARM_FLAGS : --file tests/containers/.services.sugar-swarm.yaml --verbose --profile profile1
4648 tasks :
4749 linter :
4850 help : Run lint checks
@@ -56,7 +58,7 @@ groups:
5658 params :
5759 help : Extra parameters for pytest
5860 type : string
59- default : " -vv "
61+ default : " -vvv "
6062 run : pytest -s ${{ args.params }} tests
6163
6264 smoke-1 :
@@ -332,90 +334,6 @@ groups:
332334 run : |
333335 sugar --verbose podman-ext wait --help
334336
335- smoke-swarm :
336- help : Run smoke tests for swarm commands
337- hooks :
338- pre-run :
339- # - task: docker.killall
340- - task : docker.leave_node
341- env :
342- SUGAR_FLAGS : --verbose --profile profile1
343- run : |
344- # Initialize swarm
345- sugar ${{ vars.SUGAR_FLAGS }} swarm init --options "--advertise-addr 127.0.0.1"
346-
347-
348- # Test stack commands
349- echo $'\033[32mTesting stack deployment...\033[0m'
350- sugar ${{ vars.SUGAR_FLAGS }} swarm:stack deploy --stack test-stack
351-
352- # List services (with and without stack filter)
353- echo $'\033[32mTesting service listing...\033[0m'
354- sugar ${{ vars.SUGAR_FLAGS }} swarm ls
355- sugar ${{ vars.SUGAR_FLAGS }} swarm:stack ls --stack test-stack
356-
357- # Test stack ps command
358- echo $'\033[32mTesting stack ps command...\033[0m'
359- sugar ${{ vars.SUGAR_FLAGS }} swarm:stack ps --stack test-stack
360-
361- # Test service inspection
362- echo $'\033[32mTesting service inspection...\033[0m'
363- sugar ${{ vars.SUGAR_FLAGS }} swarm:stack inspect --service service1-1 --stack test-stack
364-
365- # Test service1-1 , service1-2 and service1-3 service three times ping
366- for port in 18000 18001 18002; do
367- for i in {1..3}; do
368- curl -s http://127.0.0.1:$port
369- echo $'\033[32m - Ping $i to port $port[0m'
370- done
371- done
372-
373- # Test service logs (limited command to avoid test hanging)
374- echo $'\033[32mTesting service logs...\033[0m'
375- sugar ${{ vars.SUGAR_FLAGS }} swarm:service logs --services service1-1 --stack test-stack --tail 10
376- sugar ${{ vars.SUGAR_FLAGS }} swarm:service logs --services service1-2 --stack test-stack --tail 10
377-
378-
379- # Test service scaling
380- echo $'\033[32mTesting service scaling...\033[0m'
381- sugar ${{ vars.SUGAR_FLAGS }} swarm:service scale --stack test-stack --replicas service1-1=2,service1-2=3
382-
383- # TODO : sugar swarm update is yet to be implemented and experimental stage
384- # Test service update
385- # echo "Testing service update..."
386- # sugar ${{ vars.SUGAR_FLAGS }} swarm update --services test-stack_service1-1 --replicas 1 --detach
387-
388- # Test service rollback
389- echo $'\033[32mTesting service rollback specific services in a stack...\033[0m'
390- sugar ${{ vars.SUGAR_FLAGS }} swarm:service rollback --services service1-1,service1-3 test-stack
391-
392- # Test rollback with stack parameter
393- echo $'\033[32mTesting stack rollback all services in a stack...\033[0m'
394- sugar ${{ vars.SUGAR_FLAGS }} swarm:service rollback test-stack --all
395-
396- # Test swarm service subcommand
397- echo $'\033[32mTesting swarm service commands...\033[0m'
398- sugar ${{ vars.SUGAR_FLAGS }} swarm service --create --options "--name web nginx"
399- sugar ${{ vars.SUGAR_FLAGS }} swarm service --inspect web
400- sugar ${{ vars.SUGAR_FLAGS }} swarm service --logs web
401- sugar ${{ vars.SUGAR_FLAGS }} swarm service --ps web
402- sugar ${{ vars.SUGAR_FLAGS }} swarm service --update web --options "--image nginx:alpine"
403- sugar ${{ vars.SUGAR_FLAGS }} swarm service --scale "web=3"
404- sugar ${{ vars.SUGAR_FLAGS }} swarm service --rollback web
405- sugar ${{ vars.SUGAR_FLAGS }} swarm service --rm web
406-
407- # Test node commands
408- echo $'\033[32mTesting node commands...\033[0m'
409- sugar swarm:node ls
410- NODE_ID=$(docker node ls --format "{{.ID}}" )
411- echo $'\033[32mNode ID: $NODE_ID\033[0m'
412- sugar swarm:node inspect $NODE_ID
413- sugar swarm:node ps $NODE_ID
414-
415-
416- # Leave swarm
417- docker swarm leave --force
418-
419337 smoke-hooks :
420338 help : Run simple text for experimental commands
421339 hooks :
@@ -478,15 +396,99 @@ groups:
478396 sugar --verbose compose --help
479397 sugar --verbose compose version
480398
399+ smoke-swarm-init :
400+ help : Run smoke tests for swarm commands
401+ run : |
402+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm init --options "--advertise-addr 127.0.0.1"
403+
404+ smoke-swarm-deploy :
405+ help : Run smoke tests for swarm commands
406+ run : |
407+ # Test stack commands
408+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:stack deploy --stack test-stack
409+
410+ smoke-swarm-stack-ls :
411+ help : Run smoke tests for swarm commands
412+ run : |
413+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:stack ls --stack test-stack
414+
415+ smoke-swarm-ps :
416+ help : Run smoke tests for swarm commands
417+ run : |
418+ # Test stack ps command
419+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:stack ps --stack test-stack
420+
421+ smoke-swarm-service-inspect :
422+ help : Run smoke tests for swarm commands
423+ run : |
424+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:service inspect --services service1-1 --stack test-stack
425+ # Test service1-1 , service1-2 and service1-3 service three times ping
426+ for port in 18000 18001 18002; do
427+ for i in {1..3}; do
428+ curl -s http://127.0.0.1:$port
429+ echo $'\033[32m - Ping $i to port $port[0m'
430+ done
431+ done
432+
433+ smoke-swarm-logs :
434+ help : Run smoke tests for swarm commands
435+ run : |
436+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:service logs --services service1-1 --stack test-stack --tail 10
437+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:service logs --services service1-2 --stack test-stack --tail 10
438+
439+ smoke-swarm-service-scale :
440+ help : Run smoke tests for swarm commands
441+ run : |
442+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:service scale --stack test-stack --replicas service1-1=2,service1-2=3
443+
444+ smoke-swarm-update :
445+ help : Run smoke tests for swarm commands
446+ run : |
447+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm update
448+
449+ smoke-swarm-rollback :
450+ help : Run smoke tests for swarm commands
451+ run : |
452+ sugar ${{ env.SUGAR_SWARM_FLAGS }} swarm:service rollback --service service1-1
453+
454+ smoke-swarm-nodes :
455+ help : Run smoke tests for swarm commands
456+ run : |
457+ sugar swarm:node ls
458+ NODE_ID=$(docker node ls --format "{{.ID}}" )
459+ sugar swarm:node inspect --nodes $NODE_ID
460+ sugar swarm:node ps --nodes $NODE_ID
461+
462+ smoke-swarm-leave :
463+ help : Run smoke tests for swarm commands
464+ run : |
465+ docker swarm leave --force
466+
467+ smoke-swarm :
468+ help : Run smoke tests for swarm commands
469+ hooks :
470+ pre-run :
471+ - task : docker.killall
472+ - task : tests.smoke-swarm-init
473+ - task : tests.smoke-swarm-deploy
474+ - task : tests.smoke-swarm-stack-ls
475+ - task : tests.smoke-swarm-ps
476+ - task : tests.smoke-swarm-service-inspect
477+ - task : tests.smoke-swarm-logs
478+ - task : tests.smoke-swarm-update
479+ - task : tests.smoke-swarm-rollback
480+ - task : tests.smoke-swarm-service-scale
481+ - task : tests.smoke-swarm-nodes
482+ - task : tests.smoke-swarm-leave
483+
481484 docker :
482485 help : Commands for docker
483486 tasks :
484487 killall :
485488 help : Kill all running Docker containers
486- run : docker kill `docker ps -q` || true
487- leave_node :
488- help : Leave the swarm
489- run : docker node inspect self --format '{{.Spec.Role}}' &>/dev/null && { docker node leave --force && echo "Node left the swarm"; } || echo "Node already left the swarm"
489+ run : |
490+ docker kill $(docker ps -qa) || true
491+ sugar swarm leave --options "--force" || true
490492
491493 podman :
492494 help : Commands for podman
0 commit comments