Skip to content

test & logs #391

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<configuration>
<environmentVariables>
<YDB_DOCKER_FEATURE_FLAGS>enable_resource_pools</YDB_DOCKER_FEATURE_FLAGS>
<YDB_DOCKER_IMAGE>ydbplatform/local-ydb:trunk</YDB_DOCKER_IMAGE>
</environmentVariables>
</configuration>
</plugin>
Expand Down
2 changes: 2 additions & 0 deletions query/src/test/java/tech/ydb/query/QueryExampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;

Expand All @@ -32,6 +33,7 @@
* @author Alexandr Gorshenin <[email protected]>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Ignore
public class QueryExampleTest {
@ClassRule
public final static GrpcTransportRule ydbRule = new GrpcTransportRule();
Expand Down
2 changes: 2 additions & 0 deletions query/src/test/java/tech/ydb/query/TableExampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;

Expand Down Expand Up @@ -43,6 +44,7 @@
* @author Alexandr Gorshenin <[email protected]>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Ignore
public class TableExampleTest {
@ClassRule
public final static GrpcTransportRule ydbRule = new GrpcTransportRule();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*
* @author Aleksandr Gorshenin
*/
@Ignore
public class QueryIntegrationTest {
private final static Logger logger = LoggerFactory.getLogger(QueryIntegrationTest.class);
private final static String TEST_TABLE = "query_service_test";
Expand Down
6 changes: 3 additions & 3 deletions query/src/test/java/tech/ydb/query/impl/ResourcePoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -40,7 +39,6 @@
*
* @author Evgeny Kuvardin
*/
@Ignore // Resource pools are unstable now
public class ResourcePoolTest {
private final static Logger logger = LoggerFactory.getLogger(ResourcePoolTest.class);

Expand Down Expand Up @@ -78,6 +76,8 @@ public static void dropAll() {
client.close();
client = null;
}

ydbTransport.printStdErr();
}

private Status selectWithPool(String poolName) {
Expand All @@ -98,7 +98,7 @@ private Status selectWithPool(String poolName) {
private Status createResourcePool(String poolName) {
String createPool = "CREATE RESOURCE POOL " + poolName + " WITH ("
+ "CONCURRENT_QUERY_LIMIT=10,"
+ "QUEUE_SIZE=\"-1\"," // Query size works unstable
+ "QUEUE_SIZE=1000,"
+ "DATABASE_LOAD_CPU_THRESHOLD=80);";
return retryCtx.supplyResult(s -> s.createQuery(createPool, TxMode.NONE).execute()).join().getStatus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public interface YdbHelper extends AutoCloseable {

String authToken();

String getStdErr();

@Override
void close();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tech.ydb.test.integration.docker;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.utility.TestcontainersConfiguration;

import tech.ydb.core.grpc.GrpcTransport;
Expand All @@ -15,6 +17,7 @@
* @author Aleksandr Gorshenin
*/
public class DockerHelperFactory extends YdbHelperFactory {
private static final Logger logger = LoggerFactory.getLogger(DockerHelperFactory.class);
private final YdbEnvironment env;
private final YdbDockerContainer container;

Expand All @@ -30,6 +33,7 @@ public DockerHelperFactory(YdbEnvironment env, YdbDockerContainer container) {

@Override
public YdbHelper createHelper() {
logger.warn("container start");
container.start();

return new YdbHelper() {
Expand Down Expand Up @@ -78,6 +82,11 @@ public void close() {
container.stop();
container.close();
}

@Override
public String getStdErr() {
return container.getLogs();
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public void close() {
container.stop();
container.close();
}

@Override
public String getStdErr() {
return container.getLogs();
}
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void init() {

withEnv("YDB_USE_IN_MEMORY_PDISKS", "true");
withEnv("YDB_ENABLE_COLUMN_TABLES", "true");
withEnv("YDB_DEFAULT_LOG_LEVEL", "DEBUG");

if (env.dockerFeatures() != null && !env.dockerFeatures().isEmpty()) {
withEnv("YDB_FEATURE_FLAGS", env.dockerFeatures());
Expand Down Expand Up @@ -104,6 +105,12 @@ public byte[] pemCert() {
});
}

public void logStdErr() {
String logs = getLogs();
System.out.println(logs);
System.out.println("LOG SIZE = " + logs.length());
}

public String database() {
return env.dockerDatabase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public byte[] pemCert() {
public void close() {
// Nothing
}

@Override
public String getStdErr() {
return "EXTERNAL";
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public String getHost() {

@Override
public <T> T copyFileFromContainer(String containerPath, ThrowingFunction<InputStream, T> function) {
if (!pemPath.equals(containerPath)) {
try (ByteArrayInputStream bais = new ByteArrayInputStream("".getBytes())) {
return function.apply(bais);
} catch (Exception ex) {
throw new AssertionError("mock error", ex);
}
}
Assert.assertEquals("check pem path", pemPath, containerPath);

try (ByteArrayInputStream bais = new ByteArrayInputStream(pemCert)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class GrpcTransportRule extends ProxyGrpcTransport implements TestRule {
private static final Logger logger = LoggerFactory.getLogger(GrpcTransportRule.class);

private final AtomicReference<GrpcTransport> proxy = new AtomicReference<>();
private final AtomicReference<YdbHelper> proxy2 = new AtomicReference<>();

@Override
public Statement apply(Statement base, Description description) {
Expand All @@ -41,14 +42,24 @@ public void evaluate() throws Throwable {
path += "/" + description.getMethodName();
}

logger.debug("create ydb helper for test {}", path);
logger.warn("create ydb helper for test {}", path);
try (YdbHelper helper = factory.createHelper()) {
logger.warn("create ydb transport for test {}", path);
proxy2.set(helper);
try (GrpcTransport transport = helper.createTransport()) {
proxy.set(transport);
base.evaluate();
proxy.set(null);
logger.warn("evaluate test {}", path);
try {
base.evaluate();
} finally {
logger.warn("finish evaluate test {}", path);
proxy.set(null);
}
logger.warn("close ydb transport for test {}", path);
}
logger.warn("close ydb helper for test {}", path);
}
proxy2.set(null);
}
};
}
Expand All @@ -57,4 +68,13 @@ public void evaluate() throws Throwable {
protected GrpcTransport origin() {
return proxy.get();
}

public void printStdErr() {
try {
String output = proxy2.get().getStdErr();
logger.warn("DOCKER OUTPUT: \n{}", output);
} catch (Exception ex) {
logger.error("DOCKER ERROR", ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ public void evaluate() throws Throwable {
protected YdbHelper origin() {
return proxy.get();
}

@Override
public String getStdErr() {
return proxy.get().getStdErr();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public void afterEach(ExtensionContext ec) throws Exception {
holder.after(ec);
}

@Override
public String getStdErr() {
return holder.helper.getStdErr();
}

private static class Holder {
private final Lock holderLock = new ReentrantLock();

Expand Down
Loading