You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/07/04 18:00:36 UTC

[GitHub] [beam] roger-mike commented on a diff in pull request #22135: BEAM-13004 A load test for DebeziumIO that uses postgress as a database

roger-mike commented on code in PR #22135:
URL: https://github.com/apache/beam/pull/22135#discussion_r913181560


##########
sdks/python/apache_beam/testing/load_tests/debezium_performance.py:
##########
@@ -0,0 +1,159 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+"""
+Performance test for debezium.
+
+The purpose of this test is verify that Python's connector ReadFromDebezium
+work propertly, for this, the test create a postgresql database inside a 
+kubernetes pod and stream querys inside of the database for 20 minutes.
+After that ReadFromDebezium checks if everything goes well
+
+Example test run:
+
+python -m apache_beam.testing.load_tests.debezium_performance
+
+or:
+
+./gradlew
+ -PloadTest.mainClass=apache_beam.testing.load_tests.debezium_performance \
+-Prunner=DirectRunner :sdks:python:apache_beam:testing:load_tests:run
+"""
+
+import psycopg2
+import os
+import time
+import random
+import logging
+
+import apache_beam as beam
+from apache_beam.options.pipeline_options import PipelineOptions
+from apache_beam.testing.load_tests.load_test import LoadTest
+from apache_beam.io.debezium import DriverClassName
+from apache_beam.io.debezium import ReadFromDebezium
+from apache_beam.options.pipeline_options import StandardOptions
+from apache_beam.testing.test_pipeline import TestPipeline
+from apache_beam.testing.util import assert_that
+from apache_beam.testing.util import equal_to
+
+class DebeziumLoadTest(LoadTest, beam.DoFn): 
+    def __init__(self):
+        self.username = 'postgres'
+        self.password = 'uuinkks' 
+        # de kubernetes
+        self.database = 'postgres'
+        self.port = "5432"
+        # Please verify the way to obtain the IP 
+        self.host = os.environ['kubernetesPostgres'] 
+        self.connector_class = DriverClassName.POSTGRESQL
+        self.connection_properties = [
+            "database.dbname=postgres",
+            "database.server.name=postgres",
+            "database.include.list=postgres",
+            "include.schema.changes=false",
+            "plugin.name=pgoutput"
+        ]
+
+    def initConnection(self): 
+        connection = psycopg2.connect(
+            host = self.host,
+            database = self.database,
+            user = self.username,
+            password = self.password
+        )
+        return connection
+    
+    def randomInsertTest(self,connection):

Review Comment:
   Should this function run in a thread?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org