Skip to content

Commit c6a772a

Browse files
committed
improve: additional logging to mysql schema e2e test (#2320)
Signed-off-by: Attila Mészáros <[email protected]>
1 parent d27c064 commit c6a772a

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

Diff for: sample-operators/leader-election/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
<dependency>
3434
<groupId>org.apache.logging.log4j</groupId>
3535
<artifactId>log4j-slf4j-impl</artifactId>
36+
<scope>compile</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.apache.logging.log4j</groupId>
40+
<artifactId>log4j-core</artifactId>
41+
<scope>compile</scope>
3642
</dependency>
3743
<dependency>
3844
<groupId>org.takes</groupId>

Diff for: sample-operators/mysql-schema/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
<groupId>org.apache.logging.log4j</groupId>
5454
<artifactId>log4j-slf4j-impl</artifactId>
5555
</dependency>
56+
<dependency>
57+
<groupId>org.apache.logging.log4j</groupId>
58+
<artifactId>log4j-core</artifactId>
59+
<scope>compile</scope>
60+
</dependency>
5661
<dependency>
5762
<groupId>org.junit.jupiter</groupId>
5863
<artifactId>junit-jupiter-api</artifactId>

Diff for: sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/dependent/SchemaDependentResource.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import static io.javaoperatorsdk.operator.sample.dependent.SecretDependentResource.MYSQL_SECRET_USERNAME;
3131
import static java.lang.String.format;
3232

33-
@SchemaConfig(pollPeriod = 700, host = "127.0.0.1",
33+
@SchemaConfig(pollPeriod = 400, host = "127.0.0.1",
3434
port = SchemaDependentResource.LOCAL_PORT,
3535
user = "root", password = "password") // NOSONAR: password is only used locally, example only
3636
@Configured(by = SchemaConfig.class, with = ResourcePollerConfig.class,
@@ -63,7 +63,9 @@ public void configureWith(ResourcePollerConfig config) {
6363

6464
@Override
6565
public Schema desired(MySQLSchema primary, Context<MySQLSchema> context) {
66-
return new Schema(primary.getMetadata().getName(), primary.getSpec().getEncoding());
66+
var desired = new Schema(primary.getMetadata().getName(), primary.getSpec().getEncoding());
67+
log.debug("Desired schema: {}", desired);
68+
return desired;
6769
}
6870

6971
@Override
@@ -72,6 +74,7 @@ public Schema create(Schema target, MySQLSchema mySQLSchema, Context<MySQLSchema
7274
Secret secret = context.getSecondaryResource(Secret.class).orElseThrow();
7375
var username = decode(secret.getData().get(MYSQL_SECRET_USERNAME));
7476
var password = decode(secret.getData().get(MYSQL_SECRET_PASSWORD));
77+
log.debug("Creating schema: {}", target);
7578
return SchemaService.createSchemaAndRelatedUser(
7679
connection,
7780
target.getName(),
@@ -107,8 +110,10 @@ public static String decode(String value) {
107110
@Override
108111
public Set<Schema> fetchResources(MySQLSchema primaryResource) {
109112
try (Connection connection = getConnection()) {
110-
return SchemaService.getSchema(connection, primaryResource.getMetadata().getName())
113+
var schema = SchemaService.getSchema(connection, primaryResource.getMetadata().getName())
111114
.map(Set::of).orElseGet(Collections::emptySet);
115+
log.debug("Fetched schema: {}", schema);
116+
return schema;
112117
} catch (SQLException e) {
113118
throw new RuntimeException("Error while trying read Schema", e);
114119
}

Diff for: sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/schema/Schema.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ public boolean equals(Object o) {
2828
if (o == null || getClass() != o.getClass())
2929
return false;
3030
Schema schema = (Schema) o;
31-
return Objects.equals(name, schema.name) && Objects.equals(characterSet, schema.characterSet);
31+
return Objects.equals(name, schema.name);
3232
}
3333

3434
@Override
3535
public int hashCode() {
3636
return Objects.hash(name, characterSet);
3737
}
38+
39+
@Override
40+
public String toString() {
41+
return "Schema{" +
42+
"name='" + name + '\'' +
43+
", characterSet='" + characterSet + '\'' +
44+
'}';
45+
}
3846
}

Diff for: sample-operators/tomcat-operator/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
<groupId>org.apache.logging.log4j</groupId>
5050
<artifactId>log4j-slf4j-impl</artifactId>
5151
</dependency>
52+
<dependency>
53+
<groupId>org.apache.logging.log4j</groupId>
54+
<artifactId>log4j-core</artifactId>
55+
<scope>compile</scope>
56+
</dependency>
5257
<dependency>
5358
<groupId>org.takes</groupId>
5459
<artifactId>takes</artifactId>

Diff for: sample-operators/webpage/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
<groupId>org.apache.logging.log4j</groupId>
3535
<artifactId>log4j-slf4j-impl</artifactId>
3636
</dependency>
37+
<dependency>
38+
<groupId>org.apache.logging.log4j</groupId>
39+
<artifactId>log4j-core</artifactId>
40+
<scope>compile</scope>
41+
</dependency>
3742
<dependency>
3843
<groupId>org.takes</groupId>
3944
<artifactId>takes</artifactId>

0 commit comments

Comments
 (0)