diff --git a/bite/api/tests.py b/bite/api/tests.py index 1b787c4..611a8c4 100644 --- a/bite/api/tests.py +++ b/bite/api/tests.py @@ -21,7 +21,7 @@ from django.test import TestCase, Client from api.models import Device, WhiteList -class ApiTestCase(TestCase): +class DPSTestCase(TestCase): c = Client() def setUp(self): @@ -29,17 +29,17 @@ class ApiTestCase(TestCase): Device.objects.create(serial='test1234') def test_no_whitelist(self): - response = self.c.post('/api/device/subscribe/', + response = self.c.post('/api/device/provision/', {'serial': 'test12345'}) self.assertEqual(response.status_code, 400) - def test_subscribe_post(self): + def test_provision_post(self): WhiteList.objects.create(serial='test12345') - response = self.c.post('/api/device/subscribe/', + response = self.c.post('/api/device/provision/', {'serial': 'test12345'}) self.assertEqual(response.status_code, 201) - def test_subscribe_get(self): + def test_provision_get(self): response = self.c.get('/api/device/list/') self.assertEqual( response.json()[0]['serial'], 'test1234') diff --git a/bite/api/urls.py b/bite/api/urls.py index cdcae17..543f974 100644 --- a/bite/api/urls.py +++ b/bite/api/urls.py @@ -33,13 +33,13 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.urls import path -from api.views import APISubscribe +from api.views import DPS urlpatterns = [ - path('device/subscribe/', - APISubscribe.as_view({'post': 'create'}), - name='device-subscribe'), + path('device/provision/', + DPS.as_view({'post': 'create'}), + name='device-provision'), path('device/list/', - APISubscribe.as_view({'get': 'list'}), + DPS.as_view({'get': 'list'}), name='device-list'), ] diff --git a/bite/api/views.py b/bite/api/views.py index 4705e69..554d081 100644 --- a/bite/api/views.py +++ b/bite/api/views.py @@ -23,6 +23,6 @@ from api.models import Device from api.serializers import DeviceSerializer -class APISubscribe(ModelViewSet): +class DPS(ModelViewSet): queryset = Device.objects.all() serializer_class = DeviceSerializer diff --git a/bite/bite/settings.py b/bite/bite/settings.py index 8fc4ea3..3d4ce91 100644 --- a/bite/bite/settings.py +++ b/bite/bite/settings.py @@ -167,11 +167,12 @@ KAFKA_BROKER = { 'PORT': '9092', } -# If no local_settings.py is availble in the current folder let's try to -# load it from the application root +try: + from bite.local_settings import * +except ImportError: + pass + try: from bite.production import * except ImportError: - # If a local_setting.py does not exist - # settings in this file only will be used pass diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml index 5bf7abc..7b75d4a 100644 --- a/docker/docker-compose.dev.yml +++ b/docker/docker-compose.dev.yml @@ -37,8 +37,11 @@ services: - "${CUSTOM_DOCKER_IP:-0.0.0.0}:8000:8000" kafka: + environment: + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT ports: - - "${CUSTOM_DOCKER_IP:-0.0.0.0}:9092:9092" + - "${CUSTOM_DOCKER_IP:-0.0.0.0}:29092:29092" data-migration: volumes: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5a74303..3a0d226 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -69,8 +69,6 @@ services: environment: ZOOKEEPER_CLIENT_PORT: 2181 ZOOKEEPER_TICK_TIME: 2000 - ports: - - 22181:2181 kafka: image: confluentinc/cp-kafka:latest @@ -81,8 +79,8 @@ services: environment: KAFKA_BROKER_ID: 1 KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092 - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 diff --git a/docker/simulator/device_simulator.py b/docker/simulator/device_simulator.py index 6ffb1e6..209929f 100755 --- a/docker/simulator/device_simulator.py +++ b/docker/simulator/device_simulator.py @@ -114,7 +114,7 @@ def main(): ) args = parser.parse_args() - subscribe = "/api/device/subscribe/" + dps = "/api/device/provision/" telemetry = "/telemetry/" if args.serial is None: @@ -123,7 +123,7 @@ def main(): ) data = {"serial": args.serial} - post_json(args.endpoint, subscribe, data) + post_json(args.endpoint, dps, data) while True: data = {