Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azorej committed Apr 23, 2024
1 parent e160db8 commit d0ca463
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@

import io.micronaut.context.annotation.EachProperty;
import io.micronaut.context.annotation.Parameter;

import java.util.Objects;
import java.util.Optional;

/**
* Encapsulates the configuration that is specific to Kubernetes. This is meant for the
* WorkerConfigsProvider to be reading configs, not for direct use as merge logic isn't
* implemented here.
* Important: we cannot distinguish between empty and non-existent environment variables
* in this context, so we treat empty and non-existing strings as the same for our update
* logic. We use the <EMPTY> literal to represent an empty string.
* WorkerConfigsProvider to be reading configs, not for direct use as merge logic isn't implemented
* here. Important: we cannot distinguish between empty and non-existent environment variables in
* this context, so we treat empty and non-existing strings as the same for our update logic. We use
* the "&lt;EMPTY&gt;" literal to represent an empty string.
*/
@EachProperty("airbyte.worker.kube-job-configs")
public final class KubeResourceConfig implements Cloneable {

public static final String EMPTY_VALUE = "<EMPTY>";

private final String name;
Expand Down Expand Up @@ -124,4 +123,5 @@ private static String resolveEmpty(final String value) {
// Let's no return null values as it can be ambiguous
return (Objects.equals(value, EMPTY_VALUE)) ? "" : Optional.ofNullable(value).orElse("");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package io.airbyte.commons.workers.config;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import io.airbyte.commons.workers.config.WorkerConfigsProvider.ResourceType;
import io.airbyte.config.ResourceRequirements;
Expand Down Expand Up @@ -59,7 +58,7 @@ void verifyTestConfigIsLoaded() {
@Test
void testKubeConfigIsReadingAllTheFields() {
assertEquals("check", checkKubeResourceConfig.getName());
assertEquals("check annotations", checkKubeResourceConfig.getAnnotations());
assertEquals("check_annotation_key=check_annotation_value", checkKubeResourceConfig.getAnnotations());
assertEquals("check labels", checkKubeResourceConfig.getLabels());
assertEquals("check node-selectors", checkKubeResourceConfig.getNodeSelectors());
assertEquals("check cpu limit", checkKubeResourceConfig.getCpuLimit());
Expand All @@ -71,11 +70,11 @@ void testKubeConfigIsReadingAllTheFields() {
@Test
void testDefaultFieldBehavior() {
assertEquals("spec", specKubeResourceConfig.getName());
assertEquals("spec annotations", specKubeResourceConfig.getAnnotations());
assertEquals("", specKubeResourceConfig.getAnnotations());
assertEquals("spec labels", specKubeResourceConfig.getLabels());
assertEquals("spec node selectors", specKubeResourceConfig.getNodeSelectors());
assertNull(specKubeResourceConfig.getCpuLimit());
assertNull(specKubeResourceConfig.getCpuRequest());
assertEquals("", specKubeResourceConfig.getCpuLimit());
assertEquals("", specKubeResourceConfig.getCpuRequest());
assertEquals("spec memory limit", specKubeResourceConfig.getMemoryLimit());
assertEquals("", specKubeResourceConfig.getMemoryRequest());
}
Expand Down

0 comments on commit d0ca463

Please sign in to comment.