{"id":16148267,"url":"https://github.com/chanwit/marine","last_synced_at":"2025-04-06T21:20:09.617Z","repository":{"id":27166975,"uuid":"30636492","full_name":"chanwit/marine","owner":"chanwit","description":"Marine: Functional Testing for Swarm","archived":false,"fork":false,"pushed_at":"2015-02-16T11:20:13.000Z","size":348,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T03:18:35.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chanwit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-11T07:43:45.000Z","updated_at":"2015-02-18T16:18:31.000Z","dependencies_parsed_at":"2022-08-17T17:40:09.251Z","dependency_job_id":null,"html_url":"https://github.com/chanwit/marine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanwit%2Fmarine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanwit%2Fmarine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanwit%2Fmarine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanwit%2Fmarine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanwit","download_url":"https://codeload.github.com/chanwit/marine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247551133,"owners_count":20957055,"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":[],"created_at":"2024-10-10T00:32:20.447Z","updated_at":"2025-04-06T21:20:09.594Z","avatar_url":"https://github.com/chanwit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Marine\n\n`Marine` is a functional testing framework designed mainly to test [Swarm](http://github.com/docker/swarm).\nBut we can generally use `Marine` to test several kinds of cluster-based application.\n\nMarine contains a set of GO APIs to prepare a cluster, initialize network for the cluster nodes, allow us to install software, e.g., Docker and Swarm on them.\nAs `Marine` is desinged to test `Swarm` and `Docker`, it directly uses VirtualBox to manage cluster machines.\n\n### Installation\n\n#### Image Preparation\n\nMarine comes with a little utility to help us prepare a ready-to-use VM image that contains `docker` and `golang`. The following command imports Ubuntu 14.10 and performs the preparation.\n\n```\n$ go get github.com/chanwit/marine/cmd/marine\n$ $GOBIN/marine prepare                   \\\n  -i=files/ubuntu-14.10-server-amd64.ova  \\\n  -o=files/ubuntu-docker-golang.ova\nINFO[0015] Imported \"ubuntu\"\nINFO[0015] Modified nic2 for \"ubuntu\"\nINFO[0015] Started \"ubuntu\"\nINFO[0035] VM \"ubuntu\" ready to connect\nINFO[0035] Sudo: \"wget -qO- --no-check-certificate https://get.docker.com/ | bash\"\nINFO[0141] Sudo: \"service docker start\"\nINFO[0141] Sudo: \"docker pull golang:1.3\"\nINFO[0275] Stopping \"ubuntu\"\nINFO[0290] VM \"ubuntu\" is now poweroff\nINFO[0290] Snapshot \"ubuntu/origin\" taken\nINFO[0407] Exported \"ubuntu\" to files/ubuntu-docker-golang.ova\nINFO[0409] Removed \"ubuntu\"\n```\n\n#### Functional Test\n\n`Marine` has been designed to use in Go test.\nJust create a test file and\n\n```go\nimport github.com/chanwit/marine\n```\n\nThis example shows how to setup a pre-check that import the prepared image.\n```go\nfunc checkFunctional(t *testing.T) {\n\tif os.Getenv(\"SWARM_FUNC_TEST\") != \"\" {\n\t\t// you need to import a VM first.\n\t\tif exist, err := vm.Exist(\"ubuntu\"); err == nil \u0026\u0026 !exist {\n\t\t\tubuntu, err := vm.Import(\n\t\t\t\tpath.Join(os.Getenv(\"GOPATH\"), \"files/ubuntu-docker-golang.ova\"),\n\t\t\t\t512)\n\t\t\tassert.NoError(t, err)\n\t\t\tassert.NotNil(t, ubuntu)\n\t\t}\n\t} else {\n\t\tt.Skip(`Enable this test with \"export SWARM_FUNC_TEST=true\"`)\n\t}\n}\n```\n\nThis test case uses the above VM, compiles `Swarm` from its `HEAD`.\nThen it tests that the `Swarm`'s version should have a proper format.\n```go\nfunc TestVersionCommitId(t *testing.T) {\n\tcheckFunctional(t)\n\n\tubuntu := \u0026vm.Machine{Name: \"ubuntu\"}\n\tbox, err := ubuntu.Clone(\"box\")\n\tbox.StartAndWait()\n\tdefer func() {\n\t\tbox.Stop()\n\t\tbox.Remove()\n\t}()\n\n\t// build swarm from master/HEAD\n\terr = box.BuildSwarm(\"docker/swarm\")\n\tassert.NoError(t, err)\n\n\tv := strings.Replace(version.VERSION, \".\", `\\.`, 2)\n\tpattern, err := regexp.Compile(`^swarm version ` + v + ` \\([0-9a-f]{7}\\)$`)\n\tassert.NoError(t, err)\n\n\tout, err := box.Sudo(\"docker run --rm -t swarm:build --version\")\n\tassert.NoError(t, err)\n\tassert.True(t, pattern.MatchString(strings.TrimSpace(string(out))))\n}\n```\n\n#### VM Clones\nTo clone the above image and prepare 4 VMs, we can call the following command.\n\n```go\n\tubuntu := \u0026marine.Machine{Name:\"ubuntu\"}\n\tboxes, err := ubuntu.CloneN(4, \"box\")\n```\n\nPlease note that all VMs will share an auto-config `host-only` network.\nWe'll have `box001`, `box002`, `box003` and `box004` if the command runs successfully.\n\nEach node will have its own port-forwarding. VM `box001` can be connected via `127.0.0.1:52201` and so on.\n\n### Creator\n\n`Marine` is created by\n\nChanwit Kaewkasi,\nCopyright 2015 Suranaree University of Technology.\n\n`Marine` code is made available under Apache Software License 2.0.\nIts document is available under Creative Commons.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanwit%2Fmarine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanwit%2Fmarine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanwit%2Fmarine/lists"}