summaryrefslogtreecommitdiff
path: root/libnetwork/testutils
Commit message (Collapse)AuthorAgeFilesLines
* libnet/testutils: spawn goroutines in test OS ctxsCory Snider2022-11-083-33/+177
| | | | | | | | | | | | There are a handful of libnetwork tests which need to have multiple concurrent goroutines inside the same test OS context (network namespace), including some platform-agnostic tests. Provide test utilities for spawning goroutines inside an OS context and setting/restoring an existing goroutine's OS context to abstract away platform differences and so that each test does not need to reinvent the wheel. Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork_test: remove in-container special caseCory Snider2022-11-082-11/+11
| | | | | | | | | | | | | | | | | | | The SetupTestOSContext calls were made conditional in https://github.com/moby/libnetwork/pull/148 to work around limitations in runtime.LockOSThread() which existed before Go 1.10. This workaround is no longer necessary now that runtime.UnlockOSThread() needs to be called an equal number of times before the goroutine is unlocked from the OS thread. Unfortunately some tests break when SetupTestOSContext is not skipped. (Evidently this code path has not been exercised in a long time.) A newly-created network namespace is very barebones: it contains a loopback interface in the down state and little else. Even pinging localhost does not work inside of a brand new namespace. Set the loopback interface to up during namespace setup so that tests which need to use the loopback interface can do so. Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork/testutils: restore netns on teardownCory Snider2022-10-241-10/+24
| | | | | | | | | | | | | | | | testutils.SetupTestOSContext() sets the calling thread's network namespace but neglected to restore it on teardown. This was not a problem in practice as it called runtime.LockOSThread() twice but runtime.UnlockOSThread() only once, so the tampered threads would be terminated by the runtime when the test case returned and replaced with a clean thread. Correct the utility so it restores the thread's network namespace during teardown and unlocks the goroutine from the thread on success. Remove unnecessary runtime.LockOSThread() calls peppering test cases which leverage testutils.SetupTestOSContext(). Signed-off-by: Cory Snider <csnider@mirantis.com>
* gofmt GoDoc comments with go1.19Sebastiaan van Stijn2022-07-082-4/+2
| | | | | | | | Older versions of Go don't format comments, so committing this as a separate commit, so that we can already make these changes before we upgrade to Go 1.19. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Update to Go 1.17.0, and gofmt with Go 1.17Sebastiaan van Stijn2021-08-241-0/+1
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* libnetwork: remove CircleCI config and codeSebastiaan van Stijn2021-06-092-17/+2
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Fix issues running libnetwork tests.Brian Goff2021-06-011-4/+5
| | | | | | | | libnetwork does different stuff depending on if you are running the tests in a container or not... without telling it we are in a container a bunch of the tests actually fail. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix libnetwork importsBrian Goff2021-06-011-1/+1
| | | | | | | | | After moving libnetwork to this repo, we need to update all the import paths for libnetwork to point to docker/docker/libnetwork instead of docker/libnetwork. This change implements that. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Revert "Adjust LockOSThread"Arko Dasgupta2019-08-151-0/+2
| | | | | | | | | This reverts commit 94af1e5af201a87c651ef1a531bb19efdcd413e0. The reason to revert this is, that TestCreateParallel is continously failing and breaking the CI Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
* Adjust LockOSThreadFlavio Crisciani2018-07-251-2/+0
| | | | | | | | | | | | | | | | | | | Go 1.10 fixed the problem related to thread and namespaces. Details: https://github.com/golang/go/commit/2595fe7fb6f272f9204ca3ef0b0c55e66fb8d90f In few words there is no more the possibility to have a go routine running on a thread that is another namespace. In this commit some cleanup is done and the method SetNamespace is being removed. This will save tons of setns syscall, that were happening way too frequently possibily to make sure that each operation was being done in the host namespace. I suspect that also all the drivers not running in a different namespace would be able to drop also the lock of the OS Thread but will address it in a different commit Removed useless LockOSThreads around Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* Remove Solaris supportSebastiaan van Stijn2017-10-251-23/+0
| | | | | | | | Solaris support for Docker will likely not reach completion, so removing these files as they are not in use and not maintained. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Fixed code issuesFlavio Crisciani2017-06-122-4/+0
| | | | | | Fixed issues highlighted by the new checks Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* libnetwork support for SolarisPuneet Pruthi2016-10-141-0/+25
| | | | Signed-off-by: Puneet Pruthi <puneetpruthi@gmail.com>
* Migrate libnetwork to use netlink.HandleAlessandro Boch2016-06-081-0/+2
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Fixed build tags for linux filesmsabansal2016-02-171-1/+1
| | | | Signed-off-by: msabansal <sabansal@microsoft.com>
* Windows HNS integrationmsabansal2016-02-122-0/+27
| | | | Signed-off-by: msabansal <sabansal@microsoft.com>
* Disable DAD for sandbox IPv6 addressesAlessandro Boch2016-01-051-0/+6
| | | | Signed-off-by: Alessandro Boch <aboch@docker.com>
* Move test specific functions to a testutils package.David Calavera2015-09-072-0/+49
This way we won't vendor test related functions in docker anymore. It also moves netns related functions to a new ns package to be able to call the ns init function in tests. I think this also helps with the overall package isolation. Signed-off-by: David Calavera <david.calavera@gmail.com>