Skip to content

Commit

Permalink
temp : Try moving trace test to some other test
Browse files Browse the repository at this point in the history
Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Mar 7, 2024
1 parent 72ace90 commit 6f430d7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
/**
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.integrationtests.springboot.complete;
package org.eclipse.jkube.integrationtests.quarkus.rest;

import io.fabric8.openshift.api.model.ImageStream;
import org.apache.maven.shared.invoker.InvocationResult;
import org.eclipse.jkube.integrationtests.OpenShiftCase;
import org.eclipse.jkube.integrationtests.maven.MavenInvocationResult;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
Expand All @@ -29,12 +13,10 @@

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

import static org.eclipse.jkube.integrationtests.Locks.CLUSTER_RESOURCE_INTENSIVE;
import static org.eclipse.jkube.integrationtests.Tags.OPEN_SHIFT;
import static org.eclipse.jkube.integrationtests.Tags.OPEN_SHIFT_OSCI;
import static org.eclipse.jkube.integrationtests.assertions.InvocationResultAssertion.assertInvocation;
import static org.eclipse.jkube.integrationtests.assertions.JKubeAssertions.assertJKube;
import static org.eclipse.jkube.integrationtests.assertions.KubernetesListAssertion.assertListResource;
Expand All @@ -45,26 +27,12 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.junit.jupiter.api.parallel.ResourceAccessMode.READ_WRITE;

@Tag(OPEN_SHIFT)
@Tag(OPEN_SHIFT_OSCI)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class CompleteOcBuildTraceEnabledITCase extends Complete implements OpenShiftCase {
@BeforeEach
void setUp() {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "trace");
}

@AfterEach
void tearDown() {
System.clearProperty("org.slf4j.simpleLogger.defaultLogLevel");
}

@Override
public List<String> getProfiles() {
return Collections.singletonList("OpenShift-Standard");
}
class QuarkusOcBuildTraceEnabledITCase extends Quarkus implements OpenShiftCase {

@Test
@Order(1)
Expand All @@ -87,6 +55,7 @@ void ocBuild() throws Exception {
final ImageStream is = getOpenShiftClient().imageStreams().withName(getApplication()).get();
assertThat(is, notNullValue());
assertThat(is.getStatus().getTags().iterator().next().getTag(), equalTo("latest"));
assertThat(getOpenShiftClient().imageStreams().withName(getApplication()).get(), notNullValue());
}

@Test
Expand All @@ -101,8 +70,8 @@ void ocResource() throws Exception {
String.format("../%s/target/classes/META-INF", getProject()));
assertThat(metaInfDirectory.exists(), equalTo(true));
assertListResource(new File(metaInfDirectory, "jkube/openshift.yml"));
assertThat(new File(metaInfDirectory, "jkube/openshift/spring-boot-complete-deploymentconfig.yml"), yaml(not(anEmptyMap())));
assertThat(new File(metaInfDirectory, "jkube/openshift/spring-boot-complete-service.yml"), yaml(not(anEmptyMap())));
assertThat(new File(metaInfDirectory, "jkube/openshift/quarkus-rest-deploymentconfig.yml"), yaml(not(anEmptyMap())));
assertThat(new File(metaInfDirectory, "jkube/openshift/quarkus-rest-service.yml"), yaml(not(anEmptyMap())));
}

@Test
Expand All @@ -112,39 +81,40 @@ void ocResource() throws Exception {
void ocApply() throws Exception {
// Given
ByteArrayOutputStream baos = new ByteArrayOutputStream();
assertThat(getOpenShiftClient().imageStreams().withName(getApplication()).get(), notNullValue());
// assertThat(getOpenShiftClient().imageStreams().withName(getApplication()).get(), notNullValue());
// When
final InvocationResult invocationResult = maven("oc:apply",
properties("org.slf4j.simpleLogger.defaultLogLevel", "trace"), baos);
properties("org.slf4j.simpleLogger.defaultLogLevel", "trace")
, baos);
// Then
String ocApplyLog = baos.toString();
assertThat(ocApplyLog, containsString("[TRACE] -HTTP START-"));
assertThat(ocApplyLog, containsString("[TRACE] -HTTP END-"));
assertInvocation(invocationResult);
assertThatShouldApplyResources();
// assertThatShouldApplyResources();
}

@Test
@Order(3)
@DisplayName("oc:log, with org.slf4j.simpleLogger.defaultLogLevel=trace, should retrieve log and print trace logs")
void ocLog() throws Exception {
// Given
Properties properties = new Properties();
properties.put("org.slf4j.simpleLogger.defaultLogLevel", "trace");
properties.put("jkube.log.follow", "false");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// When
final MavenInvocationResult invocationResult = maven("oc:log", properties, baos);
// Then
String ocLogGoalLog = baos.toString();
assertThat(ocLogGoalLog, containsString("[TRACE] -HTTP START-"));
assertThat(ocLogGoalLog, containsString("[TRACE] -HTTP END-"));
assertThat(ocLogGoalLog, containsString("[TRACE] -WS START-"));
assertThat(ocLogGoalLog, containsString("[TRACE] -WS END-"));
assertInvocation(invocationResult);
assertThat(invocationResult.getStdOut(),
stringContainsInOrder("Tomcat started on port(s)", "Started CompleteApplication in", "seconds"));
}
// @Test
// @Order(3)
// @DisplayName("oc:log, with org.slf4j.simpleLogger.defaultLogLevel=trace, should retrieve log and print trace logs")
// void ocLog() throws Exception {
// // Given
// Properties properties = new Properties();
// properties.put("org.slf4j.simpleLogger.defaultLogLevel", "trace");
// properties.put("jkube.log.follow", "false");
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// // When
// final MavenInvocationResult invocationResult = maven("oc:log", properties, baos);
// // Then
// String ocLogGoalLog = baos.toString();
// assertThat(ocLogGoalLog, containsString("[TRACE] -HTTP START-"));
// assertThat(ocLogGoalLog, containsString("[TRACE] -HTTP END-"));
// assertThat(ocLogGoalLog, containsString("[TRACE] -WS START-"));
// assertThat(ocLogGoalLog, containsString("[TRACE] -WS END-"));
// assertInvocation(invocationResult);
// assertThat(invocationResult.getStdOut(),
// stringContainsInOrder("Tomcat started on port(s)", "Started ZeroConfigApplication in", "seconds"));
// }

@Test
@Order(4)
Expand Down
27 changes: 0 additions & 27 deletions projects-to-be-tested/maven/spring/complete/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,33 +184,6 @@
</plugins>
</build>
</profile>
<profile>
<id>OpenShift-Standard</id>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<configuration>
<resources>
<labels>
<all>
<jkube.spring-boot.example>complete</jkube.spring-boot.example>
</all>
</labels>
</resources>
<enricher>
<config>
<jkube-service>
<type>NodePort</type>
</jkube-service>
</config>
</enricher>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>OpenShift-Docker</id>
<properties>
Expand Down

0 comments on commit 6f430d7

Please sign in to comment.