-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding E2E for testing gRPC server (#13)
- Loading branch information
Showing
17 changed files
with
537 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2023 SkyAPM org | ||
# | ||
# 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 bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright 2023 SkyAPM org | ||
# | ||
# 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. | ||
""" | ||
Run this file to get a web demo of the URI Drain algorithm. | ||
""" | ||
import sys | ||
|
||
import grpc | ||
import yaml | ||
|
||
from servers.protos.generated.ai_http_uri_recognition_pb2 import HttpUriRecognitionRequest, HttpRawUri | ||
from servers.protos.generated.ai_http_uri_recognition_pb2_grpc import HttpUriRecognitionServiceStub | ||
|
||
mode = sys.argv[1] | ||
service_name = sys.argv[2] | ||
|
||
channel = grpc.insecure_channel('localhost:17128') | ||
stub = HttpUriRecognitionServiceStub(channel) | ||
|
||
|
||
def feed_data(): | ||
file_path = sys.argv[3] | ||
with open(file_path, 'r') as file: | ||
urls = file.readlines() | ||
stub.feedRawData( | ||
HttpUriRecognitionRequest(service=service_name, unrecognizedUris=list(map(lambda x: HttpRawUri(name=x), urls)))) | ||
print("ok") | ||
|
||
|
||
def fetch_data(): | ||
patterns = stub.fetchAllPatterns(HttpUriRecognitionRequest(service=service_name)) | ||
print(yaml.dump(HTTPUriRecognitionResp(sorted([p.pattern for p in patterns.patterns]), patterns.version), Dumper=NoTagDumper)) | ||
|
||
|
||
class HTTPUriRecognitionResp: | ||
|
||
def __init__(self, patterns, version): | ||
self.patterns = patterns | ||
self.version = version | ||
|
||
|
||
class NoTagDumper(yaml.SafeDumper): | ||
def ignore_aliases(self, data): | ||
return True | ||
|
||
|
||
def remove_representer(dumper, data): | ||
return dumper.represent_dict(data.__dict__) | ||
|
||
|
||
yaml.add_representer(HTTPUriRecognitionResp, remove_representer, Dumper=NoTagDumper) | ||
|
||
if __name__ == '__main__': | ||
if mode == 'feed': | ||
feed_data() | ||
elif mode == 'fetch': | ||
fetch_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2023 SkyAPM org | ||
# | ||
# 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. | ||
|
||
version: '2.1' | ||
|
||
services: | ||
r3: | ||
image: r3:latest | ||
ports: | ||
- "17128:17128" | ||
networks: | ||
- e2e | ||
environment: | ||
DRAIN_ANALYSIS_MIN_URL_COUNT: 1 | ||
healthcheck: | ||
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/17128"] | ||
interval: 5s | ||
timeout: 60s | ||
retries: 120 | ||
|
||
networks: | ||
e2e: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2023 SkyAPM org | ||
# | ||
# 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. | ||
|
||
setup: | ||
env: compose | ||
file: docker-compose.yml | ||
timeout: 20m | ||
steps: | ||
- name: set PATH | ||
command: export PATH=/tmp/skywalking-infra-e2e/bin:$PATH | ||
- name: make install | ||
command: make install | ||
- name: install dependency for client.py | ||
command: pip install -r test/e2e/requirements.txt | ||
- name: adding python path | ||
command: export PYTHONPATH=$(pwd) | ||
|
||
verify: | ||
# verify with retry strategy | ||
retry: | ||
# max retry count | ||
count: 20 | ||
# the interval between two retries, in millisecond. | ||
interval: 3s | ||
cases: | ||
- query: python test/e2e/client.py feed test1 demo/Endpoint100_counterexamples.txt && sleep 1 | ||
expected: expected/feed-ok.yaml | ||
- query: python test/e2e/client.py fetch test1 | ||
expected: expected/endpoint_counterexamples.yaml | ||
|
||
- query: python test/e2e/client.py feed test2 demo/Endpoint100_trivial.txt && sleep 1 | ||
expected: expected/feed-ok.yaml | ||
- query: python test/e2e/client.py fetch test2 | ||
expected: expected/endpoint_trivial.yaml | ||
|
||
- query: python test/e2e/client.py feed test3 demo/Endpoint100_trivial_3k_repeat.txt && sleep 1 | ||
expected: expected/feed-ok.yaml | ||
- query: python test/e2e/client.py fetch test3 | ||
expected: expected/endpoint_trivial_3k.yaml | ||
|
||
- query: python test/e2e/client.py feed test4 demo/Endpoint200_hard.txt && sleep 1 | ||
expected: expected/feed-ok.yaml | ||
- query: python test/e2e/client.py fetch test4 | ||
expected: expected/endpoint_hard.yaml | ||
|
||
- query: python test/e2e/client.py feed test5 demo/Endpoint200_hard_3k_repeat.txt && sleep 1 | ||
expected: expected/feed-ok.yaml | ||
- query: python test/e2e/client.py fetch test5 | ||
expected: expected/endpoint_hard_3k.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2023 SkyAPM org | ||
# | ||
# 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. | ||
|
||
patterns: | ||
- "/api/v1/usernames/{var}" | ||
- "/api/v1/users/{var}" | ||
version: "1" |
Oops, something went wrong.