17 #ifndef __TEST_DOCKER_COMMON_HPP__ 18 #define __TEST_DOCKER_COMMON_HPP__ 51 static constexpr
char DOCKER_TEST_IMAGE[] =
"akagup/nano-admin";
57 static constexpr
char DOCKER_HTTP_IMAGE[] =
"akagup/https-server";
58 static constexpr
char DOCKER_HTTP_COMMAND[] =
"http.exe";
59 static constexpr
char DOCKER_HTTPS_IMAGE[] =
"akagup/https-server";
60 static constexpr
char DOCKER_HTTPS_COMMAND[] =
"http.exe";
62 static constexpr
char DOCKER_TEST_IMAGE[] =
"alpine";
65 static constexpr
char DOCKER_HTTP_IMAGE[] =
"alpine";
66 static constexpr
char DOCKER_HTTP_COMMAND[] =
67 "nc -lk -p 80 -e echo -e \"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\"";
71 static constexpr
char DOCKER_HTTPS_IMAGE[] =
"zhq527725/https-server";
72 static constexpr
char DOCKER_HTTPS_COMMAND[] =
"python https_server.py 443";
83 if (docker.isError()) {
88 if (directory.isError()) {
92 return docker.get()->pull(directory.get(), imageName)
117 "docker network create --driver=bridge --ipv6 " 118 "--subnet=fd01::/64 %s",
119 DOCKER_IPv6_NETWORK);
127 ASSERT_SOME(s) <<
"Unable to create the Docker IPv6 network: " 138 <<
"Unable to create the Docker IPv6 network " 139 << DOCKER_IPv6_NETWORK
140 <<
" : " << err.
get();
141 #endif // __WINDOWS__ 163 ASSERT_SOME(s) <<
"Unable to delete the Docker IPv6 network: " 174 <<
"Unable to delete the Docker IPv6 network " 175 << DOCKER_IPv6_NETWORK
176 <<
" : " << err.
get();
177 #endif // __WINDOWS__ 189 #endif // __WINDOWS__ 196 #endif // __TEST_DOCKER_COMMON_HPP__ Try< Nothing > rmdir(const std::string &directory, bool recursive=true, bool removeRoot=true, bool continueOnError=false)
Definition: rmdir.hpp:42
Definition: nothing.hpp:16
T & get()&
Definition: try.hpp:80
const T & get() const
Definition: future.hpp:1294
void removeDockerIPv6UserNetwork()
Definition: docker_common.hpp:145
const mode_t SIGKILL
Definition: windows.hpp:335
Definition: future.hpp:668
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
static IO PATH(const std::string &path)
#define AWAIT_EXPECT_WEXITSTATUS_EQ(expected, actual)
Definition: gtest.hpp:661
Try< Subprocess > subprocess(const std::string &path, std::vector< std::string > argv, const Subprocess::IO &in=Subprocess::FD(STDIN_FILENO), const Subprocess::IO &out=Subprocess::FD(STDOUT_FILENO), const Subprocess::IO &err=Subprocess::FD(STDERR_FILENO), const flags::FlagsBase *flags=nullptr, const Option< std::map< std::string, std::string >> &environment=None(), const Option< lambda::function< pid_t(const lambda::function< int()> &)>> &clone=None(), const std::vector< Subprocess::ParentHook > &parent_hooks={}, const std::vector< Subprocess::ChildHook > &child_hooks={}, const std::vector< int_fd > &whitelist_fds={})
Forks a subprocess and execs the specified 'path' with the specified 'argv', redirecting stdin...
Option< int_fd > err() const
Definition: subprocess.hpp:264
#define AWAIT_READY(actual)
Definition: gtest.hpp:282
void assertDockerKillStatus(process::Future< Option< int >> &status)
Definition: docker_common.hpp:181
process::Future< Nothing > pullDockerImage(const std::string &imageName)
Definition: docker_common.hpp:78
static Try< process::Owned< Docker > > create(const std::string &path, const std::string &socket, bool validate=true, const Option< JSON::Object > &config=None())
const T & get() const &
Definition: option.hpp:119
static Try error(const E &e)
Definition: try.hpp:43
Definition: attributes.hpp:24
bool isError() const
Definition: try.hpp:78
void then(lambda::CallableOnce< X(const T &)> &&f, std::unique_ptr< Promise< X >> promise, const Future< T > &future)
Definition: future.hpp:1487
constexpr char DOCKER_IPv6_NETWORK[]
Definition: docker_common.hpp:75
void createDockerIPv6UserNetwork()
Definition: docker_common.hpp:109
Future< size_t > read(int_fd fd, void *data, size_t size)
Performs a single non-blocking read by polling on the specified file descriptor until any data can be...
Try< std::string > format(const std::string &s, const T &...t)
Definition: format.hpp:58
#define ASSERT_SOME(actual)
Definition: gtest.hpp:128
#define AWAIT_EXPECT_WEXITSTATUS_NE(expected, actual)
Definition: gtest.hpp:708
Future< Option< int > > status() const
Exit status of this subprocess captured as a Future (completed when the subprocess exits)...
Definition: subprocess.hpp:290
Try< std::string > mkdtemp(const std::string &path=path::join(os::temp(),"XXXXXX"))
Definition: mkdtemp.hpp:38