{"id":31324809,"url":"https://github.com/hchauvin/name_manager","last_synced_at":"2026-04-19T02:02:01.302Z","repository":{"id":98217213,"uuid":"215890378","full_name":"hchauvin/name_manager","owner":"hchauvin","description":"Utility to manage shared test resources with a global lock 🔒","archived":false,"fork":false,"pushed_at":"2024-09-01T23:35:29.000Z","size":156,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-25T21:41:36.377Z","etag":null,"topics":["bazel","concurrency","distributed-lock","docker-compose","end-to-end-testing","integration-testing","test-harness","testing"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hchauvin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-10-17T21:41:33.000Z","updated_at":"2020-03-16T12:23:30.000Z","dependencies_parsed_at":"2023-06-26T02:04:09.455Z","dependency_job_id":null,"html_url":"https://github.com/hchauvin/name_manager","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/hchauvin/name_manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchauvin%2Fname_manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchauvin%2Fname_manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchauvin%2Fname_manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchauvin%2Fname_manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hchauvin","download_url":"https://codeload.github.com/hchauvin/name_manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hchauvin%2Fname_manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31991720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bazel","concurrency","distributed-lock","docker-compose","end-to-end-testing","integration-testing","test-harness","testing"],"created_at":"2025-09-25T21:40:37.154Z","updated_at":"2026-04-19T02:02:01.297Z","avatar_url":"https://github.com/hchauvin.png","language":"Go","readme":"# `name_manager`: Utility to manage shared test resources with a global lock 🔒\n\n[![CircleCI](https://circleci.com/gh/hchauvin/name_manager.svg?style=svg)](https://circleci.com/gh/hchauvin/name_manager) [![GoDoc](https://godoc.org/github.com/hchauvin/name_manager?status.svg)](https://godoc.org/github.com/hchauvin/name_manager) [![Coverage Status](https://coveralls.io/repos/github/hchauvin/name_manager/badge.svg?branch=master)](https://coveralls.io/github/hchauvin/name_manager?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/hchauvin/name_manager)](https://goreportcard.com/report/github.com/hchauvin/name_manager) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nTests should ideally set up and tear down all the resources they use.\nHowever, sometimes these resources are too expensive and they must be shared.\nFor instance, instead of using a brand new database for each test, one can\nreuse the same database and truncate the tables between the tests.  If\none wants to run tests concurrently, two by two, one can create two databases\nand reuse them in the same way.  `name_manager` can be used to share such\ntest resources between processes and to avoid race conditions where two\nconcurrent tests end up using the same shared resource.\n\n`name_manager` has an obvious application for the concurrent allocation of\nshared test resources, as explained above, but its aim is more generic:\nit is a distributed system, with a global lock, to retrieve unique names while\nensuring that previously acquired names, now released, are reused as much\nas possible.\n\n`name_manager` can be either consumed as a Go package through a standalone\nCommand-Line Interface (CLI).\n\n## Example use\n\nBy default, the `name_manager` uses the local file system as an\ninter-process lock.  There is also a MongoDB backend, which can be used,\ne.g., with Azure CosmosDB.\n\nAs an example use, let's pretend we have a bunch of end-to-end tests on\na webapp.  These tests run on a full app that is deployed with\n`docker-compose`.  Deploying with `docker-compose` is expensive, so we\nstart by using a single docker-compose project and executing the tests\nserially:\n\n```bash\n# Creates the shared resource\ndocker-compose -p stack -f docker-compose.yml up -d\n\nDOCKER_COMPOSE_PROJECT_NAME=stack test_1\nDOCKER_COMPOSE_PROJECT_NAME=stack test_2\nDOCKER_COMPOSE_PROJECT_NAME=stack test_3\nDOCKER_COMPOSE_PROJECT_NAME=stack test_4\n\n# Destroys the shared resource\ndocker-compose -f docker-compose.yml down\n```\n\nNote that, because the tests clean up the shared resource before use,\n`docker-compose down` is not necessary between invocations of the shell\nscript above and will be omitted from now on.\n\nIf the tests all take the same time to complete, and we have enough\nsystem resources, we can more or less halve the execution time, outside of\nthe setup/teardown steps, by providing two stacks and executing the tests\ntwo by two:\n\n```bash\n# Ensures the shared resources are up\ndocker-compose -p stack1 -f docker-compose.yml up -d \u0026\ndocker-compose -p stack2 -f docker-compose.yml up -d \u0026\nwait\n\n(\n  DOCKER_COMPOSE_PROJECT_NAME=stack1 test_1 \u0026\u0026\n  DOCKER_COMPOSE_PROJECT_NAME=stack1 test_2\n) \u0026\n(\n  DOCKER_COMPOSE_PROJECT_NAME=stack2 test_3 \u0026\u0026\n  DOCKER_COMPOSE_PROJECT_NAME=stack2 test_4\n) \u0026\nwait\n```\n\n`name_manager` enables a generalization of this reasoning.  See the\n`./examples` directory for examples.\n\n## Development\n\n`name_manager` is compiled with Go 1.13.\n\nThe integration tests for the mongo backend require a MongoDB server to\nbe running locally:\n\n```bash\ndocker run --name some-mongo -p 27017:27017 mongo:bionic\n\nexport MONGODB_URI=\"mongodb://127.0.0.1:27017\"\ngo test -v ./pkg/mongo_backend/...\n```\n\nThe integration tests for the firestore backend require a Firestore emulator\nto be running locally:\n\n```bash\ndocker run --name some-firestore -p 8080:8080 -e PORT=8080 ridedott/firestore-emulator:1.10.4\n\nexport FIRESTORE_EMULATOR_HOST=\"127.0.0.1:8080\"\ngo test -v ./pkg/firestore_backend/...\n```\n\n## License\n\n`name_manager` is licensed under [The MIT License](./LICENSE).\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhchauvin%2Fname_manager.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhchauvin%2Fname_manager?ref=badge_large)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhchauvin%2Fname_manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhchauvin%2Fname_manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhchauvin%2Fname_manager/lists"}