Skip to content

Commit

Permalink
Added snappy compression and made all tests run in Docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
MagielBruntink committed Dec 6, 2021
1 parent 52886ae commit dadd63f
Show file tree
Hide file tree
Showing 18 changed files with 113 additions and 75 deletions.
21 changes: 19 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Copyright 2021 Software Improvement Group
#
# 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 python:3.9-slim-buster
FROM python:3.9-slim-bullseye
########################################################################################
LABEL maintainer="Software Improvement Group Research <[email protected]>"

Expand All @@ -9,14 +24,16 @@ RUN apt-get update \
&& apt-get install -y -qq \
git \
subversion \
mercurial
mercurial \
libsnappy-dev

RUN git config --global user.email "[email protected]" \
&& git config --global user.name "Software Improvement Group Research"

WORKDIR /plugin

COPY rapidplugin rapidplugin/
COPY integration_tests/*.py integration_tests/
COPY entrypoint.py .
COPY setup.py .
COPY requirements.txt .
Expand Down
36 changes: 22 additions & 14 deletions integration_tests/kafka-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,35 +16,43 @@
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
image: zookeeper:3.7.0

kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
depends_on:
- zookeeper
image: wurstmeister/kafka:2.13-2.7.1
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_MESSAGE_MAX_BYTES: 2097152000
KAFKA_LISTENERS: INSIDE://kafka:29092,OUTSIDE://kafka:9092
KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:29092,OUTSIDE://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_LISTENERS: INSIDE://kafka:9092
KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_CREATE_TOPICS: "fasten.MetadataDBJavaExtension.out:1:1,fasten.RapidPlugin.callable.out:1:1,fasten.RapidPlugin.callable.err:1:1,fasten.RapidPlugin.callable.log:1:1"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
KAFKA_COMPRESSION_TYPE: snappy

rapidplugin:
depends_on:
- kafka
image: rapidplugin-test
entrypoint: ['python', '/plugin/entrypoint.py', '--group_id=RapidPlugin-TEST', '--bootstrap_servers=kafka:9092', '--sources_dir=/plugin/rapidplugin/tests/resources']

rapidplugin-unit-tests:
image: rapidplugin-test
entrypoint: ['python', '-m', 'pytest', 'rapidplugin/tests']

rapidplugin-integration-tests:
image: rapidplugin-test
entrypoint: ['python', '/plugin/entrypoint.py', '--group_id=RapidPlugin-TEST', '--bootstrap_servers=kafka:29092', '--sources_dir=/plugin/rapidplugin/tests/resources']
entrypoint: ['python', '-m', 'pytest', 'integration_tests']

wait-for-kafka:
image: waisbrot/wait
links:
- kafka
environment:
- TARGETS=kafka:29092
- TARGETS=kafka:9092

networks:
default:
Expand Down
4 changes: 2 additions & 2 deletions entrypoint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,7 @@

plugin_name = 'RapidPlugin'
plugin_description = 'A FASTEN plug-in to populate risk related metadata for a product.'
plugin_version = '1.2.0'
plugin_version = '1.2.1'


def get_args_parser():
Expand Down
35 changes: 0 additions & 35 deletions integration_tests/README.md

This file was deleted.

8 changes: 4 additions & 4 deletions integration_tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

@pytest.fixture()
def mock_in():
mock = MockProducer('localhost:9092',
mock = MockProducer('kafka:9092',
'fasten.MetadataDBJavaExtension.out')
yield mock
mock.free_resource()
Expand All @@ -30,7 +30,7 @@ def mock_in():
@pytest.fixture()
def mock_out():
mock = MockConsumer('MockConsumerOut',
'localhost:9092',
'kafka:9092',
'fasten.RapidPlugin.callable.out')
mock.skip_messages()
yield mock
Expand All @@ -40,7 +40,7 @@ def mock_out():
@pytest.fixture()
def mock_log():
mock = MockConsumer('MockConsumerLog',
'localhost:9092',
'kafka:9092',
'fasten.RapidPlugin.log')
mock.skip_messages()
yield mock
Expand All @@ -50,7 +50,7 @@ def mock_log():
@pytest.fixture()
def mock_err():
mock = MockConsumer('MockConsumerErr',
'localhost:9092',
'kafka:9092',
'fasten.RapidPlugin.err')
mock.skip_messages()
yield mock
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/analysis/graph_query.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/analysis/lizard_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/domain/callgraph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/domain/package.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/rapid_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
15 changes: 15 additions & 0 deletions rapidplugin/tests/sources.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Copyright 2021 Software Improvement Group
#
# 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 os
import shutil
import pytest
Expand Down
3 changes: 1 addition & 2 deletions rapidplugin/tests/test_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/tests/test_package.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion rapidplugin/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Software Improvement Group
# Copyright 2021 Software Improvement Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
23 changes: 21 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2021 Software Improvement Group
#
# 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 os import path
from setuptools import setup, find_packages

Expand All @@ -8,7 +24,7 @@

setup(
name='quality-analyzer',
version='1.2.0',
version='1.2.1',
description='FASTEN RAPID Plugin',
long_description=long_description,
long_description_content_type='text/markdown',
Expand All @@ -26,6 +42,9 @@
'lizard',
'requests',
'gitpython',
'svn'
'svn',
'svn',
'kafka-python==2.0.2',
'python-snappy'
]
)
25 changes: 20 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Copyright 2021 Software Improvement Group
#
# 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.
#

[tox]
envlist = py39

Expand All @@ -14,10 +29,10 @@ commands =
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
docker build -t rapidplugin-test .
docker run --rm --entrypoint python rapidplugin-test -m pytest rapidplugin/tests
docker-compose -f integration_tests/kafka-compose.yml up -d
docker-compose -f integration_tests/kafka-compose.yml run wait-for-kafka
pytest integration_tests
docker-compose run rapidplugin-unit-tests
docker-compose up -d rapidplugin
docker-compose run wait-for-kafka
docker-compose run rapidplugin-integration-tests

commands_post =
docker-compose -f integration_tests/kafka-compose.yml down
docker-compose down

0 comments on commit dadd63f

Please sign in to comment.