Skip to content

Commit 5db7ae3

Browse files
authored
Merge pull request mysql#10 from planetscale/piki/fix-the-unit-tests
Fix the unit tests and generate a working container
2 parents e964b38 + 7a0cf93 commit 5db7ae3

File tree

6 files changed

+72
-11
lines changed

6 files changed

+72
-11
lines changed

Dockerfile.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN apt-get update && apt-get upgrade -y
44

55
ENV DEBIAN_FRONTEND noninteractive
66

7-
ADD . /src
7+
ADD --chown=1234 . /src
88
WORKDIR /src
99

1010
RUN apt-get install -y \
@@ -25,4 +25,7 @@ RUN apt-get install -y \
2525
libnuma-dev \
2626
libmecab-dev \
2727
libssl-dev \
28+
net-tools \
2829
git-core
30+
31+
RUN adduser --disabled-password --no-create-home --gecos '' bob --uid 1234

Dockerfile.release

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@ ENV DEBIAN_FRONTEND noninteractive
77
RUN apt-get install -y \
88
libaio1 \
99
libnuma1 \
10+
libtcmalloc-minimal4 \
1011
binutils
1112

1213
ADD dist/ /dist
1314

14-
RUN tar -xzvf /dist/mysql-8.0.28-linux-x86_64.tar.gz -C /usr --strip-components=1 && strip /usr/bin/mysql* || true && rm -rf /dist/*.tar.gz
15+
RUN tar -xzvf /dist/mysql-8.0.28-linux-x86_64.tar.gz -C /usr --strip-components=1
16+
RUN strip /usr/bin/mysql* || true
17+
RUN cd /usr ; chown root.root $(tar tzf /dist/mysql-8.0.28-linux-x86_64.tar.gz | cut -d/ -f2-)
18+
RUN rm -rf /dist/*.tar.gz
1519
RUN apt-get remove -y binutils && apt-get autoremove -y
1620
RUN rm -rf /usr/mysql-test
21+
22+
RUN adduser --disabled-password --no-create-home --gecos '' vitess --uid 999
23+
RUN mkdir /var/run/mysqld
24+
RUN chown vitess.vitess /var/run/mysqld
25+
26+
USER vitess

build.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ $(id -u) -eq 0 ]; then
6+
su bob -c ./build.sh
7+
cp build/*.tar.gz /dist/
8+
exit
9+
fi
10+
111
if [ -d build ]; then
212
rm -rf build
313
fi
414

5-
mkdir build && cd build
15+
mkdir build
16+
cd build
617

718
cmake \
819
-DBUILD_CONFIG=mysql_release \
@@ -25,8 +36,13 @@ cmake \
2536
-DWITH_INNODB_MEMCACHED=1 \
2637
-DWITH_MECAB=system \
2738
-DWITH_NUMA=ON \
28-
.. && \
29-
make -j $(nproc) && \
30-
make package -j $(nproc)
39+
-DWITH_ROUTER=OFF \
40+
..
41+
42+
make -j $(nproc)
43+
44+
DISABLE_IPV6_TESTS=1 DISABLE_TMPFILE_TESTS=1 make test ARGS="-j $(nproc) -E ^routertest -VV"
45+
46+
strip -g runtime_output_directory/mysql*
3147

32-
cp *.tar.gz /dist/
48+
make -j $(nproc) package

router/src/harness/tests/test_net_ts_internet.cc

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,11 @@ TEST(NetTS_internet, tcp_ipv4_socket_bind_accept_connect_dynbuffer) {
637637
}
638638

639639
TEST(NetTS_internet, tcp_ipv6_socket_bind_accept_connect) {
640+
if (getenv("DISABLE_IPV6_TESTS")) {
641+
// fails when ipv6 is present but disabled
642+
GTEST_SKIP();
643+
}
644+
640645
net::io_context io_ctx;
641646

642647
net::ip::tcp::endpoint endp = net_ipv6_any_port_endpoint();
@@ -724,6 +729,11 @@ TEST(NetTS_internet, tcp_ipv6_socket_bind_accept_connect) {
724729
}
725730

726731
TEST(NetTS_internet, udp_ipv6_socket_bind_accept_connect) {
732+
if (getenv("DISABLE_IPV6_TESTS")) {
733+
// fails when ipv6 is present but disabled
734+
GTEST_SKIP();
735+
}
736+
727737
net::io_context io_ctx;
728738

729739
// any ip, any port
@@ -881,13 +891,19 @@ class NetTS_internet_async : public ::testing::Test,
881891
// the receiving side calls net::async_receive() which should read until the
882892
// end-of-stream.
883893
TEST_P(NetTS_internet_async, tcp_client_send_close) {
884-
net::io_context io_ctx;
885894

886895
using protocol_type = net::ip::tcp;
887896

888897
// localhost, any port
889898
protocol_type::endpoint endp = std::get<1>(GetParam());
890899

900+
if (getenv("DISABLE_IPV6_TESTS") && endp == net_ipv6_any_port_endpoint()) {
901+
// fails when ipv6 is present but disabled
902+
GTEST_SKIP();
903+
}
904+
905+
net::io_context io_ctx;
906+
891907
protocol_type::acceptor acceptor(io_ctx);
892908
EXPECT_THAT(acceptor.open(endp.protocol()), ::testing::Truly(res_has_value));
893909
auto bind_res = acceptor.bind(endp);
@@ -989,6 +1005,11 @@ TEST_P(NetTS_internet_async, tcp_accept_with_endpoint) {
9891005
// localhost, any port
9901006
protocol_type::endpoint endp = std::get<1>(GetParam());
9911007

1008+
if (getenv("DISABLE_IPV6_TESTS") && endp == net_ipv6_any_port_endpoint()) {
1009+
// fails when ipv6 is present but disabled
1010+
GTEST_SKIP();
1011+
}
1012+
9921013
protocol_type::acceptor acceptor(io_ctx);
9931014
EXPECT_THAT(acceptor.open(endp.protocol()), ::testing::Truly(res_has_value));
9941015
auto bind_res = acceptor.bind(endp);

router/tests/component/test_http_server.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ static_assert(sizeof(kInvalidBindAddress) > 7 + 1,
7171
"kInvalidBindAddress is too short");
7272
#endif
7373

74+
const std::string localhost_ipv4("127.0.0.1");
75+
const std::string localhost_ipv6("::1");
76+
7477
using namespace std::chrono_literals;
7578

7679
const std::string kHttpBasedir(kPlaceholderHttpBaseDir);
@@ -213,6 +216,11 @@ TempDirectory HttpServerPlainTest::http_base_dir_;
213216
* - make a client connect to the http-server
214217
*/
215218
TEST_P(HttpServerPlainTest, ensure) {
219+
if (getenv("DISABLE_IPV6_TESTS") && GetParam().http_hostname == localhost_ipv6) {
220+
// fails when ipv6 is present but disabled
221+
GTEST_SKIP();
222+
}
223+
216224
std::vector<std::pair<std::string, std::string>> http_section;
217225
http_section.reserve(GetParam().http_section.size());
218226

@@ -313,9 +321,6 @@ TEST_P(HttpServerPlainTest, ensure) {
313321
}
314322
}
315323

316-
const std::string localhost_ipv4("127.0.0.1");
317-
const std::string localhost_ipv6("::1");
318-
319324
static const HttpServerPlainParams http_server_static_files_params[]{
320325
{"bind-address-ipv4-any",
321326
"WL11891::TS-3",

unittest/gunit/mysys_pathfuncs-t.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ TEST(Mysys, LoadPathOverflow) {
142142

143143
#ifdef HAVE_O_TMPFILE
144144
TEST(Mysys, CreateTempFile) {
145+
if (getenv("DISABLE_TMPFILE_TESTS")) {
146+
// In Docker, /tmp is a plain subdirectory under /, which is an overlayfs
147+
// O_TMPFILE does not work on overlayfs
148+
GTEST_SKIP();
149+
}
150+
145151
char dst[FN_REFLEN];
146152
aset(dst, 0xaa);
147153

0 commit comments

Comments
 (0)