-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fabric8 it part 5 #1470
Merged
Merged
Fabric8 it part 5 #1470
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
a468581
fix
wind57 fd54734
checkstyle
wind57 cfacf31
clean-up
wind57 ec05ccc
clean-up
wind57 8f2f2d9
started work
wind57 8ef893e
clean-up
wind57 3585182
merged
wind57 446eee2
started-work
wind57 d350fdf
merge 3.0.x
wind57 85535c8
merge
wind57 29d9bcb
Merge branch 'fabric8-configmap-event-reload-patch-refactor-part-2' i…
wind57 8c8370e
continue work
wind57 74c03f5
dirty
wind57 752d92e
dirty
wind57 ed96191
fixed
wind57 aef0127
merge 3.0.x
wind57 37a6ee9
fix merge
wind57 bfc418d
rename package
wind57 8680b1e
increase
wind57 a95ad35
fix
wind57 d9f9be0
fix
wind57 1d68777
trigger
wind57 81c0d41
simplify + enable all tests
wind57 d1f42c5
remove overlaping test
wind57 a0cd375
dirty
wind57 4964e36
dirty
wind57 385243a
merge 3.0.x
wind57 00738ea
fix
wind57 30bb51e
Merge branch '3.0.x' into fabric8-it-part-5
wind57 473f69f
format
wind57 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
...java/org/springframework/cloud/kubernetes/fabric8/reload/SecretsEventsReloadDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright 2013-2022 the original author or authors. | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
package org.springframework.cloud.kubernetes.fabric8.reload; | ||
|
||
import java.time.Duration; | ||
import java.util.Base64; | ||
import java.util.Map; | ||
|
||
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; | ||
import io.fabric8.kubernetes.api.model.Secret; | ||
import io.fabric8.kubernetes.api.model.SecretBuilder; | ||
import io.fabric8.kubernetes.client.KubernetesClient; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.testcontainers.k3s.K3sContainer; | ||
|
||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
import static org.awaitility.Awaitility.await; | ||
import static org.springframework.cloud.kubernetes.fabric8.reload.TestUtil.builder; | ||
import static org.springframework.cloud.kubernetes.fabric8.reload.TestUtil.retrySpec; | ||
|
||
/** | ||
* @author wind57 | ||
*/ | ||
final class SecretsEventsReloadDelegate { | ||
|
||
/** | ||
* <pre> | ||
* - secret with no labels and data: from.secret.properties.key = secret-initial exists in namespace default | ||
* - we assert that we can read it correctly first, by invoking localhost/key. | ||
* | ||
* - then we change the secret by adding a label, this in turn does not | ||
* change the result of localhost/key, because the data has not changed. | ||
* | ||
* - then we change data inside the secret, and we must see the updated value. | ||
* </pre> | ||
*/ | ||
static void testSecretReload(KubernetesClient client, K3sContainer container, String appLabelValue) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test was moved from the other module |
||
Commons.assertReloadLogStatements("added secret informer for namespace", | ||
"added configmap informer for namespace", appLabelValue); | ||
|
||
WebClient webClient = builder().baseUrl("http://localhost/key-from-secret").build(); | ||
String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) | ||
.block(); | ||
Assertions.assertEquals("secret-initial", result); | ||
|
||
Secret secret = new SecretBuilder() | ||
.withMetadata(new ObjectMetaBuilder().withLabels(Map.of("letter", "a")).withNamespace("default") | ||
.withName("event-reload").build()) | ||
.withData(Map.of("application.properties", | ||
Base64.getEncoder().encodeToString("from.secret.properties.key=secret-initial".getBytes()))) | ||
.build(); | ||
client.secrets().inNamespace("default").resource(secret).createOrReplace(); | ||
|
||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> { | ||
WebClient innerWebClient = builder().baseUrl("http://localhost/key-from-secret").build(); | ||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) | ||
.retryWhen(retrySpec()).block(); | ||
return "secret-initial".equals(innerResult); | ||
}); | ||
|
||
Commons.waitForLogStatement("Secret event-reload was updated in namespace default", container, appLabelValue); | ||
Commons.waitForLogStatement("data in secret has not changed, will not reload", container, appLabelValue); | ||
|
||
// change data | ||
secret = new SecretBuilder() | ||
.withMetadata(new ObjectMetaBuilder().withNamespace("default").withName("event-reload").build()) | ||
.withData(Map.of("application.properties", | ||
Base64.getEncoder() | ||
.encodeToString("from.secret.properties.key=secret-initial-changed".getBytes()))) | ||
.build(); | ||
|
||
client.secrets().inNamespace("default").resource(secret).createOrReplace(); | ||
|
||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> { | ||
WebClient innerWebClient = builder().baseUrl("http://localhost/key-from-secret").build(); | ||
String innerResult = innerWebClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) | ||
.retryWhen(retrySpec()).block(); | ||
return "secret-initial-changed".equals(innerResult); | ||
}); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have an integration test that deals with reload in fabric8, but only for configmaps. This PR takes the secrets reload tests and moves them to the common place.