]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/nodejs/test/episodic-code-generation-test/client.js
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / nodejs / test / episodic-code-generation-test / client.js
CommitLineData
f67539c2
TL
1#!/usr/bin/env node
2
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22const assert = require("assert");
23const test = require("tape");
24const thrift = require("thrift");
25const program = require("commander");
26
27program
28 .option("--host <host>", "Set the thrift server host to connect", "localhost")
29 .option("--port <port>", "Set the thrift server port number to connect", 9090)
30 .parse(process.argv);
31
32const Service = require("./gen-2/second-episode/gen-nodejs/Service");
33const Types = require("types-package/first-episode/Types_types");
34
35const host = program.host;
36const port = program.port;
37
38const options = {
39 transport: thrift.TBufferedTransport,
40 protocol: thrift.TJSONProtocol
41};
42
43const connection = thrift.createConnection(host, port, options);
44const testDriver = function(client, callback) {
45 test("NodeJS episodic compilation client-server test", function(assert) {
46 const type1Object = new Types.Type1();
47 type1Object.number = 42;
48 type1Object.message = "The answer";
49 client.testEpisode(type1Object, function(err, response) {
50 assert.error(err, "no callback error");
51 assert.equal(response.number, type1Object.number + 1);
52 assert.equal(
53 response.message,
54 type1Object.message + " [Hello from the server]"
55 );
56 assert.end();
57 callback("Server successfully tested");
58 });
59 });
60};
61
62connection.on("error", function(err) {
63 assert(false, err);
64});
65
66const client = thrift.createClient(Service, connection);
67
68runTests();
69
70function runTests() {
71 testDriver(client, function(status) {
72 console.log(status);
73 connection.destroy();
74 });
75}
76
77exports.expressoTest = function() {};