Skip to content

Commit

Permalink
Check chaos mesh namespace instead of minikube status
Browse files Browse the repository at this point in the history
  • Loading branch information
ikhoon committed Dec 6, 2023
1 parent 0929dac commit 2a5628b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.condition.EnabledIf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -59,7 +60,7 @@

@KubernetesTest
@LoadKubernetesManifests({ "checker-infra.yaml", "control-infra.yaml" })
@EnableIfMinikubeIsRunning
@EnabledIf("com.linecorp.armeria.kubernetes.it.ChaosMeshAvailableCondition#isRunning")
class ChaosIT {

// Forked from https://github.com/fabric8io/kubernetes-client/blob/56a6c2c4f336cc6f64c19029a55c2d3d0289344f/chaos-tests/src/test/java/ChaosIT.java#L42-L42
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2023 LINE Corporation
*
* LINE Corporation 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:
*
* 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 com.linecorp.armeria.kubernetes.it;

import static org.assertj.core.api.Assertions.assertThat;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.linecorp.armeria.client.kubernetes.ArmeriaHttpClient;

import io.fabric8.kubernetes.api.model.Namespace;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;

final class ChaosMeshAvailableCondition {

private static final Logger logger = LoggerFactory.getLogger(ChaosMeshAvailableCondition.class);

static boolean isRunning() {
try (KubernetesClient client = new KubernetesClientBuilder().build()) {
assertThat(client.getHttpClient()).isInstanceOf(ArmeriaHttpClient.class);
final Namespace namespace = client.namespaces().withName("chaos-mesh").get();
return "Active".equals(namespace.getStatus().getPhase());
} catch (Exception cause) {
logger.trace("Chaos Mesh is not running in Kubernetes", cause);
return false;
}
}

private ChaosMeshAvailableCondition() {}
}

This file was deleted.

This file was deleted.

0 comments on commit 2a5628b

Please sign in to comment.