{"id":15898686,"url":"https://github.com/kadalu/binnacle","last_synced_at":"2025-03-20T16:32:43.679Z","repository":{"id":37099158,"uuid":"233753763","full_name":"kadalu/binnacle","owner":"kadalu","description":"A simple imperative tool for Tests and Infra automation","archived":false,"fork":false,"pushed_at":"2024-01-28T07:53:40.000Z","size":120,"stargazers_count":6,"open_issues_count":5,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-14T09:04:39.772Z","etag":null,"topics":["bash","distributed-systems","kadalu","ruby","testing"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kadalu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"kadalu"}},"created_at":"2020-01-14T04:06:46.000Z","updated_at":"2024-03-26T15:51:37.000Z","dependencies_parsed_at":"2023-01-29T19:30:44.112Z","dependency_job_id":"d051719c-63da-4876-9757-a91ebbaccf95","html_url":"https://github.com/kadalu/binnacle","commit_stats":{"total_commits":83,"total_committers":5,"mean_commits":16.6,"dds":"0.49397590361445787","last_synced_commit":"de81e2ebc4414726eb8d1a82e646aeac8c818254"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadalu%2Fbinnacle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadalu%2Fbinnacle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadalu%2Fbinnacle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadalu%2Fbinnacle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kadalu","download_url":"https://codeload.github.com/kadalu/binnacle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244077837,"owners_count":20394353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","distributed-systems","kadalu","ruby","testing"],"created_at":"2024-10-06T10:07:30.597Z","updated_at":"2025-03-20T16:32:43.638Z","avatar_url":"https://github.com/kadalu.png","language":"Ruby","funding_links":["https://github.com/sponsors/kadalu"],"categories":[],"sub_categories":[],"readme":"# Test and infra automation Framework - Binnacle\n\n## Install\n\n```\ngem install kadalu-binnacle\n```\n\n## Usage\n\nCheck the version\n\n```\nbinnacle --version\n```\n\n```\nbinnacle \u003ctask-file|task_files_list\u003e [options]\n```\n\nRun a single task file\n\n```ruby\n# File: verify_report.t\ncommand_run \"my-script ~/report.csv\"\ncommand_run \"stat ~/report.csv\"\n```\n\n```\nbinnacle verify_report.t\n```\n\nFor detailed output, use `-v` and to print the output of the commands, use `-vv`\n\n```\nbinnacle -vv verify_report.t\n```\n\nFor JSON results,\n\n```\nbinnacle -vv verify_report.t --results-json=report.json\n```\n\nTo run multiple files,\n\n```\nbinnacle -vv file1.t file2.t file3.t\n```\n\nAlternatively give list of files as task list(`*.tl`)\n\nFile: tasks.tl\n\n```\nfile1.t\nfile2.t\nfile3.t\n```\n\nOr give directory path to run all the tasks in the directory\n\n```\nbinnacle -vv tasks_dir\n```\n\nWide output: Set this flag to not crop the output lines\n\n```\nbinnacle -vv -w verify_report.t\n```\n\n## Syntax and Keywords\n\n### Run any command (`command_run` or `command_test`)\n\n```ruby\ncommand_run \"stat ~/report.csv\"\n```\n\n```ruby\ncommand_test \"stat ~/report.csv\"\n```\n\nTo test a command that returns a specific error\n\n```ruby\ncommand_test 1, \"stat ~/non/existing/file\"\n```\n\nIgnore errors and run any command\n\n```ruby\ncommand_run nil, \"docker stop app-dev\"\ncommand_run nil, \"docker rm app-dev\"\n```\n\n### Run the command and validate the output\n\n```ruby\n#              Expect value         Command\ncommand_expect \"node1.example.com\", \"hostname\"\n```\n\n### Run a command in a docker container\n\n```ruby\ncommand_mode \"docker\"\ncommand_container \"myapp\"\n\ncommand_run \"stat /var/www/html/index.html\"\n```\n\n### Run a command using SSH\n\n```ruby\ncommand_mode \"ssh\"\ncommand_ssh_user \"ubuntu\"\ncommand_sudo true\ncommand_ssh_pem_file \"~/.ssh/id_rsa\"\n\ncommand_node \"node1.example.com\"\ncommand_run \"stat /var/www/html/index.html\"\n```\n\n### Equal and Not Equal\n\n```ruby\ncompare_equal? var1, 100, \"Test if var1 == 100\"\ncompare_not_equal? var1, 100, \"Test if var1 != 100\"\n```\n\n### True and False\n\n```ruby\ncompare_true? var1 == 100, \"Test if var1 == 100\"\ncompare_false? var1 == 100, \"Test if var1 != 100\"\n```\n\n## Customization\n\n`command_node`, `command_mode` etc are used to adjust the behaviour of the plugins. These options can be used as global options or as block options. Block options helps to limit those settings only for that block.\n\n```ruby\ncommand_node \"server1\"\ncommand_run \"command 1\"\n\ncommand_node \"server2\"\ncommand_run \"command 2\"\n\ncommand_node \"server1\"\ncommand_run \"command 3\"\n```\n\n```ruby\ncommand_node \"server1\"\ncommand_run \"command 1\"\n\ncommand_node \"server2\" do\n    command_run \"command 2\"\nend\n\ncommand_run \"command 3\"\n```\n\nBoth examples above are same. The second one is easy since no need to remember the changed options after executing the command 2.\n\n### Options\n\n- `command_mode` (`local` (default), `docker`, `ssh`)\n- `command_node` or `command_container`\n- `command_ssh_user`\n- `command_ssh_port`\n- `command_ssh_pem_file`\n- `command_sudo`\n- `exit_on_not_ok`\n\n## Embed other task files\n\nUse load keyword to include the tests/utilities from other files.\n\nFor example, `repeat_tests.t`\n\n```ruby\ncommand_test \"command 1\"\ncommand_test \"command 2\"\n```\n\nand the `main.t` tests file\n\n```ruby\ncommand_mode \"docker\"\n\ncontainers = [\"node1.example.com\", \"node2.example.com\", \"node3.example.com\"]\ncontainers.each do |container|\n    command_node container\n\n    load \"./repeat_tests.t\"\nend\n```\n\n## Testing ReST APIs\n\n```ruby\nhttp_base_url \"http://localhost:3000\"\n\nhttp_get \"/api/users\"\n\n# Test a specific status code\nhttp_get \"/api/users\", status: 200\n\n# Create a user with JSON data\ndata = {\n  \"name\" =\u003e \"Binnacle\",\n  \"url\" =\u003e \"https://binnacle.kadalu.tech\"\n}\n\nhttp_post \"/api/users\", json: data, status: 201\n\n# JSON as Text\nhttp_post \"/api/users\", json: \u003c\u003c-DATA, status: 201\n{\n  \"name\": \"Binnacle\",\n  \"url\": \"https://binnacle.kadalu.tech\"\n}\nDATA\n\n# As Form data\ndata = {\n  \"name\" =\u003e \"Binnacle\",\n  \"url\" =\u003e \"https://binnacle.kadalu.tech\"\n}\n\nhttp_post \"/api/users\", form: data, status: 201\n\n# Upload a file\ndata = {\n  \"name\" =\u003e \"Binnacle\",\n  \"url\" =\u003e \"https://binnacle.kadalu.tech\",\n  \"profile\" =\u003e \"@./binnacle_logo.png\"\n}\n\nhttp_post \"/api/users\", multipart: data, status: 201\n\n# Edit\ndata = {\n  \"name\" =\u003e \"Kadalu Binnacle\"\n}\n\nhttp_put \"/api/users/1\", form: data, status: 200\n\n# Delete\nhttp_delete \"/api/users/1\", status: 204\n\n# Get JSON response\nhttp_response_type \"json\"\ndata = http_get \"/api/users\"\ncompare_equal \"Kadalu Binnacle\", data[:json][\"name\"]\n\n# Add and Remove header\nhttp_add_header \"Authorization\", \"Bearer 1234\"\nhttp_get \"/api/users\", status: 200 # With Auth Header\nhttp_remove_header \"Authorization\"\nhttp_get \"/api/users\", status: 401 # Without Auth header\n```\n\nA simple script to check the status of websites\n\n```ruby\nhttp_get \"https://kadalu.tech\"\nhttp_get \"https://content.kadalu.tech\"\nhttp_get \"https://aravindavk.in\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkadalu%2Fbinnacle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkadalu%2Fbinnacle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkadalu%2Fbinnacle/lists"}