From a9d020ecdafe89571fdf42608518c8dd7fc47321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Tue, 26 Mar 2024 16:07:08 +0100 Subject: [PATCH 1/3] improve: additional logging to mysql schema e2e test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- .../sample/dependent/SchemaDependentResource.java | 11 ++++++++--- .../operator/sample/schema/Schema.java | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/dependent/SchemaDependentResource.java b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/dependent/SchemaDependentResource.java index 77d8932e58..476898af00 100644 --- a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/dependent/SchemaDependentResource.java +++ b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/dependent/SchemaDependentResource.java @@ -30,7 +30,7 @@ import static io.javaoperatorsdk.operator.sample.dependent.SecretDependentResource.MYSQL_SECRET_USERNAME; import static java.lang.String.format; -@SchemaConfig(pollPeriod = 700, host = "127.0.0.1", +@SchemaConfig(pollPeriod = 400, host = "127.0.0.1", port = SchemaDependentResource.LOCAL_PORT, user = "root", password = "password") // NOSONAR: password is only used locally, example only @Configured(by = SchemaConfig.class, with = ResourcePollerConfig.class, @@ -63,7 +63,9 @@ public void configureWith(ResourcePollerConfig config) { @Override public Schema desired(MySQLSchema primary, Context context) { - return new Schema(primary.getMetadata().getName(), primary.getSpec().getEncoding()); + var desired = new Schema(primary.getMetadata().getName(), primary.getSpec().getEncoding()); + log.debug("Desired schema: {}", desired); + return desired; } @Override @@ -72,6 +74,7 @@ public Schema create(Schema target, MySQLSchema mySQLSchema, Context fetchResources(MySQLSchema primaryResource) { try (Connection connection = getConnection()) { - return SchemaService.getSchema(connection, primaryResource.getMetadata().getName()) + var schema = SchemaService.getSchema(connection, primaryResource.getMetadata().getName()) .map(Set::of).orElseGet(Collections::emptySet); + log.debug("Fetched schema: {}", schema); + return schema; } catch (SQLException e) { throw new RuntimeException("Error while trying read Schema", e); } diff --git a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java index 34c1e54255..eb408a4684 100644 --- a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java +++ b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java @@ -35,4 +35,12 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(name, characterSet); } + + @Override + public String toString() { + return "Schema{" + + "name='" + name + '\'' + + ", characterSet='" + characterSet + '\'' + + '}'; + } } From e1fd83a36dbbf9a0298535409786990056964477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Wed, 27 Mar 2024 10:57:48 +0100 Subject: [PATCH 2/3] dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- sample-operators/leader-election/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sample-operators/leader-election/pom.xml b/sample-operators/leader-election/pom.xml index 3a1b0a48a3..bcbc4fbcff 100644 --- a/sample-operators/leader-election/pom.xml +++ b/sample-operators/leader-election/pom.xml @@ -33,6 +33,12 @@ org.apache.logging.log4j log4j-slf4j-impl + compile + + + org.apache.logging.log4j + log4j-core + compile org.takes From 84892953aa349fc72976bf59e8454d56c02f7a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20M=C3=A9sz=C3=A1ros?= Date: Wed, 27 Mar 2024 12:43:47 +0100 Subject: [PATCH 3/3] fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Attila Mészáros --- sample-operators/mysql-schema/pom.xml | 5 +++++ .../io/javaoperatorsdk/operator/sample/schema/Schema.java | 2 +- sample-operators/tomcat-operator/pom.xml | 5 +++++ sample-operators/webpage/pom.xml | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sample-operators/mysql-schema/pom.xml b/sample-operators/mysql-schema/pom.xml index 554a937f2c..dedb681116 100644 --- a/sample-operators/mysql-schema/pom.xml +++ b/sample-operators/mysql-schema/pom.xml @@ -53,6 +53,11 @@ org.apache.logging.log4j log4j-slf4j-impl + + org.apache.logging.log4j + log4j-core + compile + org.junit.jupiter junit-jupiter-api diff --git a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java index eb408a4684..87fb88e9a4 100644 --- a/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java +++ b/sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java @@ -28,7 +28,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; Schema schema = (Schema) o; - return Objects.equals(name, schema.name) && Objects.equals(characterSet, schema.characterSet); + return Objects.equals(name, schema.name); } @Override diff --git a/sample-operators/tomcat-operator/pom.xml b/sample-operators/tomcat-operator/pom.xml index 5e04d9c88c..158133160d 100644 --- a/sample-operators/tomcat-operator/pom.xml +++ b/sample-operators/tomcat-operator/pom.xml @@ -49,6 +49,11 @@ org.apache.logging.log4j log4j-slf4j-impl + + org.apache.logging.log4j + log4j-core + compile + org.takes takes diff --git a/sample-operators/webpage/pom.xml b/sample-operators/webpage/pom.xml index ad961b8393..5470ece6d3 100644 --- a/sample-operators/webpage/pom.xml +++ b/sample-operators/webpage/pom.xml @@ -34,6 +34,11 @@ org.apache.logging.log4j log4j-slf4j-impl + + org.apache.logging.log4j + log4j-core + compile + org.takes takes