Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
eos
QuarkDB
Commits
e8595bce
Commit
e8595bce
authored
Jan 15, 2020
by
Georgios Bitzes
Browse files
Implement IptablesHelper to ease blocking / unblocking a port
parent
36f411c6
Pipeline
#1344704
canceled with stages
in 9 minutes and 12 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
e8595bce
# Changelog
## Unreleased
### New features
-
Possibility to choose between three different journal fsync policies through
``RAFT-SET-FSYNC-POLICY``
command.
-
Implementation of
``CLIENT GETNAME``
, and automatic tagging of intercluster
connections.
### Improvements
-
Automatic fsync of the raft journal once per second.
-
Better resilience in case of sudden machine powercuts.
## 0.4.0 (2019-12-06)
### Bug fixes
...
...
qclient
@
b14f94b6
Compare
0da6445c
...
b14f94b6
Subproject commit
0da6445cf5c0c7793b82f703d27d53be72442b2b
Subproject commit
b14f94b6506cee945e3ccdad98251610af385ee1
test/sudo/poweroff.cc
View file @
e8595bce
...
...
@@ -30,6 +30,12 @@ using namespace quarkdb;
class
Poweroff
:
public
TestCluster3NodesFixture
{};
TEST_F
(
Poweroff
,
WithDataLoss
)
{
IptablesHelper
iptables
;
ASSERT_TRUE
(
iptables
.
singleAcceptPackets
(
nodes
()[
0
].
port
));
ASSERT_TRUE
(
iptables
.
singleAcceptPackets
(
nodes
()[
1
].
port
));
ASSERT_TRUE
(
iptables
.
singleAcceptPackets
(
nodes
()[
2
].
port
));
spinup
(
0
);
spinup
(
1
);
spinup
(
2
);
RETRY_ASSERT_TRUE
(
checkStateConsensus
(
0
,
1
,
2
));
...
...
@@ -47,13 +53,13 @@ TEST_F(Poweroff, WithDataLoss) {
int
follower
=
(
leaderID
+
1
)
%
3
;
int
followerPort
=
nodes
()[
follower
].
port
;
ASSERT_
EQ
(
system
(
SSTR
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport "
<<
followerPort
<<
" -j DROP"
).
c_str
()),
0
);
ASSERT_
TRUE
(
iptables
.
singleDropPackets
(
followerPort
)
);
spindown
(
follower
);
ASSERT_TRUE
(
journal
(
follower
)
->
simulateDataLoss
(
3
));
ASSERT_EQ
(
journal
(
follower
)
->
getLogSize
(),
journal
(
leaderID
)
->
getLogSize
()
-
3
);
ASSERT_
EQ
(
system
(
SSTR
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport "
<<
followerPort
<<
" -j ACCEPT"
).
c_str
()),
0
);
ASSERT_
TRUE
(
iptables
.
singleAcceptPackets
(
followerPort
)
);
spinup
(
follower
);
// ensure the leader restores the missing entries
...
...
test/sudo/qclient.cc
View file @
e8595bce
...
...
@@ -21,12 +21,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
************************************************************************/
#include
"../test-utils.hh"
#include
<qclient/QClient.hh>
#include
<gtest/gtest.h>
#include
<chrono>
using
namespace
quarkdb
;
TEST
(
QClient
,
HostDroppingIncomingPacketsConstructor
)
{
ASSERT_EQ
(
system
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport 56789 -j DROP"
),
0
);
IptablesHelper
iptables
;
ASSERT_TRUE
(
iptables
.
singleDropPackets
(
56789
));
qclient
::
Options
opts
;
std
::
unique_ptr
<
qclient
::
QClient
>
qcl
;
...
...
@@ -50,11 +55,12 @@ TEST(QClient, HostDroppingIncomingPacketsConstructor) {
std
::
cout
<<
"Destructor took "
<<
destructorDuration
.
count
()
<<
" ms"
<<
std
::
endl
;
ASSERT_LE
(
destructorDuration
,
std
::
chrono
::
milliseconds
(
50
));
ASSERT_
EQ
(
system
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport 56789 -j ACCEPT"
),
0
);
ASSERT_
TRUE
(
iptables
.
singleAcceptPackets
(
56789
)
);
}
TEST
(
QClient
,
HostDroppingIncomingPacketsFutureTimeout
)
{
ASSERT_EQ
(
system
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport 56789 -j DROP"
),
0
);
IptablesHelper
iptables
;
ASSERT_TRUE
(
iptables
.
singleDropPackets
(
56789
));
qclient
::
Options
opts
;
opts
.
tcpTimeout
=
std
::
chrono
::
seconds
(
3
);
...
...
@@ -72,6 +78,6 @@ TEST(QClient, HostDroppingIncomingPacketsFutureTimeout) {
ASSERT_GE
(
dur
,
std
::
chrono
::
seconds
(
3
));
ASSERT_LE
(
dur
,
std
::
chrono
::
seconds
(
4
));
ASSERT_
EQ
(
system
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport 56789 -j ACCEPT"
),
0
);
ASSERT_
TRUE
(
iptables
.
singleAcceptPackets
(
56789
)
);
}
test/test-utils.cc
View file @
e8595bce
...
...
@@ -398,4 +398,13 @@ void TestNode::spindown() {
shard
()
->
spindown
();
}
bool
IptablesHelper
::
singleDropPackets
(
int
port
)
{
return
system
(
SSTR
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport "
<<
port
<<
" -j DROP"
).
c_str
())
==
0
;
}
bool
IptablesHelper
::
singleAcceptPackets
(
int
port
)
{
return
system
(
SSTR
(
"iptables -I OUTPUT -p tcp --dest 127.0.0.1 --dport "
<<
port
<<
" -j ACCEPT"
).
c_str
())
==
0
;
}
}
test/test-utils.hh
View file @
e8595bce
...
...
@@ -519,6 +519,12 @@ public:
}
};
class
IptablesHelper
{
public:
bool
singleDropPackets
(
int
port
);
bool
singleAcceptPackets
(
int
port
);
};
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment