Skip to content
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

Remove MustGather from test-frame #142

Merged
merged 1 commit into from
Jul 16, 2024
Merged
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
37 changes: 0 additions & 37 deletions test-frame-log-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,43 +169,6 @@ 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.

### MustGather
`MustGather` is an annotation which can handle collecting logs which user want automatically in case of test failure or before/after failure.
It gets configuration passed into `MustGatherController` and call collecting in proper callbacks.

Register `MustGatherController` handlers and configure

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

@MustGather
class TestClass() {
static {
// Setup global log collector and handlers
MustGatherController.setupMustGatherController(new LogCollectorBuilder()
.withNamespacedResources("sa", "deployment", "configmaps", "secret")
.withClusterWideResources("nodes")
.withKubeClient(KubeResourceManager.getKubeClient())
.withKubeCmdClient(KubeResourceManager.getKubeCmdClient())
.withRootFolderPath("/some-path/path/")
.build());
MustGatherController.setMustGatherCallback(() -> {
MustGatherController.getMustGatherController().collectFromNamespaces("test-namespace", "test-namespace-2");
MustGatherController.getMustGatherController().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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
*/
package io.skodjob.testframe.test.integration;

import io.skodjob.testframe.LogCollectorBuilder;
import io.skodjob.testframe.annotations.MustGather;
import io.skodjob.testframe.listeners.MustGatherController;
import io.skodjob.testframe.test.integration.helpers.GlobalLogCollectorTestHandler;
import io.skodjob.testframe.utils.LoggerUtils;
import io.skodjob.testframe.annotations.ResourceManager;
import io.skodjob.testframe.annotations.TestVisualSeparator;
Expand All @@ -16,17 +12,14 @@
import io.skodjob.testframe.resources.NamespaceType;
import io.skodjob.testframe.resources.ServiceAccountType;
import io.skodjob.testframe.utils.KubeUtils;
import org.junit.jupiter.api.extension.ExtendWith;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.atomic.AtomicBoolean;

@ExtendWith(GlobalLogCollectorTestHandler.class) // For testing purpose
@ResourceManager
@MustGather
@TestVisualSeparator
public abstract class AbstractIT {
static AtomicBoolean isCreateHandlerCalled = new AtomicBoolean(false);
Expand Down Expand Up @@ -58,19 +51,6 @@ public abstract class AbstractIT {
LoggerUtils.logResource("Deleted", r);
}
});

// Setup global log collector and handlers
MustGatherController.setupMustGatherController(new LogCollectorBuilder()
.withNamespacedResources("sa", "deployment", "configmaps", "secret")
.withClusterWideResources("nodes")
.withKubeClient(KubeResourceManager.getKubeClient())
.withKubeCmdClient(KubeResourceManager.getKubeCmdClient())
.withRootFolderPath(LOG_DIR.toString())
.build());
MustGatherController.setMustGatherCallback(() -> {
MustGatherController.getMustGatherController().collectFromNamespaces("default");
MustGatherController.getMustGatherController().collectClusterWideResources();
});
}

protected String nsName1 = "test";
Expand Down

This file was deleted.

This file was deleted.

Loading