MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestOTLPWriteHandler

Function TestOTLPWriteHandler

pkg/util/push/otlp_test.go:1051–1154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1049}
1050
1051func TestOTLPWriteHandler(t *testing.T) {
1052 cfg := distributor.OTLPConfig{
1053 ConvertAllAttributes: false,
1054 DisableTargetInfo: false,
1055 }
1056
1057 exportRequest := generateOTLPWriteRequest()
1058
1059 tests := []struct {
1060 description string
1061 maxRecvMsgSize int
1062 contentType string
1063 expectedStatusCode int
1064 expectedErrMsg string
1065 encodingType string
1066 }{
1067 {
1068 description: "Test proto format write with no compression",
1069 maxRecvMsgSize: 10000,
1070 contentType: pbContentType,
1071 expectedStatusCode: http.StatusOK,
1072 },
1073 {
1074 description: "Test proto format write with gzip",
1075 maxRecvMsgSize: 10000,
1076 contentType: pbContentType,
1077 expectedStatusCode: http.StatusOK,
1078 encodingType: "gzip",
1079 },
1080 {
1081 description: "Test json format write with no compression",
1082 maxRecvMsgSize: 10000,
1083 contentType: jsonContentType,
1084 expectedStatusCode: http.StatusOK,
1085 },
1086 {
1087 description: "Test json format write with gzip",
1088 maxRecvMsgSize: 10000,
1089 contentType: jsonContentType,
1090 expectedStatusCode: http.StatusOK,
1091 encodingType: "gzip",
1092 },
1093 {
1094 description: "request too big than maxRecvMsgSize (proto) with no compression",
1095 maxRecvMsgSize: 10,
1096 contentType: pbContentType,
1097 expectedStatusCode: http.StatusBadRequest,
1098 expectedErrMsg: "received message larger than max",
1099 },
1100 {
1101 description: "request too big than maxRecvMsgSize (proto) with gzip",
1102 maxRecvMsgSize: 10,
1103 contentType: pbContentType,
1104 expectedStatusCode: http.StatusBadRequest,
1105 expectedErrMsg: "received message larger than max",
1106 encodingType: "gzip",
1107 },
1108 {

Callers

nothing calls this directly

Calls 9

NewOverridesFunction · 0.92
DefaultLimitsConfigFunction · 0.92
generateOTLPWriteRequestFunction · 0.85
getOTLPHttpRequestFunction · 0.85
OTLPHandlerFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected