Commit 0da767c0 authored by Paal Kvamme's avatar Paal Kvamme
Browse files

Extend tests of IZgyWriter::reopen() to also include cloud access.

parent 7f04be37
......@@ -65,6 +65,30 @@ namespace {
}
}
namespace {
#if 0
}
#endif
#ifdef HAVE_SD
/**
* Convenience to hard code credentials for testing. Returns an IOContext.
* Picking up sdurl/sdapikey from the environment is redundant since
* the library already does this as a fallback.
*/
SeismicStoreIOContext getContext()
{
using InternalZGY::Environment;
return SeismicStoreIOContext()
.sdurl(Environment::getStringEnv("OPENZGY_SDURL"))
.sdapikey(Environment::getStringEnv("OPENZGY_SDAPIKEY"))
.sdtoken(Environment::getStringEnv("OPENZGY_TOKEN") != "" ?
Environment::getStringEnv("OPENZGY_TOKEN") :
"FILE:carbon.slbapp.com", "");
}
#endif
}
namespace Test_API {
#if 0
}
......@@ -594,10 +618,11 @@ void test_ZgyWriterArgs()
TEST_CHECK(ss.str().find("\"ms\"") != std::string::npos);
}
static void do_write_once(const std::string& filename)
static void do_write_once(const std::string& filename, const IOContext *context = nullptr)
{
LocalFileAutoDelete lad("testfile.zgy");
ZgyWriterArgs args = ZgyWriterArgs()
.iocontext(context)
.filename(filename)
.size(33, 28, 92)
.datatype(SampleDataType::int16)
......@@ -620,9 +645,9 @@ static void do_write_once(const std::string& filename)
writer->close();
}
static void do_check_written(const std::string& filename)
static void do_check_written(const std::string& filename, const IOContext* context = nullptr)
{
std::shared_ptr<OpenZGY::IZgyReader> reader = OpenZGY::IZgyReader::open(filename);
std::shared_ptr<OpenZGY::IZgyReader> reader = OpenZGY::IZgyReader::open(filename, context);
if (verbose()) {
std::cout << "\n";
dump_api(reader, std::cout);
......@@ -663,9 +688,10 @@ static void do_check_written(const std::string& filename)
/**
* As do_write_once() but the file gets opened, closed, and opened again.
*/
static void do_write_twice(const std::string& filename)
static void do_write_twice(const std::string& filename, const IOContext* context = nullptr)
{
ZgyWriterArgs firstargs = ZgyWriterArgs()
.iocontext(context)
.filename(filename)
.size(33, 28, 92)
.bricksize(64, 64, 64)
......@@ -673,6 +699,7 @@ static void do_write_twice(const std::string& filename)
.datarange(-32768,+32767);
ZgyWriterArgs secondargs = ZgyWriterArgs()
.iocontext(context)
.filename(filename)
.ilstart(1).ilinc(2)
.xlstart(500).xlinc(5)
......@@ -717,12 +744,29 @@ void test_update()
do_check_written(lad.name());
}
// TODO-TEST:
//void test_update_cloud()
//{
// CloudFileAutoDelete lad("updatecloud.zgy");
// do_update(lad.name());
//}
#ifdef HAVE_SD
void
test_write_cloud()
{
SeismicStoreIOContext context = getContext();
// TODO-Low, this CloudFileAutoDelete doesn't actually clean up.
// Hopefully the test or the cleanup task will handle it.
Test_Utils::CloudFileAutoDelete cad("writecloud.zgy");
do_write_once(cad.name(), &context);
do_check_written(cad.name(), &context);
}
void
test_update_cloud()
{
SeismicStoreIOContext context = getContext();
// TODO-Low, this CloudFileAutoDelete doesn't actually clean up.
// Hopefully the test or the cleanup task will handle it.
Test_Utils::CloudFileAutoDelete cad("updatecloud.zgy");
do_write_twice(cad.name(), &context);
do_check_written(cad.name(), &context);
}
#endif
void test_historange()
{
......@@ -1368,7 +1412,10 @@ public:
register_test("api.readbadpos", test_readbadpos);
register_test("api.write", test_write);
register_test("api.update", test_update);
// TODO-TEST: register_test("api.update_cloud", test_update_cloud);
#ifdef HAVE_SD
register_test("api.write_cloud", test_write_cloud);
register_test("api.update_cloud", test_update_cloud);
#endif
register_test("api.historange", test_historange);
register_test("api.lod_lowpass", test_lod_lowpass);
register_test("api.lod_weighted", test_lod_weighted);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment