Gave status schema validation trace events more descriptive names. Fixed schema in tests.

This commit is contained in:
Stephen Atherton 2018-07-05 17:05:47 -07:00
parent 50586b51f1
commit b2fc2b4829
4 changed files with 13 additions and 11 deletions

View File

@ -140,7 +140,7 @@ struct StatusWorkload : TestWorkload {
schemaCoverage(spath);
if (!schema.count(key)) {
TraceEvent(sev, "SchemaMismatch").detail("Path", kpath).detail("SchemaPath", spath);
TraceEvent(sev, "SchemaMismatchKeyNotInSchema").detail("Path", kpath).detail("SchemaPath", spath);
ok = false;
continue;
}
@ -157,13 +157,13 @@ struct StatusWorkload : TestWorkload {
break;
}
if (!any_match) {
TraceEvent(sev, "SchemaMismatch").detail("Path", kpath).detail("SchemaEnumItems", enum_values.size()).detail("Value", json_spirit::write_string(rv));
TraceEvent(sev, "SchemaMismatchValueNotInEnum").detail("Path", kpath).detail("SchemaEnumItems", enum_values.size()).detail("Value", json_spirit::write_string(rv));
schemaCoverage(spath + ".$enum." + json_spirit::write_string(rv));
ok = false;
}
} else if (sv.type() == json_spirit::obj_type && sv.get_obj().count("$map")) {
if (rv.type() != json_spirit::obj_type) {
TraceEvent(sev, "SchemaMismatch").detail("Path", kpath).detail("SchemaType", sv.type()).detail("ValueType", rv.type());
TraceEvent(sev, "SchemaMismatchExpectedMapType").detail("Path", kpath).detail("SchemaType", sv.type()).detail("ValueType", rv.type());
ok = false;
continue;
}
@ -181,7 +181,7 @@ struct StatusWorkload : TestWorkload {
auto vpath = kpath + "[" + value_pair.first + "]";
auto upath = spath + ".$map";
if (value_pair.second.type() != json_spirit::obj_type) {
TraceEvent(sev, "SchemaMismatch").detail("Path", vpath).detail("ValueType", value_pair.second.type());
TraceEvent(sev, "SchemaMismatchExpectedMapType").detail("Path", vpath).detail("ValueType", value_pair.second.type());
ok = false;
continue;
}
@ -191,7 +191,7 @@ struct StatusWorkload : TestWorkload {
} else {
// The schema entry isn't an operator, so it asserts a type and (depending on the type) recursive schema definition
if (normJSONType(sv.type()) != normJSONType(rv.type())) {
TraceEvent(sev, "SchemaMismatch").detail("Path", kpath).detail("SchemaType", sv.type()).detail("ValueType", rv.type());
TraceEvent(sev, "SchemaMismatchType").detail("Path", kpath).detail("SchemaType", sv.type()).detail("ValueType", rv.type());
ok = false;
continue;
}
@ -201,7 +201,7 @@ struct StatusWorkload : TestWorkload {
if (!schema_array.size()) {
// An empty schema array means that the value array is required to be empty
if (value_array.size()) {
TraceEvent(sev, "SchemaMismatch").detail("Path", kpath).detail("SchemaSize", schema_array.size()).detail("ValueSize", value_array.size());
TraceEvent(sev, "SchemaMismatchExpectedEmptyArray").detail("Path", kpath).detail("SchemaSize", schema_array.size()).detail("ValueSize", value_array.size());
ok = false;
continue;
}
@ -211,7 +211,7 @@ struct StatusWorkload : TestWorkload {
int index = 0;
for(auto &value_item : value_array) {
if (value_item.type() != json_spirit::obj_type) {
TraceEvent(sev, "SchemaMismatch").detail("Path", kpath + format("[%d]",index)).detail("ValueType", value_item.type());
TraceEvent(sev, "SchemaMismatchType").detail("Path", kpath + format("[%d]",index)).detail("ValueType", value_item.type());
ok = false;
continue;
}
@ -252,8 +252,10 @@ struct StatusWorkload : TestWorkload {
self->totalSize += br.getLength();
TraceEvent("StatusWorkloadReply").detail("ReplySize", br.getLength()).detail("Latency", now() - issued);//.detail("Reply", json_spirit::write_string(json_spirit::mValue(result)));
if (self->statusSchema.present() && !schemaMatch(self->statusSchema.get(), result) )
if (self->statusSchema.present() && !schemaMatch(self->statusSchema.get(), result) ) {
TraceEvent(SevError, "StatusWorkloadValidationFailed").detail("JSON", json_spirit::write_string(json_spirit::mValue(result)));
//printf("%s\n", json_spirit::write_string(json_spirit::mValue(result), json_spirit::Output_options::pretty_print).c_str());
}
}
catch (Error& e) {
if (e.code() != error_code_actor_cancelled) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long