Committer: Avi Kivity <avi@scylladb.com> Branch: next Switch to the the CMake-ified Seastar This change allows Scylla to be compiled against the `master` branch of Seastar. The necessary changes: - Add `-Wno-error` to prevent a Seastar warning from terminating the build - The new Seastar build system generates the pkg-config files (for example, `seastar.pc`) at configure time, so we don't need to invoke Ninja to generate them - The `-march` argument is no longer inherited from Seastar (correctly), so it needs to be provided independently - Define `SEASTAR_TESTING_MAIN` so that the definition of an entry point is included for all unit test compilation units - Independently link Scylla against Seastar's compiled copy of fmt in its build directory - All test files use the (now public) Seastar testing headers - Add some missing Seastar headers to source files [avi: regenerate frozen toolchain, adjust seastar submoule] Signed-off-by: Jesse Haber-Kucharsky <jhaberku@scylladb.com> Message-Id: <02141f2e1ecff5cbcd56b32768356c3bf62750c4.1548820547.git.jhaberku@scylladb.com>
115 lines
4.7 KiB
C++
115 lines
4.7 KiB
C++
/*
|
|
* Copyright (C) 2015 ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* This file is part of Scylla.
|
|
*
|
|
* Scylla is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Scylla is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
|
|
#include <boost/range/irange.hpp>
|
|
#include <boost/range/adaptors.hpp>
|
|
#include <boost/range/algorithm.hpp>
|
|
#include <boost/test/unit_test.hpp>
|
|
#include <stdint.h>
|
|
|
|
#include <seastar/testing/test_case.hh>
|
|
#include "tests/cql_test_env.hh"
|
|
#include "tests/cql_assertions.hh"
|
|
|
|
#include <seastar/core/future-util.hh>
|
|
#include "transport/messages/result_message.hh"
|
|
#include "cql3/query_processor.hh"
|
|
#include "cql3/untyped_result_set.hh"
|
|
|
|
SEASTAR_TEST_CASE(test_execute_internal_insert) {
|
|
return do_with_cql_env([] (auto& e) {
|
|
auto& qp = e.local_qp();
|
|
return qp.execute_internal("create table ks.cf (p1 varchar, c1 int, r1 int, PRIMARY KEY (p1, c1));").then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
}).then([&qp] {
|
|
return qp.execute_internal("insert into ks.cf (p1, c1, r1) values (?, ?, ?);", { sstring("key1"), 1, 100 }).then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("select * from ks.cf where p1 = ? and c1 = 1;", { sstring("key1") }).then([](auto rs) {
|
|
BOOST_REQUIRE(!rs->empty());
|
|
auto i = rs->one().template get_as<int32_t>("r1");
|
|
BOOST_CHECK_EQUAL(i, int32_t(100));
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("insert into ks.cf (p1, c1, r1) values (?, ?, ?);", { sstring("key2"), 2, 200 }).then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("select * from ks.cf;").then([](auto rs) {
|
|
BOOST_REQUIRE(!rs->empty());
|
|
BOOST_CHECK_EQUAL(rs->size(), 2);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
SEASTAR_TEST_CASE(test_execute_internal_delete) {
|
|
return do_with_cql_env([] (auto& e) {
|
|
auto& qp = e.local_qp();
|
|
return qp.execute_internal("create table ks.cf (p1 varchar, c1 int, r1 int, PRIMARY KEY (p1, c1));").then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
}).then([&qp] {
|
|
return qp.execute_internal("insert into ks.cf (p1, c1, r1) values (?, ?, ?);", { sstring("key1"), 1, 100 }).then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("delete from ks.cf where p1 = ? and c1 = ?;", { sstring("key1"), 1 }).then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("select * from ks.cf;").then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
SEASTAR_TEST_CASE(test_execute_internal_update) {
|
|
return do_with_cql_env([] (auto& e) {
|
|
auto& qp = e.local_qp();
|
|
return qp.execute_internal("create table ks.cf (p1 varchar, c1 int, r1 int, PRIMARY KEY (p1, c1));").then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
}).then([&qp] {
|
|
return qp.execute_internal("insert into ks.cf (p1, c1, r1) values (?, ?, ?);", { sstring("key1"), 1, 100 }).then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("select * from ks.cf where p1 = ? and c1 = 1;", { sstring("key1") }).then([](auto rs) {
|
|
BOOST_REQUIRE(!rs->empty());
|
|
auto i = rs->one().template get_as<int32_t>("r1");
|
|
BOOST_CHECK_EQUAL(i, int32_t(100));
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("update ks.cf set r1 = ? where p1 = ? and c1 = ?;", { 200, sstring("key1"), 1 }).then([](auto rs) {
|
|
BOOST_REQUIRE(rs->empty());
|
|
});
|
|
}).then([&qp] {
|
|
return qp.execute_internal("select * from ks.cf where p1 = ? and c1 = 1;", { sstring("key1") }).then([](auto rs) {
|
|
BOOST_REQUIRE(!rs->empty());
|
|
auto i = rs->one().template get_as<int32_t>("r1");
|
|
BOOST_CHECK_EQUAL(i, int32_t(200));
|
|
});
|
|
});
|
|
});
|
|
}
|