mirror of
https://github.com/cirruslabs/tart.git
synced 2026-10-01 19:51:10 +02:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e0dbcea4b | ||
|
|
3f1624e31a |
@@ -19,7 +19,7 @@ class ControlSocket {
|
||||
func run() async throws {
|
||||
// Remove control socket file from previous "tart run" invocations,
|
||||
// if any, otherwise we may get the "address already in use" error
|
||||
try? FileManager.default.removeItem(atPath: controlSocketURL.path())
|
||||
try? FileManager.default.removeItem(atPath: controlSocketURL.path)
|
||||
|
||||
// Change the current working directory to a VM's base directory
|
||||
// to work around Unix domain socket 104 byte limitation [1]
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import XCTest
|
||||
@testable import tart
|
||||
|
||||
final class ControlSocketURLTests: XCTestCase {
|
||||
func testControlSocketURLResolvesToAbsolutePath() throws {
|
||||
let baseURL = URL(fileURLWithPath: "/Users/test/.tart/vms/myvm/")
|
||||
let vmDir = VMDirectory(baseURL: baseURL)
|
||||
|
||||
// The .path property resolves relative URLs to absolute paths,
|
||||
// which is required for stale socket cleanup in ControlSocket.run()
|
||||
// since it happens before the working directory is changed.
|
||||
XCTAssertEqual(
|
||||
vmDir.controlSocketURL.path,
|
||||
"/Users/test/.tart/vms/myvm/control.sock"
|
||||
)
|
||||
}
|
||||
|
||||
func testControlSocketURLRelativePathIsJustFilename() throws {
|
||||
let baseURL = URL(fileURLWithPath: "/Users/test/.tart/vms/myvm/")
|
||||
let vmDir = VMDirectory(baseURL: baseURL)
|
||||
|
||||
// The .relativePath is used for socket binding after cwd is changed
|
||||
XCTAssertEqual(
|
||||
vmDir.controlSocketURL.relativePath,
|
||||
"control.sock"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import requests
|
||||
|
||||
from testcontainers.core.waiting_utils import wait_container_is_ready
|
||||
from testcontainers.core.container import DockerContainer
|
||||
from testcontainers.core.wait_strategies import HttpWaitStrategy
|
||||
|
||||
|
||||
class DockerRegistry(DockerContainer):
|
||||
@@ -10,11 +8,9 @@ class DockerRegistry(DockerContainer):
|
||||
def __init__(self):
|
||||
super().__init__("registry:2")
|
||||
self.with_exposed_ports(self._default_exposed_port)
|
||||
self.waiting_for(HttpWaitStrategy(self._default_exposed_port, "/v2/").for_status_code(200))
|
||||
|
||||
@wait_container_is_ready(requests.exceptions.ConnectionError)
|
||||
def remote_name(self, for_vm: str):
|
||||
exposed_port = self.get_exposed_port(self._default_exposed_port)
|
||||
|
||||
requests.get(f"http://127.0.0.1:{exposed_port}/v2/")
|
||||
|
||||
return f"127.0.0.1:{exposed_port}/tart/{for_vm}:latest"
|
||||
|
||||
Reference in New Issue
Block a user