Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys committed Jul 8, 2024
1 parent a66477c commit 9cad612
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test-frame-log-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,42 @@ the logs path will then look like this:
```
The tree path will look similarly to above examples, there will be folders for Namespaces matching the specified labels.

### Global log collector
`GlobaLogCollector` is an annotation which can handle collecting logs which user want automatically in case of test failure or before/after failure.

Register GlobalLogCollector handlers and configure

```java
import io.skodjob.testframe.LogCollectorBuilder;
import io.skodjob.testframe.annotations.CollectLogs;
import io.skodjob.testframe.listeners.GlobalLogCollector;
import io.skodjob.testframe.resources.KubeResourceManager;
import org.junit.jupiter.api.Test;

@CollectLogs
class TestClass() {
static {
// Setup global log collector and handlers
GlobalLogCollector.setupGlobalLogCollector(new LogCollectorBuilder()
.withNamespacedResources("sa", "deployment", "configmaps", "secret")
.withClusterWideResources("nodes")
.withKubeClient(KubeResourceManager.getKubeClient())
.withKubeCmdClient(KubeResourceManager.getKubeCmdClient())
.withRootFolderPath("/some-path/path/")
.build());
GlobalLogCollector.addLogCallback(() -> {
GlobalLogCollector.getGlobalLogCollector().collectFromNamespaces("test-namespace", "test-namespace-2");
GlobalLogCollector.getGlobalLogCollector().collectClusterWideResources();
});
}

@Test
void test() {
...
}
}
```

### Specifying additional folder path

In case that you would like to collect the logs to additional sub-directories of your root folder, the `LogCollector` contains
Expand Down

0 comments on commit 9cad612

Please sign in to comment.