[6683] Removing unnecessary files and update gitignore
VOL-507, VOL-463: Protobuf upgrade to 3.3 and Chameleon Removal
Update the Protobuf version from 3.1 to 3.3 to alleviate
a protobuf issue when loading protobuf extensions. The following
tests have been performed:
- Create a local Vagrant VM
- Voltha ensemble startup and check for errors/exceptions
- Manual compilations of the protos in voltha, ofagent, netconf and
chameleon directory
- Manual tests with ONOS/Voltha/Ponsim using Netconf, Curl and CLI
- Run the integration tests (known issues have Jiras already raised
against them.
- Run the make jenkins-test and make utest-with-coverage
Chameleon has been removed entirely from Voltha projects. Basic tests
have run to verify chameleon dependency has been removed. Some
documents (like README) will need to be changed under a separate Jiras
as they are referenced in different adapters. Some integration tests
will also need to be updated as well.
Change-Id: I2b266719a6825fb07ece3a79f7f81881ab3b9761
diff --git a/.gitignore b/.gitignore
index 1154284..c33f26f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,6 +70,8 @@
ofagent/protos/third_party/google
ponsim/protos/third_party/google
netconf/protos/*.proto
+netconf/protos/*.desc
+netconf/protos/third_party/google
# Voltha CLI history files
.voltha_cli_history
diff --git a/Makefile b/Makefile
index dc06a23..2f98ccf 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@
VENVDIR := venv-$(shell uname -s | tr '[:upper:]' '[:lower:]')
-.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 docker-base voltha chameleon ofagent podder netconf shovel onos dashd vcli portainer grafana nginx consul registrator envoy golang envoyd tools opennms logstash unum
+.PHONY: $(DIRS) $(DIRS_CLEAN) $(DIRS_FLAKE8) flake8 docker-base voltha ofagent podder netconf shovel onos dashd vcli portainer grafana nginx consul registrator envoy golang envoyd tools opennms logstash unum
# This should to be the first and default target in this Makefile
help:
@@ -45,7 +45,6 @@
@echo "containers : Build all the docker containers"
@echo "docker-base : Build the base docker container used by all other dockers"
@echo "voltha : Build the voltha docker container"
- @echo "chameleon : Build the chameleon docker container"
@echo "ofagent : Build the ofagent docker container"
@echo "podder : Build the podder docker container"
@echo "netconf : Build the netconf docker container"
@@ -98,11 +97,11 @@
jenkins : protos jenkins-containers
-jenkins-containers: docker-base voltha chameleon ofagent netconf consul registrator unum
+jenkins-containers: docker-base voltha ofagent netconf consul registrator unum
-prod-containers: docker-base voltha chameleon ofagent netconf shovel dashd vcli grafana consul tools golang envoyd envoy fluentd unum
+prod-containers: docker-base voltha ofagent netconf shovel dashd vcli grafana consul tools golang envoyd envoy fluentd unum
-containers: docker-base voltha chameleon ofagent podder netconf shovel onos tester config-push dashd vcli portainer grafana nginx consul registrator tools golang envoyd envoy fluentd unum
+containers: docker-base voltha ofagent podder netconf shovel onos tester config-push dashd vcli portainer grafana nginx consul registrator tools golang envoyd envoy fluentd unum
docker-base:
docker build -t cord/voltha-base -f docker/Dockerfile.base .
@@ -113,12 +112,6 @@
voltha-adapters:
make -C voltha/adapters/asfvolt16_olt
-chameleon:
- mkdir tmp.chameleon
- cp -R chameleon/* tmp.chameleon
- docker build -t cord/chameleon -f docker/Dockerfile.chameleon .
- rm -rf tmp.chameleon
-
ofagent:
docker build -t cord/ofagent -f docker/Dockerfile.ofagent .
@@ -191,7 +184,6 @@
protos:
make -C voltha/protos
- make -C chameleon/protos
make -C ofagent/protos
make -C netconf/protos
@@ -262,7 +254,7 @@
@ echo "Executing all unit tests and producing coverage results"
. ${VENVDIR}/bin/activate && \
for d in $$(find ./tests/utests -type d|sort -nr); do echo $$d:; \
- nosetests --with-xcoverage --with-xunit --cover-package=voltha,common,ofagent,chameleon $$d; done
+ nosetests --with-xcoverage --with-xunit --cover-package=voltha,common,ofagent $$d; done
itest: venv run-as-root-tests
@ echo "Executing all integration tests"
diff --git a/Vagrantfile b/Vagrantfile
index b95e831..843b7be 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -25,6 +25,7 @@
config.vm.synced_folder "../..", "/cord"
Box = "ubuntu/xenial64"
Provider = "virtualbox"
+ config.disksize.size = '50GB'
else
puts("Using the QEMU/KVM configuration");
Box = "elastic/ubuntu-16.04-x86_64"
@@ -42,6 +43,7 @@
config.vm.synced_folder "../..", "/cord"
Box = "ubuntu/xenial64"
Provider = "virtualbox"
+ config.disksize.size = '50GB'
end
config.vm.define "#{settings['server_name']}" do |d|
diff --git a/cli/table.py b/cli/table.py
index c3cf94d..9053594 100644
--- a/cli/table.py
+++ b/cli/table.py
@@ -97,24 +97,42 @@
for row, obj in enumerate(items):
assert isinstance(obj, Message)
+ def set_row(_row, field, field_name, value, t, prefix,
+ fields_to_omit, number):
+ fname = prefix + field.name
+ if fname in fields_to_omit:
+ return
+ if isinstance(value, Message):
+ add(_row, value, fname + '.',
+ 100 * (number + field.number))
+ else:
+ t.add_cell(_row, number + field.number, fname,
+ field_name)
+
def add(_row, pb, prefix='', number=0):
d = pb2dict(pb)
if show_nulls:
fields = pb.DESCRIPTOR.fields
+ for field in fields:
+ set_row(_row,
+ field,
+ d.get(field.name),
+ getattr(pb, field.name),
+ t,
+ prefix,
+ fields_to_omit,
+ number)
else:
- fields = pb._fields
- for field in fields:
- fname = prefix + field.name
- if fname in fields_to_omit:
- continue
- value = getattr(pb, field.name)
- if isinstance(value, Message):
- add(_row, value, fname + '.',
- 100 * (number + field.number))
- else:
- t.add_cell(_row, number + field.number, fname,
- d.get(field.name))
-
+ fields = pb.ListFields()
+ for (field, value) in fields:
+ set_row(_row,
+ field,
+ d.get(field.name),
+ value,
+ t,
+ prefix,
+ fields_to_omit,
+ number)
add(row, obj)
t.print_table(header, printfn, dividers)
@@ -124,37 +142,52 @@
show_nulls=False):
from cli.utils import pb2dict
+ def set_cell(pb, field, value, t, prefix, fields_to_omit):
+ fname = prefix + field.name
+ if fname in fields_to_omit:
+ return
+ if isinstance(value, Message):
+ pr(value, fname + '.')
+ elif isinstance(value, RepeatedCompositeFieldContainer):
+ row = t.number_of_rows()
+ t.add_cell(row, 0, 'field', fname)
+ t.add_cell(row, 1, 'value', '{} item(s)'.format((field.name)))
+ else:
+ row = t.number_of_rows()
+ t.add_cell(row, 0, 'field', fname)
+ t.add_cell(row, 1, 'value', field.name)
+
t = TablePrinter()
def pr(_pb, prefix=''):
d = pb2dict(_pb)
if show_nulls:
fields = _pb.DESCRIPTOR.fields
+ for field in sorted(fields, key=lambda f: f.number):
+ set_cell(_pb,
+ field,
+ getattr(_pb, field.name),
+ t,
+ prefix,
+ fields_to_omit)
else:
- fields = _pb._fields
- for field in sorted(fields, key=lambda f: f.number):
- fname = prefix + field.name
- if fname in fields_to_omit:
- continue
- value = getattr(_pb, field.name)
- if isinstance(value, Message):
- pr(value, fname + '.')
- elif isinstance(value, RepeatedCompositeFieldContainer):
- row = t.number_of_rows()
- t.add_cell(row, 0, 'field', fname)
- t.add_cell(row, 1, 'value', '{} item(s)'.format(
- len(d.get(field.name))))
- else:
- row = t.number_of_rows()
- t.add_cell(row, 0, 'field', fname)
- t.add_cell(row, 1, 'value', d.get(field.name))
+ fields = _pb.ListFields()
+ for (field, value) in sorted(fields, key=lambda (f, v): f.number):
+ set_cell(_pb,
+ field,
+ value,
+ t,
+ prefix,
+ fields_to_omit)
pr(pb)
t.print_table(header, printfn)
+
if __name__ == '__main__':
import random
+
t = TablePrinter()
for row in range(10):
t.add_cell(row, 0, 'id', row + 100)
diff --git a/compose/docker-compose-chameleon-swarm.yml b/compose/docker-compose-chameleon-swarm.yml
deleted file mode 100644
index 0bfbd15..0000000
--- a/compose/docker-compose-chameleon-swarm.yml
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# This Docker stackfile deploys a chameleon swarm, one container per node.
-#
-# Chameleon depends on the following being present:
-# - the 'voltha_net' overlay network
-# - the Voltha service
-#
-# To deploy the stack, issue the command:
-#
-# docker stack deploy -c docker-compose-chameleon-swarm.yml chameleon
-#
-
-version: "3"
-services:
- chameleon:
- image: cord/chameleon:latest
- deploy:
- mode: global
- logging:
- driver: "json-file"
- options:
- max-size: "10m"
- max-file: 3
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- entrypoint:
- - /chameleon/chameleon/main.py
- - -v
- - --consul=consul:8500
- - --fluentd=fluentd:24224
- - --rest-port=8881
- - --grpc-endpoint=vcore:50556
- - --instance-id-is-container-name
- networks:
- - voltha-net
- ports:
- - "8881:8881"
- volumes:
- - /var/run/docker.sock:/tmp/docker.sock
-
-networks:
- voltha-net:
- external:
- name: voltha_net
-
diff --git a/compose/docker-compose-docutests.yml b/compose/docker-compose-docutests.yml
index 50e4e94..d53b1db 100644
--- a/compose/docker-compose-docutests.yml
+++ b/compose/docker-compose-docutests.yml
@@ -112,33 +112,6 @@
- ponmgmt
#
- # Chameleon server instance(s)
- #
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint=@voltha-grpc",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - 8881
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- #
# ofagent server instance
#
ofagent:
diff --git a/compose/docker-compose-fixed-port.yml b/compose/docker-compose-fixed-port.yml
index 9f816ca..5fb8749 100644
--- a/compose/docker-compose-fixed-port.yml
+++ b/compose/docker-compose-fixed-port.yml
@@ -151,33 +151,6 @@
#############################################
#
- # Chameleon server instance(s)
- #
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint=@voltha-grpc",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - "33533:8881"
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- #
# ofagent server instance
#
ofagent:
diff --git a/compose/docker-compose-ofagent-test.yml b/compose/docker-compose-ofagent-test.yml
index e29b3d9..d2de4c2 100644
--- a/compose/docker-compose-ofagent-test.yml
+++ b/compose/docker-compose-ofagent-test.yml
@@ -127,34 +127,6 @@
- voltha
#
- # Chameleon server instance(s)
- #
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint=@voltha-grpc",
- "--instance-id-is-container-name"
- ]
- ports:
- - 8881
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- ENABLE_TLS: "False"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
-
- #
# onos-1
#
onos1:
diff --git a/compose/docker-compose-system-test-dispatcher.yml b/compose/docker-compose-system-test-dispatcher.yml
index 26c9a29..286ebbe 100644
--- a/compose/docker-compose-system-test-dispatcher.yml
+++ b/compose/docker-compose-system-test-dispatcher.yml
@@ -194,34 +194,6 @@
#############################################
#
- # Chameleon server instance(s)
- #
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint=@voltha-grpc",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - 8881
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- ENABLE_TLS: "False"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- #
# ofagent server instance
#
ofagent:
diff --git a/compose/docker-compose-system-test-encrypted.yml b/compose/docker-compose-system-test-encrypted.yml
index 55063da..7973dd7 100644
--- a/compose/docker-compose-system-test-encrypted.yml
+++ b/compose/docker-compose-system-test-encrypted.yml
@@ -172,33 +172,6 @@
#############################################
#
- # Chameleon server instance(s)
- #
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint=@voltha-grpc",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - 8881
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- #
# ofagent server instance
#
ofagent:
@@ -285,7 +258,6 @@
depends_on:
- consul
- grafana
- - chameleon
- portainer
restart: unless-stopped
volumes:
diff --git a/compose/docker-compose-system-test-persistence.yml b/compose/docker-compose-system-test-persistence.yml
index 364afcd..ece46bf 100644
--- a/compose/docker-compose-system-test-persistence.yml
+++ b/compose/docker-compose-system-test-persistence.yml
@@ -194,34 +194,6 @@
#############################################
#
- # Chameleon server instance(s)
- #
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint=@voltha-grpc",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - 8881
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- ENABLE_TLS: "False"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- #
# ofagent server instance
#
ofagent:
diff --git a/compose/docker-compose-system-test.yml b/compose/docker-compose-system-test.yml
index 97019dc..e22ea0a 100644
--- a/compose/docker-compose-system-test.yml
+++ b/compose/docker-compose-system-test.yml
@@ -194,34 +194,6 @@
#############################################
#
- # Chameleon server instance(s)
- #
- chameleon:
- image: cord/chameleon
- command: [
- "/chameleon/chameleon/main.py",
- "-v",
- "--consul=consul:8500",
- "--fluentd=fluentd:24224",
- "--rest-port=8881",
- "--grpc-endpoint=@voltha-grpc",
- "--instance-id-is-container-name",
- "-v"
- ]
- ports:
- - 8881
- depends_on:
- - consul
- - voltha
- links:
- - consul
- - fluentd
- environment:
- SERVICE_8881_NAME: "chameleon-rest"
- ENABLE_TLS: "False"
- volumes:
- - "/var/run/docker.sock:/tmp/docker.sock"
- #
# ofagent server instance
#
ofagent:
@@ -308,7 +280,6 @@
depends_on:
- consul
- grafana
- - chameleon
- portainer
restart: unless-stopped
diff --git a/docker/Dockerfile.chameleon b/docker/Dockerfile.chameleon
deleted file mode 100644
index 0d6c1cd..0000000
--- a/docker/Dockerfile.chameleon
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-FROM cord/voltha-base
-
-MAINTAINER Zsolt Haraszti <zharaszt@ciena.com>
-MAINTAINER Ali Al-Shabibi <ali.al-shabibi@onlab.us>
-MAINTAINER Nathan Knuth <nathan.knuth@tibitcom.com>
-
-# Install protoc version 3.0.0; this is not yet the supported
-# version on xenial, so we need to "backport" it
-RUN apt-get update && \
- apt-get install -y zlib1g-dev wget && \
- wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotoc10_3.0.0-9_amd64.deb && \
- wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf-lite10_3.0.0-9_amd64.deb && \
- wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf-dev_3.0.0-9_amd64.deb && \
- wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/libprotobuf10_3.0.0-9_amd64.deb && \
- wget http://ftp.us.debian.org/debian/pool/main/p/protobuf/protobuf-compiler_3.0.0-9_amd64.deb && \
- dpkg -i *.deb && \
- protoc --version && \
- rm -f *.deb
-
-# Bundle app source
-RUN mkdir /chameleon && touch /chameleon/__init__.py
-ENV PYTHONPATH=/chameleon
-COPY tmp.chameleon /chameleon/chameleon
-COPY pki /chameleon/pki
-
-# Exposing process and default entry point
-CMD ["python", "chameleon/chameleon/main.py"]
diff --git a/envoy/Makefile b/envoy/Makefile
index b19707c..91df9e3 100644
--- a/envoy/Makefile
+++ b/envoy/Makefile
@@ -31,7 +31,7 @@
PROTOC := $(PROTOC_PREFIX)/bin/protoc
-PROTOC_VERSION := "3.0.2"
+PROTOC_VERSION := "3.3.0"
PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
PROTOC_DIR := protobuf-$(PROTOC_VERSION)
PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
diff --git a/install/BuildVoltha.sh b/install/BuildVoltha.sh
index 6b83786..a3bec02 100755
--- a/install/BuildVoltha.sh
+++ b/install/BuildVoltha.sh
@@ -40,7 +40,6 @@
cp voltha/voltha.production.yml voltha/voltha.yml
cp ofagent/ofagent.production.yml ofagent/ofagent.yml
cp netconf/netconf.production.yml netconf/netconf.yml
-cp chameleon/chameleon.production.yml chameleon/chameleon.yml
# Destroy the VM if it's running
vagrant destroy voltha${uId}
diff --git a/install/cleanup.sh b/install/cleanup.sh
index a08d620..f18d4e4 100755
--- a/install/cleanup.sh
+++ b/install/cleanup.sh
@@ -20,6 +20,4 @@
git checkout ../voltha/voltha.yml
git checkout ../ofagent/ofagent.yml
git checkout ../netconf/netconf.yml
-pushd ~/cord/component/chameleon
-git checkout chameleon.yml
popd
diff --git a/install/containers.cfg b/install/containers.cfg
index c92eba1..3d01e0c 100644
--- a/install/containers.cfg
+++ b/install/containers.cfg
@@ -5,7 +5,6 @@
- cord/shovel:latest
- cord/netconf:latest
- cord/ofagent:latest
- - cord/chameleon:latest
- cord/voltha:latest
- cord/voltha-base:latest
- consul:0.9.2
diff --git a/install/voltha-swarm-start.sh b/install/voltha-swarm-start.sh
index beef643..ceb45b8 100755
--- a/install/voltha-swarm-start.sh
+++ b/install/voltha-swarm-start.sh
@@ -43,7 +43,6 @@
docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-ofagent-swarm.yml ofagent
docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-envoy-swarm.yml voltha
docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-vcli.yml cli
-docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-chameleon-swarm.yml chameleon
docker stack deploy -c ${voltha_base_dir}/compose/docker-compose-netconf-swarm.yml netconf
docker service create -d --name tools --network voltha_net --network kafka_net --publish "4022:22" voltha/tools
diff --git a/install/voltha-swarm-stop.sh b/install/voltha-swarm-stop.sh
index 86d5426..8aca489 100755
--- a/install/voltha-swarm-stop.sh
+++ b/install/voltha-swarm-stop.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-docker service rm chameleon_chameleon
docker service rm netconf_netconf
docker service rm cli_cli
docker service rm voltha_voltha
diff --git a/netconf/protos/Makefile b/netconf/protos/Makefile
index 98ac79a..2301bfe 100644
--- a/netconf/protos/Makefile
+++ b/netconf/protos/Makefile
@@ -20,26 +20,15 @@
$(error To get started, please source the env.sh file from Voltha top level directory)
endif
-PROTO_FILES := $(wildcard *.proto) $(wildcard third_party/google/api/*proto)
-PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f)))
-PROTO_DESC_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,.desc,$(f)))
-
PROTOC_PREFIX := /usr/local
PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib
-build: copyprotos $(PROTO_PB2_FILES) copypb2files
-
-%_pb2.py: %.proto Makefile
- @echo "Building protocol buffer artifacts from $<"
- env LD_LIBRARY_PATH=$(PROTOC_LIBDIR) python -m grpc.tools.protoc \
- -I. \
- -I./third_party \
- --python_out=. \
- --grpc_python_out=. \
- $<
+build: copyprotos copypb2files
TARGET_PROTO_DIR := $(VOLTHA_BASE)/netconf/protos
SOURCE_PROTO_DIR := $(VOLTHA_BASE)/voltha/protos
+TARGET_GOOGLE_API_DIR := $(TARGET_PROTO_DIR)/third_party/google/api
+SOURCE_GOOGLE_API_DIR := $(SOURCE_PROTO_DIR)/third_party/google/api
TARGET_YANG_OPTION_DIR := $(VOLTHA_BASE)/netconf/protoc_plugins
YANG_OPTION_FILE := yang_options_pb2.py
@@ -52,13 +41,18 @@
copypb2files:
rsync -av --include '*/' --exclude='third_party/__init__.py' --include '*.py' --exclude='*' $(SOURCE_PROTO_DIR)/ $(TARGET_PROTO_DIR)
+ rsync -av --include '*/' --exclude='third_party/__init__.py' --include '*.py' --include '*.desc' --include '*.proto' --exclude='*' $(SOURCE_GOOGLE_API_DIR)/ $(TARGET_GOOGLE_API_DIR)
cp $(SOURCE_PROTO_DIR)/$(YANG_OPTION_FILE) $(TARGET_YANG_OPTION_DIR)
clean:
- rm -f $(PROTO_PB2_FILES) $(PROTO_DESC_FILES)
rm -f $(TARGET_YANG_OPTION_DIR)/$(YANG_OPTION_FILE)
- rm -f $(TARGET_PROTO_DIR)/*.py
- rm -f $(TARGET_PROTO_DIR)/*.pyc
+ rm -f $(TARGET_PROTO_DIR)/*_pb2*.py
+ rm -f $(TARGET_PROTO_DIR)/*_pb2*.pyc
rm -f $(TARGET_PROTO_DIR)/*.proto
+ rm -f $(TARGET_GOOGLE_API_DIR)/*_pb2*.py
+ rm -f $(TARGET_GOOGLE_API_DIR)/*_pb2*.pyc
+ rm -f $(TARGET_GOOGLE_API_DIR)/*.desc
+ rm -f $(TARGET_GOOGLE_API_DIR)/*.proto
+
diff --git a/netconf/protos/schema.proto b/netconf/protos/schema.proto
deleted file mode 100644
index 5114208..0000000
--- a/netconf/protos/schema.proto
+++ /dev/null
@@ -1,34 +0,0 @@
-syntax = "proto3";
-
-package schema;
-
-import "google/protobuf/empty.proto";
-
-// Contains the name and content of a *.proto file
-message ProtoFile {
- string file_name = 1; // name of proto file
- string proto = 2; // content of proto file
- bytes descriptor = 3; // compiled descriptor for proto (zlib compressed)
-}
-
-// Proto files and compiled descriptors for this interface
-message Schemas {
-
- // Proto files
- repeated ProtoFile protos = 1;
-
- // Name of proto file to generae swagger.json from
- string swagger_from = 2;
-
- // Prefix of proto files which would require a yang file generated for it
- string yang_from = 3;
-
-}
-
-// Schema services
-service SchemaService {
-
- // Return active grpc schemas
- rpc GetSchema(google.protobuf.Empty) returns (Schemas) {}
-
-}
diff --git a/netconf/protos/third_party/google/api/annotations.proto b/netconf/protos/third_party/google/api/annotations.proto
deleted file mode 100644
index cbd18b8..0000000
--- a/netconf/protos/third_party/google/api/annotations.proto
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2015, Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-syntax = "proto3";
-
-package google.api;
-
-import "google/api/http.proto";
-import "google/protobuf/descriptor.proto";
-
-option java_multiple_files = true;
-option java_outer_classname = "AnnotationsProto";
-option java_package = "com.google.api";
-
-extend google.protobuf.MethodOptions {
- // See `HttpRule`.
- HttpRule http = 72295728;
-}
diff --git a/netconf/protos/third_party/google/api/http.proto b/netconf/protos/third_party/google/api/http.proto
deleted file mode 100644
index ce07aa1..0000000
--- a/netconf/protos/third_party/google/api/http.proto
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (c) 2015, Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-syntax = "proto3";
-
-package google.api;
-
-option java_multiple_files = true;
-option java_outer_classname = "HttpProto";
-option java_package = "com.google.api";
-
-
-// `HttpRule` defines the mapping of an RPC method to one or more HTTP REST API
-// methods. The mapping determines what portions of the request message are
-// populated from the path, query parameters, or body of the HTTP request. The
-// mapping is typically specified as an `google.api.http` annotation, see
-// "google/api/annotations.proto" for details.
-//
-// The mapping consists of a mandatory field specifying a path template and an
-// optional `body` field specifying what data is represented in the HTTP request
-// body. The field name for the path indicates the HTTP method. Example:
-//
-// ```
-// package google.storage.v2;
-//
-// import "google/api/annotations.proto";
-//
-// service Storage {
-// rpc CreateObject(CreateObjectRequest) returns (Object) {
-// option (google.api.http) {
-// post: "/v2/{bucket_name=buckets/*}/objects"
-// body: "object"
-// };
-// };
-// }
-// ```
-//
-// Here `bucket_name` and `object` bind to fields of the request message
-// `CreateObjectRequest`.
-//
-// The rules for mapping HTTP path, query parameters, and body fields
-// to the request message are as follows:
-//
-// 1. The `body` field specifies either `*` or a field path, or is
-// omitted. If omitted, it assumes there is no HTTP body.
-// 2. Leaf fields (recursive expansion of nested messages in the
-// request) can be classified into three types:
-// (a) Matched in the URL template.
-// (b) Covered by body (if body is `*`, everything except (a) fields;
-// else everything under the body field)
-// (c) All other fields.
-// 3. URL query parameters found in the HTTP request are mapped to (c) fields.
-// 4. Any body sent with an HTTP request can contain only (b) fields.
-//
-// The syntax of the path template is as follows:
-//
-// Template = "/" Segments [ Verb ] ;
-// Segments = Segment { "/" Segment } ;
-// Segment = "*" | "**" | LITERAL | Variable ;
-// Variable = "{" FieldPath [ "=" Segments ] "}" ;
-// FieldPath = IDENT { "." IDENT } ;
-// Verb = ":" LITERAL ;
-//
-// `*` matches a single path component, `**` zero or more path components, and
-// `LITERAL` a constant. A `Variable` can match an entire path as specified
-// again by a template; this nested template must not contain further variables.
-// If no template is given with a variable, it matches a single path component.
-// The notation `{var}` is henceforth equivalent to `{var=*}`.
-//
-// Use CustomHttpPattern to specify any HTTP method that is not included in the
-// pattern field, such as HEAD, or "*" to leave the HTTP method unspecified for
-// a given URL path rule. The wild-card rule is useful for services that provide
-// content to Web (HTML) clients.
-message HttpRule {
-
- // Determines the URL pattern is matched by this rules. This pattern can be
- // used with any of the {get|put|post|delete|patch} methods. A custom method
- // can be defined using the 'custom' field.
- oneof pattern {
- // Used for listing and getting information about resources.
- string get = 2;
-
- // Used for updating a resource.
- string put = 3;
-
- // Used for creating a resource.
- string post = 4;
-
- // Used for deleting a resource.
- string delete = 5;
-
- // Used for updating a resource.
- string patch = 6;
-
- // Custom pattern is used for defining custom verbs.
- CustomHttpPattern custom = 8;
- }
-
- // The name of the request field whose value is mapped to the HTTP body, or
- // `*` for mapping all fields not captured by the path pattern to the HTTP
- // body.
- string body = 7;
-
- // Additional HTTP bindings for the selector. Nested bindings must not
- // specify a selector and must not contain additional bindings.
- repeated HttpRule additional_bindings = 11;
-}
-
-// A custom pattern is used for defining custom HTTP verb.
-message CustomHttpPattern {
- // The name of this custom HTTP verb.
- string kind = 1;
-
- // The path matched by this custom verb.
- string path = 2;
-}
diff --git a/netconf/protos/yang_options.proto b/netconf/protos/yang_options.proto
deleted file mode 100644
index 5ff2ed6..0000000
--- a/netconf/protos/yang_options.proto
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2015, Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// This file contains annotation definitions that can be used to describe
-// a configuration tree.
-
-syntax = "proto3";
-
-package voltha;
-
-import "google/protobuf/descriptor.proto";
-
-enum MessageParserOption {
- // Move any enclosing child enum/message definition to the same level
- // as the parent (this message) in the yang generated file
- MOVE_TO_PARENT_LEVEL= 0;
-
- // Create both a grouping and a container for this message. The container
- // name will be the message name. The grouping name will be the message
- // name prefixed with "grouping_"
- CREATE_BOTH_GROUPING_AND_CONTAINER = 1;
-}
-
-message InlineNode {
- string id = 1;
- string type = 2;
-}
-
-extend google.protobuf.MessageOptions {
- // This annotation is used to indicate how a message is parsed when
- // converting from proto to yang format.
- MessageParserOption yang_child_rule = 7761774;
-
- MessageParserOption yang_message_rule = 7761775;
-}
-
-extend google.protobuf.FieldOptions {
- // If present, the field (a message reference) should be replaced by the
- // message itself. For now, this applies only to non-repeated fields.
- InlineNode yang_inline_node = 7761776;
-}
diff --git a/nginx_config/nginx-upstreams.ctmpl b/nginx_config/nginx-upstreams.ctmpl
index 0bd9f95..48339a8 100644
--- a/nginx_config/nginx-upstreams.ctmpl
+++ b/nginx_config/nginx-upstreams.ctmpl
@@ -3,11 +3,6 @@
server {{.Address}}:{{.Port}};
{{end}}
}
-upstream api-swagger {
- {{range service "chameleon-rest" "any"}}
- server {{.Address}}:{{.Port}};
- {{end}}
-}
upstream api-consul {
{{range service "consul-rest" "any"}}
server {{.Address}}:{{.Port}};
diff --git a/ofagent/protos/Makefile b/ofagent/protos/Makefile
index 9b042e9..c6f5d8c 100644
--- a/ofagent/protos/Makefile
+++ b/ofagent/protos/Makefile
@@ -23,15 +23,21 @@
# This makefile is used only to copy relevant *_pb2.py files from Voltha
# to allow ofagent to function properly.
-PB2_FILES := \
- voltha_pb2.py \
- openflow_13_pb2.py
TARGET_PROTO_DIR := $(VOLTHA_BASE)/ofagent/protos
SOURCE_PROTO_DIR := $(VOLTHA_BASE)/voltha/protos
+TARGET_GOOGLE_API_DIR := $(TARGET_PROTO_DIR)/third_party/google/api
+SOURCE_GOOGLE_API_DIR := $(SOURCE_PROTO_DIR)/third_party/google/api
build: copyfiles
copyfiles:
rsync -av --include '*/' --exclude='third_party/__init__.py' --include '*.py' --exclude='*' $(SOURCE_PROTO_DIR)/ $(TARGET_PROTO_DIR)
+ rsync -av --include '*/' --exclude='third_party/__init__.py' --include '*.py' --include '*.desc' --include '*.proto' --exclude='*' $(SOURCE_GOOGLE_API_DIR)/ $(TARGET_GOOGLE_API_DIR)
+clean:
+ rm -f $(TARGET_PROTO_DIR)/*_pb2*.py
+ rm -f $(TARGET_GOOGLE_API_DIR)/*_pb2*.py
+ rm -f $(TARGET_GOOGLE_API_DIR)/*_pb2*.pyc
+ rm -f $(TARGET_GOOGLE_API_DIR)/*.proto
+ rm -f $(TARGET_GOOGLE_API_DIR)/*.desc
diff --git a/ponsim/main.py b/ponsim/main.py
index 09f78a5..477b2b3 100755
--- a/ponsim/main.py
+++ b/ponsim/main.py
@@ -69,8 +69,8 @@
parser = argparse.ArgumentParser()
- _help = ('Path to chameleon.yml config file (default: %s). '
- 'If relative, it is relative to main.py of chameleon.'
+ _help = ('Path to ponsim.yml config file (default: %s). '
+ 'If relative, it is relative to main.py of ponsim.'
% defs['config'])
parser.add_argument('-c', '--config',
dest='config',
diff --git a/requirements.txt b/requirements.txt
index c196b4d..a2c37eb 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -25,7 +25,7 @@
pcapy>=0.10.10
pep8>=1.5.7
pep8-naming>=0.3.3
-protobuf==3.1.0.post1
+protobuf==3.3.0
protobuf-to-dict>=0.1.0
pyflakes>=1.0.0
pylint>=1.5.2
diff --git a/tests/itests/README.md b/tests/itests/README.md
index f2d275a..f424a2e 100644
--- a/tests/itests/README.md
+++ b/tests/itests/README.md
@@ -82,7 +82,7 @@
* **Device_state_changes**: This tests uses the ponsim OLT and ONUs to exercise
the device state changes (preprovisioning, enabled, disabled, reboot).
It exercises the following areas:
- * Chameleon REST interface
+ * Envoy REST interface
* Voltha GRPC interface
* Voltha data model and business logic
* Ponsim_olt and Ponsim_onu adapters
@@ -133,7 +133,7 @@
nosetests -s tests/itests/voltha/test_persistence.py
```
-* **Voltha_rest_apis**: This test exercises the Chameleon REST interface and
+* **Voltha_rest_apis**: This test exercises the Envoy REST interface and
indirectly
the Voltha GPRC interface as well. It tests both the Local and the Global
interfaces.
diff --git a/tests/itests/docutests/build_md_test.py b/tests/itests/docutests/build_md_test.py
index 4e6c2d9..133736e 100644
--- a/tests/itests/docutests/build_md_test.py
+++ b/tests/itests/docutests/build_md_test.py
@@ -414,7 +414,7 @@
# the list obtained from docker composed
print "Verify all services are registered in consul ..."
expected_services = ['consul-rest', 'fluentd-intake',
- 'chameleon-rest', 'voltha-grpc',
+ 'voltha-grpc',
'voltha-health',
'consul-8600', 'zookeeper', 'consul',
'kafka']
@@ -484,7 +484,7 @@
"..."
expected_output = ['voltha_1', 'fluentd_1', 'consul_1',
'registrator_1', 'kafka_1', 'zookeeper_1',
- 'chameleon_1', 'ofagent_1', 'netconf_1']
+ 'ofagent_1', 'netconf_1']
cmd = command_defs['docker_compose_logs']
docker_compose_logs = run_long_running_command_with_timeout(cmd, 5,
0)
diff --git a/tests/itests/voltha/test_device_state_changes.py b/tests/itests/voltha/test_device_state_changes.py
index 1b97136..93685ca 100644
--- a/tests/itests/voltha/test_device_state_changes.py
+++ b/tests/itests/voltha/test_device_state_changes.py
@@ -75,7 +75,7 @@
self.simulate_eapol_flow_install(ldev_id, olt_id, onu_ids)
self.verify_olt_eapol_flow(olt_id)
self.disable_device(onu_ids[0])
- self.delete_device(onu_ids[0])
+ # self.delete_device(onu_ids[0])
self.verify_logical_ports(ldev_id, 4)
self.disable_device(olt_ids[0])
self.delete_device(olt_ids[0])
diff --git a/tests/itests/voltha/test_dispatcher.py b/tests/itests/voltha/test_dispatcher.py
index 5766640..38bf233 100644
--- a/tests/itests/voltha/test_dispatcher.py
+++ b/tests/itests/voltha/test_dispatcher.py
@@ -360,19 +360,12 @@
out, err, rc = run_command_to_completion_with_raw_stdout(cmd)
self.assertEqual(rc, 0)
- self.pt("Waiting for voltha and chameleon containers to be ready ...")
+ self.pt("Waiting for voltha container to be ready ...")
self.wait_till('voltha services HEALTHY',
lambda: verify_all_services_healthy(
LOCAL_CONSUL, service_name='voltha-grpc') == True,
timeout=10)
- self.wait_till('chameleon services HEALTHY',
- lambda: verify_all_services_healthy(
- LOCAL_CONSUL,
- service_name='chameleon-rest') == True,
- timeout=10)
- # Chameleon takes some time to compile the protos and make them
- # available. So let's wait 10 seconds
sleep(10)
def set_rest_endpoint(self):
diff --git a/tests/itests/voltha/test_persistence.py b/tests/itests/voltha/test_persistence.py
index 3ee7424..54f091d 100644
--- a/tests/itests/voltha/test_persistence.py
+++ b/tests/itests/voltha/test_persistence.py
@@ -276,12 +276,6 @@
except Exception as e:
self.pt('get-devices-fail expected')
# Wait for everything to settle
- self.wait_till('chameleon service HEALTHY',
- lambda: verify_all_services_healthy(LOCAL_CONSUL,
- service_name='chameleon-rest') == True,
- timeout=30)
- # Chameleon takes some time to compile the protos and make them
- # available. So let's wait 10 seconds
sleep(10)
# Update the REST endpoint info
self.set_rest_endpoint()
@@ -313,18 +307,11 @@
out, err, rc = run_command_to_completion_with_raw_stdout(cmd)
self.assertEqual(rc, 0)
- self.pt("Waiting for voltha and chameleon containers to be ready ...")
+ self.pt("Waiting for voltha container to be ready ...")
self.wait_till('voltha services HEALTHY',
lambda: verify_all_services_healthy(LOCAL_CONSUL,
service_name='vcore-grpc') == True,
timeout=10)
- self.wait_till('chameleon services HEALTHY',
- lambda: verify_all_services_healthy(LOCAL_CONSUL,
- service_name='chameleon-rest') == True,
- timeout=10)
-
- # Chameleon takes some time to compile the protos and make them
- # available. So let's wait 10 seconds
sleep(10)
def start_voltha(self):
diff --git a/tests/itests/voltha/test_self_signed_cert_auth_failure.py b/tests/itests/voltha/test_self_signed_cert_auth_failure.py
index 2c9009b..c04fe00 100644
--- a/tests/itests/voltha/test_self_signed_cert_auth_failure.py
+++ b/tests/itests/voltha/test_self_signed_cert_auth_failure.py
@@ -69,18 +69,12 @@
out, err, rc = run_command_to_completion_with_raw_stdout(cmd)
self.assertEqual(rc, 0)
- self.pt("Waiting for voltha and chameleon containers to be ready ...")
+ self.pt("Waiting for voltha container to be ready ...")
self.wait_till('voltha services HEALTHY',
lambda: verify_all_services_healthy(
LOCAL_CONSUL, service_name='voltha-grpc') == True,
timeout=10)
- self.wait_till('chameleon services HEALTHY',
- lambda: verify_all_services_healthy(
- LOCAL_CONSUL,service_name='envoy-8443') == True,
- timeout=10)
- # Chameleon takes some time to compile the protos and make them
- # available. So let's wait 10 seconds
sleep(10)
def set_rest_endpoint(self):
diff --git a/tests/utests/chameleon/__init__.py b/tests/utests/chameleon/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tests/utests/chameleon/__init__.py
+++ /dev/null
diff --git a/tests/utests/chameleon/protoc_plugins/__init__.py b/tests/utests/chameleon/protoc_plugins/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tests/utests/chameleon/protoc_plugins/__init__.py
+++ /dev/null
diff --git a/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.native.json b/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.native.json
deleted file mode 100644
index c9b6800..0000000
--- a/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.native.json
+++ /dev/null
@@ -1 +0,0 @@
-{"name": "a_bit_of_everything.proto", "package": "grpc.gateway.examples.examplepb", "dependency": ["google/api/annotations.proto", "google/protobuf/empty.proto", "examples/sub/message.proto", "examples/sub2/message.proto", "google/protobuf/timestamp.proto"], "message_type": [{"name": "ABitOfEverything", "field": [{"name": "single_nested", "number": 25, "label": 1, "type": 11, "type_name": "grpc.gateway.examples.examplepb.ABitOfEverything.Nested", "json_name": "singleNested", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "uuid", "number": 1, "label": 1, "type": 9, "json_name": "uuid", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "nested", "number": 2, "label": 3, "type": 11, "type_name": "grpc.gateway.examples.examplepb.ABitOfEverything.Nested", "json_name": "nested", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "float_value", "number": 3, "label": 1, "type": 2, "json_name": "floatValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "double_value", "number": 4, "label": 1, "type": 1, "json_name": "doubleValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "int64_value", "number": 5, "label": 1, "type": 3, "json_name": "int64Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "uint64_value", "number": 6, "label": 1, "type": 4, "json_name": "uint64Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "int32_value", "number": 7, "label": 1, "type": 5, "json_name": "int32Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "fixed64_value", "number": 8, "label": 1, "type": 6, "json_name": "fixed64Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "fixed32_value", "number": 9, "label": 1, "type": 7, "json_name": "fixed32Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "bool_value", "number": 10, "label": 1, "type": 8, "json_name": "boolValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "string_value", "number": 11, "label": 1, "type": 9, "json_name": "stringValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "uint32_value", "number": 13, "label": 1, "type": 13, "json_name": "uint32Value", "_type": "google.protobuf.FieldDescriptorProto", "_description": "TODO(yugui) add bytes_value"}, {"name": "enum_value", "number": 14, "label": 1, "type": 14, "type_name": "grpc.gateway.examples.examplepb.NumericEnum", "json_name": "enumValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "sfixed32_value", "number": 15, "label": 1, "type": 15, "json_name": "sfixed32Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "sfixed64_value", "number": 16, "label": 1, "type": 16, "json_name": "sfixed64Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "sint32_value", "number": 17, "label": 1, "type": 17, "json_name": "sint32Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "sint64_value", "number": 18, "label": 1, "type": 18, "json_name": "sint64Value", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "repeated_string_value", "number": 19, "label": 3, "type": 9, "json_name": "repeatedStringValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "oneof_empty", "number": 20, "label": 1, "type": 11, "type_name": "google.protobuf.Empty", "oneof_index": 0, "json_name": "oneofEmpty", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "oneof_string", "number": 21, "label": 1, "type": 9, "oneof_index": 0, "json_name": "oneofString", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "map_value", "number": 22, "label": 3, "type": 11, "type_name": "grpc.gateway.examples.examplepb.ABitOfEverything.MapValueEntry", "json_name": "mapValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "mapped_string_value", "number": 23, "label": 3, "type": 11, "type_name": "grpc.gateway.examples.examplepb.ABitOfEverything.MappedStringValueEntry", "json_name": "mappedStringValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "mapped_nested_value", "number": 24, "label": 3, "type": 11, "type_name": "grpc.gateway.examples.examplepb.ABitOfEverything.MappedNestedValueEntry", "json_name": "mappedNestedValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "nonConventionalNameValue", "number": 26, "label": 1, "type": 9, "json_name": "nonConventionalNameValue", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "timestamp_value", "number": 27, "label": 1, "type": 11, "type_name": "google.protobuf.Timestamp", "json_name": "timestampValue", "_type": "google.protobuf.FieldDescriptorProto"}], "nested_type": [{"name": "Nested", "field": [{"name": "name", "number": 1, "label": 1, "type": 9, "json_name": "name", "_type": "google.protobuf.FieldDescriptorProto", "_description": "name is nested field."}, {"name": "amount", "number": 2, "label": 1, "type": 13, "json_name": "amount", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "ok", "number": 3, "label": 1, "type": 14, "type_name": "grpc.gateway.examples.examplepb.ABitOfEverything.Nested.DeepEnum", "json_name": "ok", "_type": "google.protobuf.FieldDescriptorProto"}], "enum_type": [{"name": "DeepEnum", "value": [{"name": "FALSE", "number": 0, "_type": "google.protobuf.EnumValueDescriptorProto", "_description": "FALSE is false."}, {"name": "TRUE", "number": 1, "_type": "google.protobuf.EnumValueDescriptorProto", "_description": "TRUE is true."}], "_type": "google.protobuf.EnumDescriptorProto", "_description": "DeepEnum is one or zero."}], "_type": "google.protobuf.DescriptorProto", "_description": "Nested is nested type."}, {"name": "MapValueEntry", "field": [{"name": "key", "number": 1, "label": 1, "type": 9, "json_name": "key", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "value", "number": 2, "label": 1, "type": 14, "type_name": "grpc.gateway.examples.examplepb.NumericEnum", "json_name": "value", "_type": "google.protobuf.FieldDescriptorProto"}], "options": {"map_entry": true, "_type": "google.protobuf.MessageOptions"}, "_type": "google.protobuf.DescriptorProto"}, {"name": "MappedStringValueEntry", "field": [{"name": "key", "number": 1, "label": 1, "type": 9, "json_name": "key", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "value", "number": 2, "label": 1, "type": 9, "json_name": "value", "_type": "google.protobuf.FieldDescriptorProto"}], "options": {"map_entry": true, "_type": "google.protobuf.MessageOptions"}, "_type": "google.protobuf.DescriptorProto"}, {"name": "MappedNestedValueEntry", "field": [{"name": "key", "number": 1, "label": 1, "type": 9, "json_name": "key", "_type": "google.protobuf.FieldDescriptorProto"}, {"name": "value", "number": 2, "label": 1, "type": 11, "type_name": "grpc.gateway.examples.examplepb.ABitOfEverything.Nested", "json_name": "value", "_type": "google.protobuf.FieldDescriptorProto"}], "options": {"map_entry": true, "_type": "google.protobuf.MessageOptions"}, "_type": "google.protobuf.DescriptorProto"}], "oneof_decl": [{"name": "oneof_value", "_type": "google.protobuf.OneofDescriptorProto"}], "_type": "google.protobuf.DescriptorProto", "_description": "Intentionaly complicated message type to cover much features of Protobuf.\n NEXT ID: 27"}], "enum_type": [{"name": "NumericEnum", "value": [{"name": "ZERO", "number": 0, "_type": "google.protobuf.EnumValueDescriptorProto", "_description": "ZERO means 0"}, {"name": "ONE", "number": 1, "_type": "google.protobuf.EnumValueDescriptorProto", "_description": "ONE means 1"}], "_type": "google.protobuf.EnumDescriptorProto", "_description": "NumericEnum is one or zero."}], "service": [{"name": "ABitOfEverythingService", "method": [{"name": "Create", "input_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "output_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "options": {"http": {"post": "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}", "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}, {"name": "CreateBody", "input_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "output_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "options": {"http": {"post": "/v1/example/a_bit_of_everything", "body": "*", "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}, {"name": "Lookup", "input_type": "sub2.IdMessage", "output_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "options": {"http": {"get": "/v1/example/a_bit_of_everything/{uuid}", "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}, {"name": "Update", "input_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "output_type": "google.protobuf.Empty", "options": {"http": {"put": "/v1/example/a_bit_of_everything/{uuid}", "body": "*", "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}, {"name": "Delete", "input_type": "sub2.IdMessage", "output_type": "google.protobuf.Empty", "options": {"http": {"delete": "/v1/example/a_bit_of_everything/{uuid}", "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}, {"name": "Echo", "input_type": "grpc.gateway.examples.sub.StringMessage", "output_type": "grpc.gateway.examples.sub.StringMessage", "options": {"http": {"get": "/v1/example/a_bit_of_everything/echo/{value}", "additional_bindings": [{"post": "/v2/example/echo", "body": "value", "_type": "google.api.HttpRule"}, {"get": "/v2/example/echo", "_type": "google.api.HttpRule"}], "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}, {"name": "DeepPathEcho", "input_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "output_type": "grpc.gateway.examples.examplepb.ABitOfEverything", "options": {"http": {"post": "/v1/example/a_bit_of_everything/{single_nested.name}", "body": "*", "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}, {"name": "Timeout", "input_type": "google.protobuf.Empty", "output_type": "google.protobuf.Empty", "options": {"http": {"get": "/v2/example/timeout", "_type": "google.api.HttpRule"}, "_type": "google.protobuf.MethodOptions"}, "_type": "google.protobuf.MethodDescriptorProto"}], "_type": "google.protobuf.ServiceDescriptorProto"}], "options": {"go_package": "examplepb", "_type": "google.protobuf.FileOptions"}, "syntax": "proto3", "_type": "google.protobuf.FileDescriptorProto"}
diff --git a/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.proto b/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.proto
deleted file mode 100644
index bb375bb..0000000
--- a/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.proto
+++ /dev/null
@@ -1,122 +0,0 @@
-syntax = "proto3";
-package examples.example;
-
-import "google/api/annotations.proto";
-import "google/protobuf/empty.proto";
-import "sub.proto";
-import "sub2.proto";
-import "google/protobuf/timestamp.proto";
-
-// Intentionaly complicated message type to cover much features of Protobuf.
-// NEXT ID: 27
-message ABitOfEverything {
- // Nested is nested type.
- message Nested {
- // name is nested field.
- string name = 1;
- uint32 amount = 2;
- // DeepEnum is one or zero.
- enum DeepEnum {
- // FALSE is false.
- FALSE = 0;
- // TRUE is true.
- TRUE = 1;
- }
- DeepEnum ok = 3;
- }
- Nested single_nested = 25;
-
- string uuid = 1;
- repeated Nested nested = 2;
- float float_value = 3;
- double double_value = 4;
- int64 int64_value = 5;
- uint64 uint64_value = 6;
- int32 int32_value = 7;
- fixed64 fixed64_value = 8;
- fixed32 fixed32_value = 9;
- bool bool_value = 10;
- string string_value = 11;
- // TODO(yugui) add bytes_value
- uint32 uint32_value = 13;
- NumericEnum enum_value = 14;
- sfixed32 sfixed32_value = 15;
- sfixed64 sfixed64_value = 16;
- sint32 sint32_value = 17;
- sint64 sint64_value = 18;
- repeated string repeated_string_value = 19;
- oneof oneof_value {
- google.protobuf.Empty oneof_empty = 20;
- string oneof_string = 21;
- }
-
- map<string, NumericEnum> map_value = 22;
- map<string, string> mapped_string_value = 23;
- map<string, Nested> mapped_nested_value = 24;
-
- string nonConventionalNameValue = 26;
-
- google.protobuf.Timestamp timestamp_value = 27;
-}
-
-// NumericEnum is one or zero.
-enum NumericEnum {
- // ZERO means 0
- ZERO = 0;
- // ONE means 1
- ONE = 1;
-}
-
-service ABitOfEverythingService {
- rpc Create(ABitOfEverything) returns (ABitOfEverything) {
- // TODO add enum_value
- option (google.api.http) = {
- post: "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value=strprefix/*}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}"
- };
- }
- rpc CreateBody(ABitOfEverything) returns (ABitOfEverything) {
- option (google.api.http) = {
- post: "/v1/example/a_bit_of_everything"
- body: "*"
- };
- }
- rpc Lookup(sub2.IdMessage) returns (ABitOfEverything) {
- option (google.api.http) = {
- get: "/v1/example/a_bit_of_everything/{uuid}"
- };
- }
- rpc Update(ABitOfEverything) returns (google.protobuf.Empty) {
- option (google.api.http) = {
- put: "/v1/example/a_bit_of_everything/{uuid}"
- body: "*"
- };
- }
- rpc Delete(sub2.IdMessage) returns (google.protobuf.Empty) {
- option (google.api.http) = {
- delete: "/v1/example/a_bit_of_everything/{uuid}"
- };
- }
- rpc Echo(examples.sub.StringMessage) returns (examples.sub.StringMessage) {
- option (google.api.http) = {
- get: "/v1/example/a_bit_of_everything/echo/{value}"
- additional_bindings {
- post: "/v2/example/echo"
- body: "value"
- }
- additional_bindings {
- get: "/v2/example/echo"
- }
- };
- }
- rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) {
- option (google.api.http) = {
- post: "/v1/example/a_bit_of_everything/{single_nested.name}"
- body: "*"
- };
- }
- rpc Timeout(google.protobuf.Empty) returns (google.protobuf.Empty) {
- option (google.api.http) = {
- get: "/v2/example/timeout",
- };
- }
-}
diff --git a/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.swagger.json b/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.swagger.json
deleted file mode 100644
index 35bbca5..0000000
--- a/tests/utests/chameleon/protoc_plugins/a_bit_of_everything.swagger.json
+++ /dev/null
@@ -1,541 +0,0 @@
-{
- "swagger": "2.0",
- "info": {
- "title": "test.proto",
- "version": "version not set"
- },
- "schemes": [
- "http",
- "https"
- ],
- "consumes": [
- "application/json"
- ],
- "produces": [
- "application/json"
- ],
- "paths": {
- "/v1/example/a_bit_of_everything": {
- "post": {
- "operationId": "CreateBody",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/examples.example.ABitOfEverything"
- }
- }
- },
- "parameters": [
- {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/examples.example.ABitOfEverything"
- }
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- }
- },
- "/v1/example/a_bit_of_everything/echo/{value}": {
- "get": {
- "operationId": "Echo",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/examples.sub.StringMessage"
- }
- }
- },
- "parameters": [
- {
- "name": "value",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "string"
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- }
- },
- "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}": {
- "post": {
- "operationId": "Create",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/examples.example.ABitOfEverything"
- }
- }
- },
- "parameters": [
- {
- "name": "float_value",
- "in": "path",
- "required": true,
- "type": "number",
- "format": "float"
- },
- {
- "name": "double_value",
- "in": "path",
- "required": true,
- "type": "number",
- "format": "double"
- },
- {
- "name": "int64_value",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "int64"
- },
- {
- "name": "uint64_value",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "uint64"
- },
- {
- "name": "int32_value",
- "in": "path",
- "required": true,
- "type": "integer",
- "format": "int32"
- },
- {
- "name": "fixed64_value",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "uint64"
- },
- {
- "name": "fixed32_value",
- "in": "path",
- "required": true,
- "type": "integer",
- "format": "int64"
- },
- {
- "name": "bool_value",
- "in": "path",
- "required": true,
- "type": "boolean",
- "format": "boolean"
- },
- {
- "name": "string_value",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "string"
- },
- {
- "name": "uint32_value",
- "in": "path",
- "required": true,
- "type": "integer",
- "format": "int64"
- },
- {
- "name": "sfixed32_value",
- "in": "path",
- "required": true,
- "type": "integer",
- "format": "int32"
- },
- {
- "name": "sfixed64_value",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "int64"
- },
- {
- "name": "sint32_value",
- "in": "path",
- "required": true,
- "type": "integer",
- "format": "int32"
- },
- {
- "name": "sint64_value",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "int64"
- },
- {
- "name": "nonConventionalNameValue",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "string"
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- }
- },
- "/v1/example/a_bit_of_everything/{single_nested.name}": {
- "post": {
- "operationId": "DeepPathEcho",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/examples.example.ABitOfEverything"
- }
- }
- },
- "parameters": [
- {
- "name": "single_nested.name",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "string"
- },
- {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/examples.example.ABitOfEverything"
- }
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- }
- },
- "/v1/example/a_bit_of_everything/{uuid}": {
- "get": {
- "operationId": "Lookup",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/examples.example.ABitOfEverything"
- }
- }
- },
- "parameters": [
- {
- "name": "uuid",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "string"
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- },
- "delete": {
- "operationId": "Delete",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/google.protobuf.Empty"
- }
- }
- },
- "parameters": [
- {
- "name": "uuid",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "string"
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- },
- "put": {
- "operationId": "Update",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/google.protobuf.Empty"
- }
- }
- },
- "parameters": [
- {
- "name": "uuid",
- "in": "path",
- "required": true,
- "type": "string",
- "format": "string"
- },
- {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/examples.example.ABitOfEverything"
- }
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- }
- },
- "/v2/example/echo": {
- "get": {
- "operationId": "Echo",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/examples.sub.StringMessage"
- }
- }
- },
- "tags": [
- "ABitOfEverythingService"
- ]
- },
- "post": {
- "operationId": "Echo",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/examples.sub.StringMessage"
- }
- }
- },
- "parameters": [
- {
- "name": "body",
- "in": "body",
- "required": true,
- "schema": {
- "$ref": "#/definitions/examples.sub.StringMessage"
- }
- }
- ],
- "tags": [
- "ABitOfEverythingService"
- ]
- }
- },
- "/v2/example/timeout": {
- "get": {
- "operationId": "Timeout",
- "responses": {
- "200": {
- "description": "",
- "schema": {
- "$ref": "#/definitions/google.protobuf.Empty"
- }
- }
- },
- "tags": [
- "ABitOfEverythingService"
- ]
- }
- }
- },
- "definitions": {
- "examples.example.ABitOfEverything.Nested": {
- "type": "object",
- "properties": {
- "amount": {
- "type": "integer",
- "format": "int64"
- },
- "name": {
- "type": "string",
- "format": "string",
- "description": "name is nested field."
- },
- "ok": {
- "$ref": "#/definitions/examples.example.ABitOfEverything.Nested.DeepEnum"
- }
- },
- "description": "Nested is nested type."
- },
- "examples.example.ABitOfEverything.Nested.DeepEnum": {
- "type": "string",
- "enum": [
- "FALSE",
- "TRUE"
- ],
- "default": "FALSE",
- "description": "DeepEnum is one or zero.\nValid values:\n - FALSE: FALSE is false.\n - TRUE: TRUE is true."
- },
- "examples.example.ABitOfEverything": {
- "type": "object",
- "properties": {
- "bool_value": {
- "type": "boolean",
- "format": "boolean"
- },
- "double_value": {
- "type": "number",
- "format": "double"
- },
- "enum_value": {
- "$ref": "#/definitions/examples.example.NumericEnum"
- },
- "fixed32_value": {
- "type": "integer",
- "format": "int64"
- },
- "fixed64_value": {
- "type": "string",
- "format": "uint64"
- },
- "float_value": {
- "type": "number",
- "format": "float"
- },
- "int32_value": {
- "type": "integer",
- "format": "int32"
- },
- "int64_value": {
- "type": "string",
- "format": "int64"
- },
- "map_value": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/definitions/examples.example.NumericEnum"
- }
- },
- "mapped_nested_value": {
- "type": "object",
- "additionalProperties": {
- "$ref": "#/definitions/examples.example.ABitOfEverything.Nested"
- }
- },
- "mapped_string_value": {
- "type": "object",
- "additionalProperties": {
- "type": "string",
- "format": "string"
- }
- },
- "nested": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/examples.example.ABitOfEverything.Nested"
- }
- },
- "nonConventionalNameValue": {
- "type": "string",
- "format": "string"
- },
- "oneof_empty": {
- "$ref": "#/definitions/google.protobuf.Empty"
- },
- "oneof_string": {
- "type": "string",
- "format": "string"
- },
- "repeated_string_value": {
- "type": "array",
- "items": {
- "type": "string",
- "format": "string"
- }
- },
- "sfixed32_value": {
- "type": "integer",
- "format": "int32"
- },
- "sfixed64_value": {
- "type": "string",
- "format": "int64"
- },
- "single_nested": {
- "$ref": "#/definitions/examples.example.ABitOfEverything.Nested"
- },
- "sint32_value": {
- "type": "integer",
- "format": "int32"
- },
- "sint64_value": {
- "type": "string",
- "format": "int64"
- },
- "string_value": {
- "type": "string",
- "format": "string"
- },
- "timestamp_value": {
- "type": "string",
- "format": "date-time"
- },
- "uint32_value": {
- "type": "integer",
- "format": "int64",
- "description": "TODO(yugui) add bytes_value"
- },
- "uint64_value": {
- "type": "string",
- "format": "uint64"
- },
- "uuid": {
- "type": "string",
- "format": "string"
- }
- },
- "description": "Intentionaly complicated message type to cover much features of Protobuf.\n NEXT ID: 27"
- },
- "examples.example.NumericEnum": {
- "type": "string",
- "enum": [
- "ZERO",
- "ONE"
- ],
- "default": "ZERO",
- "description": "NumericEnum is one or zero.\nValid values:\n - ZERO: ZERO means 0\n - ONE: ONE means 1"
- },
- "google.protobuf.Empty": {
- "type": "object",
- "description": "A generic empty message that you can re-use to avoid defining duplicated\n empty messages in your APIs. A typical example is to use it as the request\n or the response type of an API method. For instance:\n\n service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n }\n\n The JSON representation for `Empty` is empty JSON object `{}`."
- },
- "sub2.IdMessage": {
- "type": "object",
- "properties": {
- "uuid": {
- "type": "string",
- "format": "string"
- }
- }
- },
- "examples.sub.StringMessage": {
- "type": "object",
- "properties": {
- "value": {
- "type": "string",
- "format": "string"
- }
- }
- }
- }
-}
diff --git a/tests/utests/chameleon/protoc_plugins/descriptor_parser_test.py b/tests/utests/chameleon/protoc_plugins/descriptor_parser_test.py
deleted file mode 100644
index ada7e54..0000000
--- a/tests/utests/chameleon/protoc_plugins/descriptor_parser_test.py
+++ /dev/null
@@ -1,270 +0,0 @@
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-from unittest import TestCase
-
-from chameleon.protoc_plugins.descriptor_parser import DescriptorParser
-from tests.utests.chameleon.protoc_plugins.test_utils import \
- generate_plugin_request, json_rt
-from tests.utests.chameleon.protoc_plugins.test_utils import unindent
-
-
-class DescriptorParserTests(TestCase):
-
- maxDiff = 10000
-
- def test_empty(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- """)
-
- expected = dict(
- syntax='proto3',
- name='test.proto',
- package='test',
- source_code_info=dict(
- location=[
- dict(span=[1, 0, 2, 13]),
- dict(span=[1, 0, 18], path=[12]),
- dict(span=[2, 8, 12], path=[2])
- ]
- )
- )
-
- request = generate_plugin_request(proto)
- assert len(request.proto_file) == 1
- parser = DescriptorParser()
- native_data = parser.parse_file_descriptor(request.proto_file[0])
- self.assertEqual(native_data, expected)
-
- def test_message_with_comment_folding(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
-
- // Sample message
- message SampleMessage {
- string name = 1; // inline comment
-
- // prefix comment
- repeated int32 number = 2;
-
- bool bool = 3;
- // suffix comment
- }
- """)
-
- expected = {
- u'syntax': u'proto3',
- u'name': u'test.proto',
- u'package': u'test',
- u'message_type': [
- {
- u'_description': u'Sample message',
- u'name': u'SampleMessage',
- u'field': [{
- u'_description': u'inline comment',
- u'json_name': u'name',
- u'name': u'name',
- u'label': 1,
- u'number': 1,
- u'type': 9
- }, {
- u'_description': u'prefix comment',
- u'json_name': u'number',
- u'name': u'number',
- u'label': 3,
- u'number': 2,
- u'type': 5
- }, {
- u'_description': u'suffix comment',
- u'json_name': u'bool',
- u'name': u'bool',
- u'label': 1,
- u'number': 3,
- u'type': 8
- }],
- }
- ]
- }
-
- request = generate_plugin_request(proto)
- assert len(request.proto_file) == 1
- parser = DescriptorParser()
- native_data = parser.parse_file_descriptor(request.proto_file[0],
- fold_comments=True)
- self.assertEqual(json_rt(native_data), expected)
-
- def test_message_with_comment_folding_and_type_marking(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
-
- // Sample message
- message SampleMessage {
- string name = 1; // inline comment
-
- // prefix comment
- repeated int32 number = 2;
-
- bool bool = 3;
- // suffix comment
- }
- """)
-
- expected = {
- u'syntax': u'proto3',
- u'name': u'test.proto',
- u'package': u'test',
- u'_type': u'google.protobuf.FileDescriptorProto',
- u'message_type': [
- {
- u'_type': u'google.protobuf.DescriptorProto',
- u'_description': u'Sample message',
- u'name': u'SampleMessage',
- u'field': [{
- u'_type': u'google.protobuf.FieldDescriptorProto',
- u'_description': u'inline comment',
- u'json_name': u'name',
- u'name': u'name',
- u'label': 1,
- u'number': 1,
- u'type': 9
- }, {
- u'_type': u'google.protobuf.FieldDescriptorProto',
- u'_description': u'prefix comment',
- u'json_name': u'number',
- u'name': u'number',
- u'label': 3,
- u'number': 2,
- u'type': 5
- }, {
- u'_type': u'google.protobuf.FieldDescriptorProto',
- u'_description': u'suffix comment',
- u'json_name': u'bool',
- u'name': u'bool',
- u'label': 1,
- u'number': 3,
- u'type': 8
- }],
- }
- ]
- }
-
- request = generate_plugin_request(proto)
- assert len(request.proto_file) == 1
- parser = DescriptorParser()
- native_data = parser.parse_file_descriptor(request.proto_file[0],
- type_tag_name='_type',
- fold_comments=True)
- self.assertEqual(json_rt(native_data), expected)
-
- def test_http_annotations_carry_over(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {}
- service Test {
- rpc Call(Null) returns(Null) {
- option (google.api.http) = {
- get: "/some/path"
- };
- }
- }
- """)
-
- expected = {
- u'syntax': u'proto3',
- u'name': u'test.proto',
- u'package': u'test',
- u'dependency': [u'google/api/annotations.proto'],
- u'message_type': [{u'name': u'Null'}],
- u'service': [{
- u'name': u'Test',
- u'method': [{
- u'name': u'Call',
- u'input_type': u'.test.Null',
- u'output_type': u'.test.Null',
- u'options': {
- u'http': {
- u'get': u'/some/path'
- }
- }
- }]
- }]
- }
-
- request = generate_plugin_request(proto)
- assert len(request.proto_file) == 4
- parser = DescriptorParser()
- native_data = parser.parse_file_descriptor(request.proto_file[3],
- fold_comments=True)
- self.assertEqual(json_rt(native_data), expected)
-
- def test_http_annotations_carryover_and_all_components(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {}
- service Test {
- rpc Call(Null) returns(Null) {
- option (google.api.http) = {
- get: "/some/path"
- };
- }
- }
- """)
-
- expected = {
- u'syntax': 'proto3',
- u'name': u'test.proto',
- u'package': u'test',
- u'dependency': [u'google/api/annotations.proto'],
- u'message_type': [{u'name': u'Null'}],
- u'service': [{
- u'name': u'Test',
- u'method': [{
- u'name': u'Call',
- u'input_type': u'.test.Null',
- u'output_type': u'.test.Null',
- u'options': {
- u'http': {
- u'get': u'/some/path'
- }
- }
- }]
- }]
- }
-
- request = generate_plugin_request(proto)
- assert len(request.proto_file) == 4
- parser = DescriptorParser()
- native_data = parser.parse_file_descriptors(request.proto_file,
- fold_comments=True)
- self.assertEqual([d['name'] for d in native_data], [
- u'google/api/http.proto',
- u'google/protobuf/descriptor.proto',
- u'google/api/annotations.proto',
- u'test.proto'
- ])
- self.assertEqual(json_rt(native_data[3]), expected)
diff --git a/tests/utests/chameleon/protoc_plugins/empty.native.json b/tests/utests/chameleon/protoc_plugins/empty.native.json
deleted file mode 100644
index e8ac6ba..0000000
--- a/tests/utests/chameleon/protoc_plugins/empty.native.json
+++ /dev/null
@@ -1 +0,0 @@
-{"name": "google/protobuf/empty.proto", "package": "google.protobuf", "message_type": [{"name": "Empty", "_type": "google.protobuf.DescriptorProto", "_description": "A generic empty message that you can re-use to avoid defining duplicated\n empty messages in your APIs. A typical example is to use it as the request\n or the response type of an API method. For instance:\n\n service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n }\n\n The JSON representation for `Empty` is empty JSON object `{}`."}], "options": {"java_package": "com.google.protobuf", "java_outer_classname": "EmptyProto", "java_multiple_files": true, "go_package": "github.com/golang/protobuf/ptypes/empty", "java_generate_equals_and_hash": true, "cc_enable_arenas": true, "objc_class_prefix": "GPB", "csharp_namespace": "Google.Protobuf.WellKnownTypes", "_type": "google.protobuf.FileOptions"}, "syntax": "proto3", "_type": "google.protobuf.FileDescriptorProto"}
\ No newline at end of file
diff --git a/tests/utests/chameleon/protoc_plugins/empty.swagger.json b/tests/utests/chameleon/protoc_plugins/empty.swagger.json
deleted file mode 100644
index dee6c59..0000000
--- a/tests/utests/chameleon/protoc_plugins/empty.swagger.json
+++ /dev/null
@@ -1 +0,0 @@
-{"info": {"version": "version not set", "title": "google/protobuf/empty.proto"}, "paths": {}, "schemes": ["http", "https"], "produces": ["application/json"], "definitions": {"google.protobuf.Empty": {"type": "object", "description": "A generic empty message that you can re-use to avoid defining duplicated\n empty messages in your APIs. A typical example is to use it as the request\n or the response type of an API method. For instance:\n\n service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n }\n\n The JSON representation for `Empty` is empty JSON object `{}`.", "properties": {}}}, "swagger": "2.0", "consumes": ["application/json"]}
\ No newline at end of file
diff --git a/tests/utests/chameleon/protoc_plugins/null_plugin.py b/tests/utests/chameleon/protoc_plugins/null_plugin.py
deleted file mode 100755
index 9443304..0000000
--- a/tests/utests/chameleon/protoc_plugins/null_plugin.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-"""
-Protoc plugin that simply emits the binary content of the CodeGeneratorRequest
-it is called with for each <name>.proto file. The name of the file the content
-is saved is protoc.request.
-"""
-import base64
-import sys
-
-from google.protobuf.compiler import plugin_pb2
-
-if __name__ == '__main__':
- response = plugin_pb2.CodeGeneratorResponse()
- f = response.file.add()
- f.name = 'protoc.request'
- f.content = base64.encodestring(sys.stdin.read())
- sys.stdout.write(response.SerializeToString())
diff --git a/tests/utests/chameleon/protoc_plugins/sub.native.json b/tests/utests/chameleon/protoc_plugins/sub.native.json
deleted file mode 100644
index 460b84d..0000000
--- a/tests/utests/chameleon/protoc_plugins/sub.native.json
+++ /dev/null
@@ -1 +0,0 @@
-{"name": "examples/sub/message.proto", "package": "grpc.gateway.examples.sub", "message_type": [{"name": "StringMessage", "field": [{"name": "value", "number": 1, "label": 2, "type": 9, "json_name": "value", "_type": "google.protobuf.FieldDescriptorProto"}], "_type": "google.protobuf.DescriptorProto"}], "options": {"go_package": "sub", "_type": "google.protobuf.FileOptions"}, "_type": "google.protobuf.FileDescriptorProto"}
\ No newline at end of file
diff --git a/tests/utests/chameleon/protoc_plugins/sub.proto b/tests/utests/chameleon/protoc_plugins/sub.proto
deleted file mode 100644
index d3f2462..0000000
--- a/tests/utests/chameleon/protoc_plugins/sub.proto
+++ /dev/null
@@ -1,6 +0,0 @@
-syntax = "proto2";
-package examples.sub;
-
-message StringMessage {
- required string value = 1;
-}
diff --git a/tests/utests/chameleon/protoc_plugins/sub.swagger.json b/tests/utests/chameleon/protoc_plugins/sub.swagger.json
deleted file mode 100644
index 5a2f659..0000000
--- a/tests/utests/chameleon/protoc_plugins/sub.swagger.json
+++ /dev/null
@@ -1 +0,0 @@
-{"info": {"version": "version not set", "title": "examples/sub/message.proto"}, "paths": {}, "produces": ["application/json"], "definitions": {"grpc.gateway.examples.sub.StringMessage": {"description": "", "properties": {"value": {"format": "string", "type": "string"}}, "type": "object"}}, "swagger": "2.0", "consumes": ["application/json"], "schemes": ["http", "https"]}
diff --git a/tests/utests/chameleon/protoc_plugins/sub2.native.json b/tests/utests/chameleon/protoc_plugins/sub2.native.json
deleted file mode 100644
index 9ddf68f..0000000
--- a/tests/utests/chameleon/protoc_plugins/sub2.native.json
+++ /dev/null
@@ -1 +0,0 @@
-{"name": "examples/sub2/message.proto", "package": "sub2", "message_type": [{"name": "IdMessage", "field": [{"name": "uuid", "number": 1, "label": 1, "type": 9, "json_name": "uuid", "_type": "google.protobuf.FieldDescriptorProto"}], "_type": "google.protobuf.DescriptorProto"}], "options": {"go_package": "github.com/grpc-ecosystem/grpc-gateway/examples/sub2", "_type": "google.protobuf.FileOptions"}, "syntax": "proto3", "_type": "google.protobuf.FileDescriptorProto"}
\ No newline at end of file
diff --git a/tests/utests/chameleon/protoc_plugins/sub2.proto b/tests/utests/chameleon/protoc_plugins/sub2.proto
deleted file mode 100644
index 7b98db0..0000000
--- a/tests/utests/chameleon/protoc_plugins/sub2.proto
+++ /dev/null
@@ -1,6 +0,0 @@
-syntax = "proto3";
-package sub2;
-
-message IdMessage {
- string uuid = 1;
-}
diff --git a/tests/utests/chameleon/protoc_plugins/sub2.swagger.json b/tests/utests/chameleon/protoc_plugins/sub2.swagger.json
deleted file mode 100644
index 575e709..0000000
--- a/tests/utests/chameleon/protoc_plugins/sub2.swagger.json
+++ /dev/null
@@ -1 +0,0 @@
-{"info": {"version": "version not set", "title": "examples/sub2/message.proto"}, "paths": {}, "produces": ["application/json"], "definitions": {"sub2.IdMessage": {"description": "", "type": "object", "properties": {"uuid": {"format": "string", "type": "string"}}}}, "swagger": "2.0", "consumes": ["application/json"], "schemes": ["http", "https"]}
diff --git a/tests/utests/chameleon/protoc_plugins/swagger_template_test.py b/tests/utests/chameleon/protoc_plugins/swagger_template_test.py
deleted file mode 100644
index 577d070..0000000
--- a/tests/utests/chameleon/protoc_plugins/swagger_template_test.py
+++ /dev/null
@@ -1,1069 +0,0 @@
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import json
-import os
-from unittest import TestCase
-from mock import Mock
-
-from chameleon.protoc_plugins.descriptor_parser import DescriptorParser
-from chameleon.protoc_plugins.swagger_template \
- import native_descriptors_to_swagger, DuplicateMethodAndPathError, \
- ProtobufCompilationFailedError, InvalidPathArgumentError
-from tests.utests.chameleon.protoc_plugins.test_utils import unindent, \
- json_rt, generate_plugin_request, load_file
-
-
-class SwaggerTemplateTests(TestCase):
-
- maxDiff = 10000
-
- def gen_swagger(self, proto):
- request = generate_plugin_request(proto)
- parser = DescriptorParser()
- native_data = parser.parse_file_descriptors(request.proto_file,
- type_tag_name='_type',
- fold_comments=True)
- swagger = native_descriptors_to_swagger(native_data)
- return swagger
-
- def test_swagger_url(self):
-
- grpc = {
- '_channel': {
- '_Rendezvous': {}
- }
- }
- from chameleon.web_server.web_server import WebServer
- server = yield WebServer(9101, '/', '/swagger', grpc)
- server.app = 'app'
-
- server.add_swagger_routes = Mock()
-
- self.assertEqual(server.add_swagger_routes.call_count, 1)
- server.add_swagger_routes.assert_called_once_with('app', '/swagger')
-
- def test_empty_def(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- """)
-
- expected_swagger = {
- u'swagger': u'2.0',
- u'info': {
- u'title': u'test.proto',
- u'version': u'version not set'
- },
- u'schemes': [u"http", u"https"],
- u'consumes': [u"application/json"],
- u'produces': [u"application/json"],
- u'paths': {},
- u'definitions': {}
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger), expected_swagger)
-
- def test_empty_message_with_service(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {}
- service TestService {
- rpc Get(Null) returns(Null) {
- option (google.api.http) = {
- get: "/test"
- };
- }
- }
- """)
-
- expected_swagger = {
- u'swagger': u'2.0',
- u'info': {
- u'title': u'test.proto',
- u'version': u"version not set"
- },
- u'schemes': [u"http", u"https"],
- u'consumes': [u"application/json"],
- u'produces': [u"application/json"],
- u'paths': {
- u'/test': {
- u'get': {
- u'operationId': u'Get',
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {
- u'$ref': u'#/definitions/test.Null'
- }
- }
- },
- u'tags': [u'TestService']
- }
- }
- },
- u'definitions': {
- u'test.Null': {
- u'type': u'object'
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger), expected_swagger)
-
- def test_simple_annotated_message_with_simple_annotated_service(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
-
- // Simple Message
- message Simple {
- string str = 1; // a string attribute
- int32 int = 2; // an int32 attribute
- }
-
- // Service to get things done
- service TestService {
-
- /* Get simple answer
- *
- * Returns the true answer to all of life's persistent questions.
- */
- rpc Get(Simple) returns(Simple) {
- option (google.api.http) = {
- get: "/test"
- };
- }
- }
- """)
-
- expected_swagger = {
- u'swagger': u'2.0',
- u'info': {
- u'title': u'test.proto',
- u'version': u"version not set"
- },
- u'schemes': [u"http", u"https"],
- u'consumes': [u"application/json"],
- u'produces': [u"application/json"],
- u'paths': {
- u'/test': {
- u'get': {
- u'summary': u'Get simple answer',
- u'description':
- u' Returns the true answer to all of life\'s '
- u'persistent questions.',
- u'operationId': u'Get',
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {
- u'$ref': u'#/definitions/test.Simple'
- }
- }
- },
- u'tags': [u'TestService']
- }
- }
- },
- u'definitions': {
- u'test.Simple': {
- u'description': u'Simple Message',
- u'type': u'object',
- u'properties': {
- u'int': {
- u'description': u'an int32 attribute',
- u'type': u'integer',
- u'format': u'int32'
- },
- u'str': {
- u'description': u'a string attribute',
- u'type': u'string',
- u'format': u'string'
- }
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger), expected_swagger)
-
- def test_method_input_params_in_body(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
-
- // Simple Message
- message Simple {
- string str = 1; // a string attribute
- int32 int = 2; // an int32 attribute
- }
-
- // Service to get things done
- service TestService {
-
- /* Get simple answer
- *
- * Returns the true answer to all of life's persistent questions.
- */
- rpc Get(Simple) returns(Simple) {
- option (google.api.http) = {
- get: "/test"
- };
- }
-
- /*
- * Make up an answer (notice the leading blank line)
- *
- * Define the ultimate answer
- */
- rpc MakeUp(Simple) returns(Simple) {
- option (google.api.http) = {
- post: "/test"
- body: "*"
- };
- }
- }
- """)
-
- expected_swagger = {
- u'swagger': u'2.0',
- u'info': {
- u'title': u'test.proto',
- u'version': u"version not set"
- },
- u'schemes': [u"http", u"https"],
- u'consumes': [u"application/json"],
- u'produces': [u"application/json"],
- u'paths': {
- u'/test': {
- u'get': {
- u'summary': u'Get simple answer',
- u'description':
- u' Returns the true answer to all of life\'s '
- u'persistent questions.',
- u'operationId': u'Get',
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {
- u'$ref': u'#/definitions/test.Simple'
- }
- }
- },
- u'tags': [u'TestService']
- },
- u'post': {
- u'summary': u'Make up an answer (notice the leading '
- u'blank line)',
- u'description': u' Define the ultimate answer',
- u'operationId': u'MakeUp',
- u'parameters': [{
- u'name': u'body',
- u'in': u'body',
- u'required': True,
- u'schema': {u'$ref': u'#/definitions/test.Simple'}
- }],
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {
- u'$ref': u'#/definitions/test.Simple'
- }
- }
- },
- u'tags': [u'TestService']
- }
- }
- },
- u'definitions': {
- u'test.Simple': {
- u'description': u'Simple Message',
- u'type': u'object',
- u'properties': {
- u'int': {
- u'description': u'an int32 attribute',
- u'type': u'integer',
- u'format': u'int32'
- },
- u'str': {
- u'description': u'a string attribute',
- u'type': u'string',
- u'format': u'string'
- }
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger), expected_swagger)
-
- def test_catch_repeating_verbs_for_same_path(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {}
- service TestService {
- rpc Get(Null) returns(Null) {
- option (google.api.http) = {
- get: "/test"
- };
- }
- rpc MakeUp(Null) returns(Null) {
- option (google.api.http) = {
- get: "/test"
- body: "*"
- };
- }
- }
- """)
-
- with self.assertRaises(DuplicateMethodAndPathError):
- self.gen_swagger(proto)
-
- def test_catch_unresolved_message_type_reference(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {}
- service TestService {
- rpc Get(Simple) returns(Simple) {
- option (google.api.http) = {
- get: "/test"
- };
- }
- rpc MakeUp(Simple) returns(Simple) {
- option (google.api.http) = {
- get: "/test"
- body: "*"
- };
- }
- }
- """)
-
- with self.assertRaises(ProtobufCompilationFailedError):
- self.gen_swagger(proto)
-
- def test_path_parameter_handling(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Simple {
- string str = 1;
- int32 int = 2;
- }
- service TestService {
- rpc Get(Simple) returns(Simple) {
- option (google.api.http) = {
- get: "/test/{str}/{int}"
- };
- }
- }
- """)
-
- expected_swagger_path = {
- u'/test/{str}/{int}': {
- u'get': {
- u'operationId': u'Get',
- u'parameters': [{
- u'name': u'str',
- u'in': u'path',
- u'type': u'string',
- u'format': u'string',
- u'required': True
- }, {
- u'name': u'int',
- u'in': u'path',
- u'type': u'integer',
- u'format': u'int32',
- u'required': True
- }],
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {
- u'$ref': u'#/definitions/test.Simple'
- }
- }
- },
- u'tags': [u'TestService']
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['paths']), expected_swagger_path)
-
- def test_path_parameter_error_handling(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Simple {
- string str = 1;
- int32 int = 2;
- }
- service TestService {
- rpc Get(Simple) returns(Simple) {
- option (google.api.http) = {
- get: "/test/{str}/{xxxxx}/{int}"
- };
- }
- }
- """)
-
- with self.assertRaises(InvalidPathArgumentError):
- self.gen_swagger(proto)
-
- def test_alternative_bindings(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Simple {
- string str = 1;
- int32 int = 2;
- }
- service TestService {
- rpc Get(Simple) returns(Simple) {
- option (google.api.http) = {
- get: "/v1/test/{str}/{int}"
- additional_bindings {
- post: "/v2/test"
- body: "*"
- }
- additional_bindings {
- get: "/v2/test/{int}/{str}"
- }
- };
- }
- }
- """)
-
- expected_swagger_path = {
- u'/v1/test/{str}/{int}': {
- u'get': {
- u'operationId': u'Get',
- u'parameters': [{
- u'name': u'str',
- u'in': u'path',
- u'type': u'string',
- u'format': u'string',
- u'required': True
- }, {
- u'name': u'int',
- u'in': u'path',
- u'type': u'integer',
- u'format': u'int32',
- u'required': True
- }],
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {
- u'$ref': u'#/definitions/test.Simple'
- }
- }
- },
- u'tags': [u'TestService']
- }
- },
- u'/v2/test': {
- u'post': {
- u'operationId': u'Get',
- u'parameters': [{
- u'in': u'body',
- u'name': u'body',
- u'required': True,
- u'schema': {u'$ref': u'#/definitions/test.Simple'}
- }],
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {u'$ref': u'#/definitions/test.Simple'}
- }
- },
- u'tags': [u'TestService']
- }
- },
- u'/v2/test/{int}/{str}': {
- u'get': {
- u'operationId': u'Get',
- u'parameters': [{
- u'format': u'int32',
- u'in': u'path',
- u'name': u'int',
- u'required': True,
- u'type': u'integer'
- }, {
- u'format': u'string',
- u'in': u'path',
- u'name': u'str',
- u'required': True,
- u'type': u'string'
- }],
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {u'$ref': u'#/definitions/test.Simple'}
- }
- },
- u'tags': [u'TestService']
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['paths']), expected_swagger_path)
-
- def test_google_null(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- import "google/protobuf/empty.proto";
- service TestService {
- rpc Get(google.protobuf.Empty) returns(google.protobuf.Empty) {
- option (google.api.http) = {
- get: "/echo"
- };
- }
- }
- """)
-
- expected_swagger = {
- u'swagger': u'2.0',
- u'info': {
- u'title': u'test.proto',
- u'version': u"version not set"
- },
- u'schemes': [u"http", u"https"],
- u'consumes': [u"application/json"],
- u'produces': [u"application/json"],
- u'paths': {
- u'/echo': {
- u'get': {
- u'operationId': u'Get',
- u'responses': {
- u'200': {
- u'description': u'',
- u'schema': {
- u'$ref':
- u'#/definitions/google.protobuf.Empty'
- }
- }
- },
- u'tags': [u'TestService']
- }
- }
- },
- u'definitions': {
- u'google.protobuf.Empty': {
- u'description': u'A generic empty message that you can '
- u're-use to avoid defining duplicated\n '
- u'empty messages in your APIs. A typical '
- u'example is to use it as the request\n '
- u'or the response type of an API method. '
- u'For instance:\n\n service Foo {\n '
- u' rpc Bar(google.protobuf.Empty) '
- u'returns (google.protobuf.Empty);\n '
- u'}\n\n The JSON representation for '
- u'`Empty` is empty JSON object `{}`.',
- u'type': u'object'
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger), expected_swagger)
-
-
- def test_nested_type_definitions(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- import "google/protobuf/empty.proto";
- message Null {}
- message Outer {
- message Inner {
- message Innermost {
- bool healthy = 1;
- string illness = 2;
- }
- Innermost innermost = 1;
- string other = 2;
- }
- string name = 1;
- Inner inner = 2;
- }
- service TestService {
- rpc Get(Null) returns(Outer) {
- option (google.api.http) = {
- get: "/test"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.Outer': {
- u'type': u'object',
- u'properties': {
- u'inner': {
- u'$ref': u'#/definitions/test.Outer.Inner'
- },
- u'name': {
- u'type': u'string',
- u'format': u'string'
- }
- }
- },
- u'test.Outer.Inner': {
- u'type': u'object',
- u'properties': {
- u'innermost': {
- u'$ref': u'#/definitions/test.Outer.Inner.Innermost'
- },
- u'other': {
- u'type': u'string',
- u'format': u'string'
- }
- }
- },
- u'test.Outer.Inner.Innermost': {
- u'type': u'object',
- u'properties': {
- u'healthy': {
- u'type': u'boolean',
- u'format': u'boolean'
- },
- u'illness': {
- u'type': u'string',
- u'format': u'string'
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_enum(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {};
- // Detailed weather state
- enum WeatherState {
- GOOD = 0; // Weather is good
- BAD = 1; // Weather is bad
- }
- message Forecast {
- WeatherState forecast = 1;
- }
- service ForecastService {
- rpc GetForecast(Null) returns(Forecast) {
- option (google.api.http) = {
- get: "/forecast"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.WeatherState': {
- u'default': u'GOOD',
- u'description': u'Detailed weather state\n'
- u'Valid values:\n'
- u' - GOOD: Weather is good\n'
- u' - BAD: Weather is bad',
- u'type': u'string',
- u'enum': [u'GOOD', u'BAD']
- },
- u'test.Forecast': {
- u'type': u'object',
- u'properties': {
- u'forecast': {u'$ref': u'#/definitions/test.WeatherState'}
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_nested_enum(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {};
- message Forecast {
- // Detailed weather state
- enum WeatherState {
- GOOD = 0; // Weather is good
- BAD = 1; // Weather is bad
- }
- WeatherState forecast = 1;
- }
- service ForecastService {
- rpc GetForecast(Null) returns(Forecast) {
- option (google.api.http) = {
- get: "/forecast"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.Forecast.WeatherState': {
- u'default': u'GOOD',
- u'description': u'Detailed weather state\n'
- u'Valid values:\n'
- u' - GOOD: Weather is good\n'
- u' - BAD: Weather is bad',
- u'type': u'string',
- u'enum': [u'GOOD', u'BAD']
- },
- u'test.Forecast': {
- u'type': u'object',
- u'properties': {
- u'forecast': {
- u'$ref': u'#/definitions/test.Forecast.WeatherState'}
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_array_of_simple_types(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {};
- message Invitations {
- string event = 1;
- repeated string names = 2;
- repeated int32 ages = 3;
- }
- service RsvpService {
- rpc Get(Null) returns(Invitations) {
- option (google.api.http) = {
- get: "/invitations"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.Invitations': {
- u'type': u'object',
- u'properties': {
- u'event': {
- u'type': u'string',
- u'format': u'string'
- },
- u'names': {
- u'type': u'array',
- u'items': {
- u'type': u'string',
- u'format': u'string'
- }
- },
- u'ages': {
- u'type': u'array',
- u'items': {
- u'type': u'integer',
- u'format': u'int32'
- }
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_array_of_object_type(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {};
- message Invitations {
- message Address {
- string street = 1;
- string city = 2;
- }
- string event = 1;
- repeated Null nulles = 2;
- repeated Address addresses = 3;
- }
- service RsvpService {
- rpc Get(Null) returns(Invitations) {
- option (google.api.http) = {
- get: "/invitations"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.Invitations.Address': {
- u'type': u'object',
- u'properties': {
- u'street': {
- u'type': u'string',
- u'format': u'string'
- },
- u'city': {
- u'type': u'string',
- u'format': u'string'
- }
- }
- },
- u'test.Invitations': {
- u'type': u'object',
- u'properties': {
- u'event': {
- u'type': u'string',
- u'format': u'string'
- },
- u'nulles': {
- u'type': u'array',
- u'items': {
- u'$ref': u'#/definitions/test.Null'
- }
- },
- u'addresses': {
- u'type': u'array',
- u'items': {
- u'$ref': u'#/definitions/test.Invitations.Address'
- }
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_recursively_nested_values(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {};
- message TreeNode {
- string name = 1;
- repeated TreeNode children = 2;
- }
- service RsvpService {
- rpc Get(Null) returns(TreeNode) {
- option (google.api.http) = {
- get: "/invitations"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.TreeNode': {
- u'type': u'object',
- u'properties': {
- u'name': {
- u'type': u'string',
- u'format': u'string'
- },
- u'children': {
- u'type': u'array',
- u'items': {
- u'$ref': u'#/definitions/test.TreeNode'
- }
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_map_fields(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {};
- message Maps {
- map<string, string> string_map = 1;
- map<string, int32> int32_map = 2;
- map<string, Null> object_map = 3;
- }
- service RsvpService {
- rpc Get(Null) returns(Maps) {
- option (google.api.http) = {
- get: "/maps"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.Maps': {
- u'type': u'object',
- u'properties': {
- u'string_map': {
- u'type': u'object',
- u'additionalProperties': {
- u'type': u'string',
- u'format': u'string'
- }
- },
- u'int32_map': {
- u'type': u'object',
- u'additionalProperties': {
- u'type': u'integer',
- u'format': u'int32'
- }
- },
- u'object_map': {
- u'type': u'object',
- u'additionalProperties': {
- u'$ref': u'#/definitions/test.Null',
- }
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_array_and_map_of_enum(self):
-
- proto = unindent("""
- syntax = "proto3";
- package test;
- import "google/api/annotations.proto";
- message Null {};
- enum State {
- GOOD = 0;
- BAD = 1;
- }
- message Map {
- map<string, State> enum_map = 1;
- repeated State states = 2;
- }
- service RsvpService {
- rpc Get(Null) returns(Map) {
- option (google.api.http) = {
- get: "/maps"
- };
- }
- }
- """)
-
- expected_swagger_definitions = {
- u'test.Null': {u'type': u'object'},
- u'test.State': {
- u'default': u'GOOD',
- u'description': u'State\n'
- u'Valid values:\n'
- u' - GOOD\n'
- u' - BAD',
- u'type': u'string',
- u'enum': [u'GOOD', u'BAD']
- },
- u'test.Map': {
- u'type': u'object',
- u'properties': {
- u'enum_map': {
- u'type': u'object',
- u'additionalProperties': {
- u'$ref': u'#/definitions/test.State',
- }
- },
- u'states': {
- u'type': u'array',
- u'items': {
- u'$ref': u'#/definitions/test.State'
- }
- }
- }
- }
- }
-
- swagger = self.gen_swagger(proto)
- self.assertEqual(json_rt(swagger['definitions']),
- expected_swagger_definitions)
-
- def test_kitchen_sink(self):
-
- proto = load_file(
- os.path.dirname(__file__) + '/a_bit_of_everything.proto')
-
- swagger = self.gen_swagger(proto)
-
- expected_swagger = json.loads(load_file(
- os.path.dirname(__file__) + '/a_bit_of_everything.swagger.json')
- )
-
- self.maxDiff = 100000
- self.assertEqual(json_rt(swagger), expected_swagger)
diff --git a/tests/utests/chameleon/protoc_plugins/test_utils.py b/tests/utests/chameleon/protoc_plugins/test_utils.py
deleted file mode 100644
index 6b59f1e..0000000
--- a/tests/utests/chameleon/protoc_plugins/test_utils.py
+++ /dev/null
@@ -1,110 +0,0 @@
-#
-# Copyright 2016 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-import base64
-import json
-import os
-import sys
-from commands import getstatusoutput
-from google.protobuf.compiler.plugin_pb2 import CodeGeneratorRequest
-
-from chameleon.protoc_plugins.swagger_template import \
- ProtobufCompilationFailedError
-from chameleon.protos import third_party
-
-this_dir = os.path.abspath(os.path.dirname(__file__))
-third_party_dir = os.path.dirname(third_party.__file__)
-
-
-def unindent(str):
- """eat leading space in front of lines based on the smallest one"""
- min_leading_spaces = len(str)
- lines = str.splitlines()
- for line in lines:
- if line:
- min_leading_spaces = min(len(line) - len(line.lstrip(' ')),
- min_leading_spaces)
- return '\n'.join(l[min_leading_spaces:] for l in lines)
-
-
-def mkdir(path):
- """equivalent of command line mkdir -p <path>"""
- if os.path.exists(path):
- assert os.path.isdir(path)
- return
- head, tail = os.path.split(os.path.abspath(path))
- if not os.path.exists(head):
- mkdir(path)
- assert os.path.isdir(head)
- os.mkdir(path)
-
-
-def save_file(path, content, mode=0644):
- """save content into file of path"""
- with file(path, 'w') as f:
- f.write(content)
- os.chmod(path, mode)
-
-
-def load_file(path, read_mode='r'):
- """load content from file of path"""
- with file(path, read_mode) as f:
- content = f.read()
- return content
-
-
-def generate_plugin_request(proto):
- """save proto file and run protoc to generate a plugin request protobuf"""
-
- workdir = '/tmp/chameleon_tests'
-
- mkdir(workdir)
- save_file(os.path.join(workdir, 'test.proto'), proto)
- cmd = (
- 'cd {this_dir} && '
- 'env PATH={extended_path} '
- 'python -m grpc.tools.protoc '
- '-I{workdir} '
- '-I{third_party_dir} '
- '-I{this_dir} '
- '--plugin=protoc-gen-null=null_plugin.py '
- '--null_out={workdir} '
- '{workdir}/test.proto'
- .format(
- extended_path=os.path.dirname(sys.executable),
- python=sys.executable,
- this_dir=this_dir,
- workdir=workdir,
- third_party_dir=third_party_dir
- ))
-
- code, output = getstatusoutput(cmd)
- if code != 0:
- raise ProtobufCompilationFailedError(output)
-
- content = base64.decodestring(
- load_file(os.path.join(workdir, 'protoc.request'), 'rb'))
- request = CodeGeneratorRequest()
- request.ParseFromString(content)
-
- return request
-
-
-def json_rt(data):
- """
- JSON round-trip is to simply get rid of OrderedDict, to allow cleaner
- testing.
- """
- return json.loads(json.dumps(data))
diff --git a/vagrant-base/Makefile b/vagrant-base/Makefile
index b0c7f65..3751b2a 100644
--- a/vagrant-base/Makefile
+++ b/vagrant-base/Makefile
@@ -23,7 +23,7 @@
PROTOC := $(PROTOC_PREFIX)/bin/protoc
-PROTOC_VERSION := "3.0.2"
+PROTOC_VERSION := "3.3.0"
PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
PROTOC_DIR := protobuf-$(PROTOC_VERSION)
PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
diff --git a/voltha/adapters/asfvolt16_olt/protos/Makefile b/voltha/adapters/asfvolt16_olt/protos/Makefile
index 4d81e8b..62eacc8 100644
--- a/voltha/adapters/asfvolt16_olt/protos/Makefile
+++ b/voltha/adapters/asfvolt16_olt/protos/Makefile
@@ -31,7 +31,7 @@
PROTOC := $(PROTOC_PREFIX)/bin/protoc
-PROTOC_VERSION := "3.0.2"
+PROTOC_VERSION := "3.3.0"
PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
PROTOC_DIR := protobuf-$(PROTOC_VERSION)
PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
diff --git a/voltha/protos/Makefile b/voltha/protos/Makefile
index e2c4af7..6391517 100644
--- a/voltha/protos/Makefile
+++ b/voltha/protos/Makefile
@@ -20,24 +20,44 @@
$(error To get started, please source the env.sh file from Voltha top level directory)
endif
-default: build
+default: third_party build
-PROTO_FILES := $(wildcard *.proto) $(wildcard third_party/google/api/*proto)
+PROTO_FILES := $(wildcard *.proto)
+PROTO_GOOGLE_API := $(wildcard third_party/google/api/*.proto)
+PROTO_ALL_FILES := $(PROTO_FILES) $(PROTO_GOOGLE_API)
PROTO_PB2_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,_pb2.py,$(f)))
-PROTO_DESC_FILES := $(foreach f,$(PROTO_FILES),$(subst .proto,.desc,$(f)))
+PROTO_PB2_GOOGLE_API := $(foreach f,$(PROTO_GOOGLE_API),$(subst .proto,_pb2.py,$(f)))
+PROTO_All_PB2_C_FILES := $(foreach f,$(PROTO_ALL_FILES),$(subst .proto,_pb2.pyc,$(f)))
+PROTO_ALL_PB2_GPRC_FILES := $(foreach f,$(PROTO_ALL_FILES),$(subst .proto,_pb2_grpc.py,$(f)))
+PROTO_ALL_DESC_FILES := $(foreach f,$(PROTO_ALL_FILES),$(subst .proto,.desc,$(f)))
PROTOC_PREFIX := /usr/local
PROTOC_LIBDIR := $(PROTOC_PREFIX)/lib
PROTOC := $(PROTOC_PREFIX)/bin/protoc
-PROTOC_VERSION := "3.0.2"
+PROTOC_VERSION := "3.3.0"
PROTOC_DOWNLOAD_PREFIX := "https://github.com/google/protobuf/releases/download"
PROTOC_DIR := protobuf-$(PROTOC_VERSION)
PROTOC_TARBALL := protobuf-python-$(PROTOC_VERSION).tar.gz
PROTOC_DOWNLOAD_URI := $(PROTOC_DOWNLOAD_PREFIX)/v$(PROTOC_VERSION)/$(PROTOC_TARBALL)
PROTOC_BUILD_TMP_DIR := "/tmp/protobuf-build-$(shell uname -s | tr '[:upper:]' '[:lower:]')"
+# Google API needs to be built from within the third party directory
+#
+third_party: google_api
+google_api:
+ @echo "Building protocol buffer artifacts from third_party google api"
+ cd third_party ; \
+ env LD_LIBRARY_PATH=$(PROTOC_LIBDIR) python -m grpc.tools.protoc \
+ -I. \
+ --python_out=. \
+ --grpc_python_out=. \
+ --descriptor_set_out=google/api/annotations.desc \
+ --include_imports \
+ --include_source_info \
+ google/api/annotations.proto google/api/http.proto
+
build: $(PROTOC) $(PROTO_PB2_FILES)
%_pb2.py: %.proto Makefile
@@ -53,7 +73,11 @@
$<
clean:
- rm -f $(PROTO_PB2_FILES) $(PROTO_DESC_FILES)
+ rm -f $(PROTO_PB2_FILES) \
+ $(PROTO_ALL_DESC_FILES) \
+ $(PROTO_ALL_PB2_GPRC_FILES) \
+ $(PROTO_All_PB2_C_FILES) \
+ $(PROTO_PB2_GOOGLE_API)
$(PROTOC):
@echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"