You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zipkin.apache.org by ad...@apache.org on 2019/04/30 03:24:46 UTC

[incubator-zipkin-api] branch proto-check created (now f5341c9)

This is an automated email from the ASF dual-hosted git repository.

adriancole pushed a change to branch proto-check
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin-api.git.


      at f5341c9  Adds validation of protobuf api

This branch includes the following new commits:

     new f5341c9  Adds validation of protobuf api

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-zipkin-api] 01/01: Adds validation of protobuf api

Posted by ad...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

adriancole pushed a commit to branch proto-check
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin-api.git

commit f5341c9f1b6cb661ff21642b970d9c4954c280e3
Author: Adrian Cole <ac...@pivotal.io>
AuthorDate: Tue Apr 30 11:24:23 2019 +0800

    Adds validation of protobuf api
---
 package-lock.json | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 package.json      |   1 +
 validate.test.js  |  52 ++++++++++++++++++++-------
 3 files changed, 144 insertions(+), 12 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index cda7e89..1bfb6b0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -393,6 +393,70 @@
         "@types/yargs": "^12.0.9"
       }
     },
+    "@protobufjs/aspromise": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz",
+      "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=",
+      "dev": true
+    },
+    "@protobufjs/base64": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz",
+      "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==",
+      "dev": true
+    },
+    "@protobufjs/codegen": {
+      "version": "2.0.4",
+      "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz",
+      "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==",
+      "dev": true
+    },
+    "@protobufjs/eventemitter": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz",
+      "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=",
+      "dev": true
+    },
+    "@protobufjs/fetch": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz",
+      "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=",
+      "dev": true,
+      "requires": {
+        "@protobufjs/aspromise": "^1.1.1",
+        "@protobufjs/inquire": "^1.1.0"
+      }
+    },
+    "@protobufjs/float": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz",
+      "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=",
+      "dev": true
+    },
+    "@protobufjs/inquire": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz",
+      "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=",
+      "dev": true
+    },
+    "@protobufjs/path": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz",
+      "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=",
+      "dev": true
+    },
+    "@protobufjs/pool": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz",
+      "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=",
+      "dev": true
+    },
+    "@protobufjs/utf8": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz",
+      "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=",
+      "dev": true
+    },
     "@types/babel__core": {
       "version": "7.1.1",
       "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.1.tgz",
@@ -440,6 +504,18 @@
       "integrity": "sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg==",
       "dev": true
     },
+    "@types/long": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.0.tgz",
+      "integrity": "sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q==",
+      "dev": true
+    },
+    "@types/node": {
+      "version": "10.14.6",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.6.tgz",
+      "integrity": "sha512-Fvm24+u85lGmV4hT5G++aht2C5I4Z4dYlWZIh62FAfFO/TfzXtPpoLI6I7AuBWkIFqZCnhFOoTT7RjjaIL5Fjg==",
+      "dev": true
+    },
     "@types/stack-utils": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz",
@@ -3533,6 +3609,12 @@
       "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=",
       "dev": true
     },
+    "long": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
+      "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==",
+      "dev": true
+    },
     "loose-envify": {
       "version": "1.4.0",
       "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -4214,6 +4296,27 @@
         "sisteransi": "^1.0.0"
       }
     },
+    "protobufjs": {
+      "version": "6.8.8",
+      "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.8.tgz",
+      "integrity": "sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw==",
+      "dev": true,
+      "requires": {
+        "@protobufjs/aspromise": "^1.1.2",
+        "@protobufjs/base64": "^1.1.2",
+        "@protobufjs/codegen": "^2.0.4",
+        "@protobufjs/eventemitter": "^1.1.0",
+        "@protobufjs/fetch": "^1.1.0",
+        "@protobufjs/float": "^1.0.2",
+        "@protobufjs/inquire": "^1.1.0",
+        "@protobufjs/path": "^1.1.2",
+        "@protobufjs/pool": "^1.1.0",
+        "@protobufjs/utf8": "^1.1.0",
+        "@types/long": "^4.0.0",
+        "@types/node": "^10.1.0",
+        "long": "^4.0.0"
+      }
+    },
     "psl": {
       "version": "1.1.31",
       "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz",
diff --git a/package.json b/package.json
index 819a0c0..7e0dbe4 100644
--- a/package.json
+++ b/package.json
@@ -23,6 +23,7 @@
   "devDependencies": {
     "jest": "^24.7.1",
     "js-yaml": "^3.13.1",
+    "protobufjs": "^6.8.8",
     "sway": "^2.0.6"
   }
 }
diff --git a/validate.test.js b/validate.test.js
index 0a4343a..24649da 100644
--- a/validate.test.js
+++ b/validate.test.js
@@ -14,20 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-'use strict';
-
-const Sway = require('sway');
-const read = require('fs').readFileSync;
-const load = require('js-yaml').load;
+describe('Zipkin Http Api', () => {
+  const Sway = require('sway');
+  const read = require('fs').readFileSync;
+  const load = require('js-yaml').load;
 
-function validateSwagger(yaml, validationCallback) {
-  const zipkinAPI = read(yaml).toString();
-  Sway.create({definition: load(zipkinAPI)}).then(api => {
-    validationCallback(api.validate());
-  });
-}
+  function validateSwagger(yaml, validationCallback) {
+    const zipkinAPI = read(yaml).toString();
+    Sway.create({definition: load(zipkinAPI)}).then(api => {
+      validationCallback(api.validate());
+    });
+  }
 
-describe('Zipkin Http Api', () => {
   it('/api/v1 yaml should have no swagger syntax errors', done => {
     validateSwagger('./zipkin-api.yaml', result => {
       expect(result.errors).toHaveLength(0);
@@ -42,3 +40,33 @@ describe('Zipkin Http Api', () => {
     });
   });
 });
+
+describe('Zipkin Protocol Buffers Api', () => {
+  const load = require('protobufjs').load;
+
+  function validateProto(proto, validationCallback) {
+    load(proto, (err, root) => {
+      if (err) throw err;
+      validationCallback(root);
+    });
+  }
+
+  it('should include core data structures', done => {
+    validateProto('zipkin.proto', root => {
+      expect(root.lookupType("zipkin.proto3.Endpoint")).toBeDefined();
+      expect(root.lookupType("zipkin.proto3.Annotation")).toBeDefined();
+      expect(root.lookupType("zipkin.proto3.Span")).toBeDefined();
+      expect(root.lookupType("zipkin.proto3.ListOfSpans")).toBeDefined();
+      done();
+    });
+  });
+
+  it('should include reporting service', done => {
+    validateProto('zipkin.proto', root => {
+      // lookup is different for services vs messages
+      expect(root.lookup("SpanService")).toBeDefined();
+      expect(root.lookupType("zipkin.proto3.ReportResponse")).toBeDefined();
+      done();
+    });
+  });
+});