Skip to content

Commit

Permalink
Add very basic README for collector-framework and some tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
nocturnalastro committed Feb 8, 2024
1 parent c2af7a9 commit 3a34397
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 80 deletions.
80 changes: 5 additions & 75 deletions collector-framework/README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,7 @@
# synchronization-testsuites
# Collector framework

The main purpose of this repo is build the necessary tooling to collect necessary synchronization-related data logs from a running OpenShift cluster. This data will then be leveraged by different analysis tools to determine if the cluster is running within acceptable bounds synchronization-wise.```
This is a framework for making it easier for people to build collectors.
It provides a basic framework just create your collector, register it,
then trigger the runner from a entry point of your choice.

The core approach taken is to strongly encourage and enforce separation of concerns between:
1. Declarative description of the cluster(s) under test
1. Configuration of a test (e.g. number of repetitions, acceptable thresholds, etc.)
1. Collectors - methods of collecting indicative information about the cluster
1. Checks - performed on collected values

## Setup

1. [Install Go](https://go.dev/doc/install)
1. Install dependencies with `go mod tidy`

### Development Extras
1. Install dev binaries: `make install-tools`. Ensure your `$GOBIN` is on your `$PATH`
1. yamllint
1. [Install yamllint](https://yamllint.readthedocs.io/en/stable/) with `sudo yum install yamllint`
1. run with `yamllint ./`
1. golangci-lint
1. [Install golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
1. run with `make lint`
1. license-eye
1. [Install license-eye](https://github.com/apache/skywalking-eyes) with `go install github.com/apache/skywalking-eyes/cmd/license-eye@latest`
1. run with `license-eye header check` or `license-eye header fix`
1. pre-commit
1. on RHEL, `pre-commit` requires recompiling python to include optional sqlite modules:
1. `sudo yum install sqlite-devel`
1. See instructions [here](https://tecadmin.net/how-to-install-python-3-10-on-centos-rhel-8-fedora/)
1. install pre-commit with `pip3.10 install pre-commit`
1. configure your repository to run pre-commit hooks with `pre-commit install`
1. manually run against all files with `pre-commit run --all-files` or against staged files with `pre-commit run`.
1. Otherwise pre-commit will now run automatically when you make a new commit.

## Usage
### Building binary
Run the following command to build the binary used in the following commands:
```shell
go build
```
###### NOTE: use the `--race` flag when developing collectors.

### Checking Enviroment
Run the following command (check help string for more details):

```shell
./collector-framework env verify --interface="<ptp interface>" --kubeconfig="${KUBECONFIG}"
```

### Running Collectors

Run the following command (check help string for more details):

```shell
./collector-framework collect --interface="<ptp interface>" --kubeconfig="${KUBECONFIG}"
```

### Fetching logs
The log subcommand has been removed. Instead we have implimented at collector which is enabled by default.
If possible you should use a log aggregator. You can control the collectors running using the `--collector` flag.

## Running tests

TODO: implement tests for all packages

To test the framework components run `ginkgo pkg/<packagename>`, for example to run the unit tests for the `config` package use `ginkgo pkg/config`

## Contributing to the repo

See [Adding a collector](doc/implementing_a_collector.md)

## To Do List

* unit tests for all of `pkg/`
* add more collectors
* better data persistance options
See `tgm-collectors` for an example.
1 change: 0 additions & 1 deletion collector-framework/pkg/collectors/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ func RegisterCollector(collectorName string, builderFunc collectonBuilderFunc, i
optional: make([]string, 0),
}
}
fmt.Print(collectorName)
registry.register(collectorName, builderFunc, inclusionType)
}
3 changes: 2 additions & 1 deletion collector-framework/pkg/runner/collector_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ package runner
import (
"strings"

"github.com/redhat-partner-solutions/vse-sync-collection-tools/collector-framework/pkg/collectors"
log "github.com/sirupsen/logrus"

"github.com/redhat-partner-solutions/vse-sync-collection-tools/collector-framework/pkg/collectors"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions tgm-collector/pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ var (
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
collectors.LinkMe()
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}

}

func init() {
Expand All @@ -45,4 +43,6 @@ func init() {
log.WarnLevel.String(),
"Log level (debug, info, warn, error, fatal, panic)",
)

collectors.IncludeCollectorsNoOp()
}
3 changes: 2 additions & 1 deletion tgm-collector/pkg/collectors/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ func getPTPInterfaceName(constructor *collectorsBase.CollectionConstructor) (str
return ptpInterface, nil
}

func LinkMe() {}
// Empty function used to insure the collectors module gets added to the resulting binary
func IncludeCollectorsNoOp() {}

0 comments on commit 3a34397

Please sign in to comment.