Add additional e2e test for v2->v1->v2 conversion
@@ -3,6 +3,8 @@ package conversion_test
import (
. "plumbing/conversion"
+ v2 "plumbing/v2"
+
"github.com/cloudfoundry/sonde-go/events"
"github.com/gogo/protobuf/proto"
@@ -150,3 +152,56 @@ var _ = DescribeTable("v1->v2->v1",
},
}),
)
+
+var ValueText = func(s string) *v2.Value {
+ return &v2.Value{&v2.Value_Text{Text: s}}
+}
+
+var ValueInteger = func(i int64) *v2.Value {
+ return &v2.Value{&v2.Value_Integer{Integer: i}}
+}
+
+var _ = FDescribeTable("v2->v1->v2",
+
+ func(v2e *v2.Envelope) {
+ _, err := proto.Marshal(v2e)
+ Expect(err).ToNot(HaveOccurred())
+
+ v1e := ToV1(v2e)
+
+ _, err = proto.Marshal(v1e)
+ Expect(err).ToNot(HaveOccurred())
+
+ newV2e := ToV2(v1e)
+ Expect(newV2e).To(Equal(v2e))
+ },
+ Entry("HttpStartStop", &v2.Envelope{
+ SourceId: "b3015d69-09cd-476d-aace-ad2d824d5ab7",
+ Message: &v2.Envelope_Timer{
+ Timer: &v2.Timer{
+ Name: "http",
+ Start: 99,
+ Stop: 100,
+ },
+ },
+ Tags: map[string]*v2.Value{
+ "request_id": ValueText("954f61c4-ac84-44be-9217-cdfa3117fb41"),
+ "peer_type": ValueText("Client"),
+ "method": ValueText("GET"),
+ "uri": ValueText("/hello-world"),
+ "remote_address": ValueText("10.1.1.0"),
+ "user_agent": ValueText("Mozilla/5.0"),
+ "status_code": ValueInteger(200),
+ "content_length": ValueInteger(1000000),
+ "instance_index": ValueInteger(10),
+ "instance_id": ValueText("application-id"),
+ "forwarded": ValueText("6.6.6.6\n8.8.8.8"),
+ "deployment": ValueText("some-deployment"),
+ "ip": ValueText("some-ip"),
+ "job": ValueText("some-job"),
+ "origin": ValueText("some-origin"),
+ "index": ValueText("some-index"),
+ "__v1_type": ValueText("HttpStartStop"),
+ },
+ }),
+)
