Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyo committed Dec 21, 2023
1 parent 75f4cc9 commit b519900
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
10 changes: 0 additions & 10 deletions crons_monitor_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func TestNewCronsJobData(t *testing.T) {

fakeId := "080181f33ca343f89b0bf55d50abfeee"

cronsJobData := NewCronsJobData(sentry.EventID(fakeId))
Expand All @@ -23,7 +22,6 @@ func TestNewCronsJobData(t *testing.T) {
}

func TestGetCheckinId(t *testing.T) {

fakeId := "080181f33ca343f89b0bf55d50abfeee"

cronsJobData := NewCronsJobData(sentry.EventID(fakeId))
Expand All @@ -37,7 +35,6 @@ func TestGetCheckinId(t *testing.T) {
}

func TestNewCronsMonitorData(t *testing.T) {

fakeMonitorSlug := "cronjob-slug"
fakeSchedule := "* * * * *"
var fakeCompletions int32 = 3
Expand All @@ -59,7 +56,6 @@ func TestNewCronsMonitorData(t *testing.T) {
}

func TestAddJob(t *testing.T) {

fakeId := "080181f33ca343f89b0bf55d50abfeee"
fakeMonitorSlug := "cronjob-slug"
fakeSchedule := "* * * * *"
Expand All @@ -84,15 +80,13 @@ func TestAddJob(t *testing.T) {
}

func TestNewCronsMetaData(t *testing.T) {

cronsMetaData := NewCronsMetaData()
if cronsMetaData.cronsMonitorDataMap == nil {
t.Errorf("Failed to create cronsMonitorDataMap")
}
}

func TestAddCronsMonitorData(t *testing.T) {

cronsMetaData := NewCronsMetaData()
if cronsMetaData.cronsMonitorDataMap == nil {
t.Errorf("Failed to create cronsMonitorDataMap")
Expand All @@ -115,7 +109,6 @@ func TestAddCronsMonitorData(t *testing.T) {
}

func TestDeleteCronsMonitorData(t *testing.T) {

cronsMetaData := NewCronsMetaData()
if cronsMetaData.cronsMonitorDataMap == nil {
t.Errorf("Failed to create cronsMonitorDataMap")
Expand All @@ -135,11 +128,9 @@ func TestDeleteCronsMonitorData(t *testing.T) {
if ok {
t.Errorf("Failed to delete cronsMonitorData from map")
}

}

func TestGetCronsMonitorData(t *testing.T) {

cronsMetaData := NewCronsMetaData()
if cronsMetaData.cronsMonitorDataMap == nil {
t.Errorf("Failed to create cronsMonitorDataMap")
Expand All @@ -159,5 +150,4 @@ func TestGetCronsMonitorData(t *testing.T) {
if retCronsMonitorData != cronsMonitorData {
t.Errorf("Failed to get correct cronsMonitorData to map")
}

}
8 changes: 0 additions & 8 deletions enhancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
const breadcrumbLimit = 20

func runEnhancers(ctx context.Context, eventObject *v1.Event, kind string, object metav1.Object, scope *sentry.Scope, sentryEvent *sentry.Event) error {

logger := zerolog.Ctx(ctx)
logger.Debug().Msgf("Running the enhancer")

Expand Down Expand Up @@ -88,7 +87,6 @@ func eventEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Objec
}

func objectEnhancer(ctx context.Context, scope *sentry.Scope, kindObjectPair *KindObjectPair, sentryEvent *sentry.Event) error {

objectTag := fmt.Sprintf("%s/%s", kindObjectPair.kind, kindObjectPair.object.GetName())
ctx, logger := getLoggerWithTag(ctx, "object", objectTag)

Expand Down Expand Up @@ -196,7 +194,6 @@ func podEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Object,
}

func jobEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Object, sentryEvent *sentry.Event) error {

jobObj, ok := object.(*batchv1.Job)
if !ok {
return errors.New("failed to cast object to Job object")
Expand Down Expand Up @@ -226,7 +223,6 @@ func jobEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Object,
}

func cronjobEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Object, sentryEvent *sentry.Event) error {

cronjobObj, ok := object.(*batchv1.CronJob)
if !ok {
return errors.New("failed to cast object to CronJob object")
Expand Down Expand Up @@ -261,7 +257,6 @@ func cronjobEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Obj
}

func replicaSetEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Object, sentryEvent *sentry.Event) error {

replicasetObj, ok := object.(*appsv1.ReplicaSet)
if !ok {
return errors.New("failed to cast object to ReplicaSet object")
Expand Down Expand Up @@ -291,7 +286,6 @@ func replicaSetEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.
}

func deploymentEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.Object, sentryEvent *sentry.Event) error {

deploymentObj, ok := object.(*appsv1.Deployment)
if !ok {
return errors.New("failed to cast object to Deployment object")
Expand Down Expand Up @@ -323,7 +317,6 @@ func deploymentEnhancer(ctx context.Context, scope *sentry.Scope, object metav1.
// and returns an empty slice if the object has
// no owning objects
func findRootOwners(ctx context.Context, kindObjPair *KindObjectPair) ([]KindObjectPair, error) {

// Use DFS to find the leaves of the owner references graph
rootOwners, err := ownerRefDFS(ctx, kindObjPair)
if err != nil {
Expand All @@ -340,7 +333,6 @@ func findRootOwners(ctx context.Context, kindObjPair *KindObjectPair) ([]KindObj

// Performs DFS to find the leaves the owner references graph
func ownerRefDFS(ctx context.Context, kindObjPair *KindObjectPair) ([]KindObjectPair, error) {

parents := kindObjPair.object.GetOwnerReferences()
// the owners slice to be returned
rootOwners := []KindObjectPair{}
Expand Down
8 changes: 0 additions & 8 deletions sentry_dsn_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

func TestNewDsnClientMapping(t *testing.T) {

// Set the custom dsn flag as true
t.Setenv("SENTRY_K8S_CUSTOM_DSNS", "TRUE")
clientMapping := NewDsnClientMapping()
Expand All @@ -30,11 +29,9 @@ func TestNewDsnClientMapping(t *testing.T) {
if clientMapping.customDsnFlag {
t.Errorf("Failed to read custom dsn flag as false")
}

}

func TestAddClientToMap(t *testing.T) {

fakeDsn := "https://c6f9a148ee0775891414b50b9af35959@o4506191942320128.ingest.sentry.io/1234567890"
clientOptions := sentry.ClientOptions{
Dsn: fakeDsn,
Expand Down Expand Up @@ -83,7 +80,6 @@ func TestGetClientFromMap(t *testing.T) {
}

func TestGetClientFromObject(t *testing.T) {

// Set the custom dsn flag as true
t.Setenv("SENTRY_K8S_CUSTOM_DSNS", "TRUE")
clientMapping := NewDsnClientMapping()
Expand Down Expand Up @@ -141,11 +137,9 @@ func TestGetClientFromObject(t *testing.T) {
if !reflect.DeepEqual(firstClient, secondClient) {
t.Errorf("The function failed to retrieve the client it originally created")
}

}

func TestSearchDsn(t *testing.T) {

// Create empty context
ctx := context.Background()
// Create simple fake client
Expand Down Expand Up @@ -220,11 +214,9 @@ func TestSearchDsn(t *testing.T) {
if podDsn != fakeDsn {
t.Errorf("DSN expected: %s, actual: %s", fakeDsn, podDsn)
}

}

func TestFindObject(t *testing.T) {

// Create empty context
ctx := context.Background()
// Create simple fake client
Expand Down

0 comments on commit b519900

Please sign in to comment.