Skip to content
Snippets Groups Projects
Commit 8ed742ff authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

Fix tests

parent 8c1e3792
No related branches found
No related tags found
No related merge requests found
......@@ -261,6 +261,9 @@ func filterStreamsByStatus(rec StreamInfo, streamStatus string) bool {
func filterStreams(rec StreamsRecord, pars GetStreamsParams) []StreamInfo {
if len(rec.Streams) == 0 {
return rec.Streams
}
if pars.Last {
return rec.Streams[len(rec.Streams)-1:]
}
......
......@@ -461,12 +461,11 @@ StreamInfo ProducerImpl::StreamRequest(StreamRequestOp op, std::string stream, u
Error parse_err;
auto parser = JsonStringParser(std::move(response));
*err = parser.GetArrayRawStrings("streams", &streams_encoded);
if (*err) {
if (*err || streams_encoded.size()==0 ) {
return StreamInfo{};
}
StreamInfo si;
std::cout << "First stream " << streams_encoded[0] << "\n";
auto ok = si.SetFromJson(streams_encoded[0]);
if (!ok) {
*err = GeneralErrorTemplates::kSimpleError.Generate("cannot parse " + streams_encoded[0]);
......
#include "asapo/producer_c.h"
#include "testing_c.h"
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
......@@ -73,12 +74,13 @@ void test_streams(AsapoProducerHandle producer) {
EXIT_IF_ERROR("asapo_producer_get_last_stream", err);
ASSERT_EQ_STRING("default",asapo_stream_info_get_name(sinfo_last),"stream name");
ASSERT_EQ_INT(1,(uint64_t)asapo_stream_info_get_ffinished(sinfo_last),"stream finished");
ASSERT_EQ_INT(2,asapo_stream_info_get_last_id(sinfo_last),"last id 0");
ASSERT_EQ_INT(1,asapo_stream_info_get_last_id(sinfo_last),"last id 0");
asapo_free_handle(&sinfo_last);
asapo_producer_delete_stream(producer,"default",5000,1,1,&err);
EXIT_IF_ERROR("asapo_producer_delete_stream", err);
sleep(1); // If no sleep, last stream info will come from broker cache
sinfo_last = asapo_producer_get_last_stream(producer,2000,&err);
EXIT_IF_ERROR("asapo_producer_get_last_stream after deletion", err);
......
......@@ -214,7 +214,7 @@ print("created: ",datetime.utcfromtimestamp(info['timestampCreated']/1000000000)
print("last record: ",datetime.utcfromtimestamp(info['timestampLast']/1000000000).strftime('%Y-%m-%d %H:%M:%S.%f'))
info = producer.stream_info('stream/test $')
assert_eq(info['lastId'], 3, "last id from different stream")
assert_eq(info['lastId'], 2, "last id from different stream")
assert_eq(info['finished'], True, "stream finished")
info = producer.stream_info('dataset_stream')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment