Skip to content

Commit

Permalink
code coverage for storagequota
Browse files Browse the repository at this point in the history
  • Loading branch information
kavyashree-r committed Nov 21, 2024
1 parent 1abac0f commit 77d0591
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 14 deletions.
13 changes: 11 additions & 2 deletions cmd/vsphere-csi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"os/signal"
"syscall"
"time"

csiconfig "sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/config"
"sigs.k8s.io/vsphere-csi-driver/v3/pkg/common/utils"
Expand Down Expand Up @@ -92,8 +93,16 @@ func main() {
}
}()

vSphereCSIDriver := service.NewDriver()
vSphereCSIDriver.Run(ctx, CSIEndpoint)
//vSphereCSIDriver := service.NewDriver()
//vSphereCSIDriver.Run(ctx, CSIEndpoint)
go func() {
vSphereCSIDriver := service.NewDriver()
vSphereCSIDriver.Run(ctx, CSIEndpoint)
}()

// Sleep for 60 min in parallel
sleepDuration := 15 * time.Minute
time.Sleep(sleepDuration)

}

Expand Down
9 changes: 9 additions & 0 deletions cmd/vsphere-csi/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"testing"
)

func TestRunMain(t *testing.T) {
main()
}
2 changes: 2 additions & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ function build_syncer_image_linux() {
--build-arg "GOPROXY=${GOPROXY}" \
--build-arg "GIT_COMMIT=${GIT_COMMIT}" \
--build-arg "GOLANG_IMAGE=${GOLANG_IMAGE}" \
--build-arg ARCH=amd64 \
--platform "linux/$ARCH" \
.

if [ "${LATEST}" ]; then
Expand Down
23 changes: 19 additions & 4 deletions images/driver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ COPY pkg/ pkg/
COPY cmd/ cmd/
ENV CGO_ENABLED=0
ENV GOPROXY ${GOPROXY:-https://proxy.golang.org}
RUN go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service.Version=${VERSION}" -o vsphere-csi ./cmd/vsphere-csi

#RUN go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/csi/service.Version=${VERSION}" -o vsphere-csi ./cmd/vsphere-csi
RUN go test -v -c -coverpkg=./... ./cmd/vsphere-csi/ -o /build/vsphere-csi.test
################################################################################
## MAIN STAGE ##
################################################################################
Expand Down Expand Up @@ -72,6 +72,21 @@ RUN tdnf -y install \
# Remove cached data
RUN tdnf clean all

COPY --from=builder /build/vsphere-csi /bin/vsphere-csi
#COPY --from=builder /build/vsphere-csi /bin/vsphere-csi

#ENTRYPOINT ["/bin/vsphere-csi"]
RUN mkdir -p /tmp/cloud

RUN chmod 777 /tmp/cloud

# Save the timestamp in an environment variable
ENV TIMESTAMP $(date +%s)

# Create an empty file with the desired name
RUN touch /tmp/cloud/contr-dump-$TIMESTAMP.out

COPY --from=builder /build/vsphere-csi.test /bin/vsphere-csi.test

#ENTRYPOINT ["/bin/vsphere-csi.test", "-test.coverprofile=/tmp/cloud/contr-dump.out"]
ENTRYPOINT ["/bin/sh", "-c", "/bin/vsphere-csi.test -test.coverprofile=/tmp/cloud/contr-$(date +%s).out"]

ENTRYPOINT ["/bin/vsphere-csi"]
6 changes: 3 additions & 3 deletions images/syncer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ ENV CGO_ENABLED=0

ENV GOPROXY ${GOPROXY:-https://proxy.golang.org}

RUN go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer.Version=${VERSION}" -o vsphere-syncer ./cmd/syncer

##RUN go build -a -ldflags="-w -s -extldflags=static -X sigs.k8s.io/vsphere-csi-driver/v3/pkg/syncer.Version=${VERSION}" -o vsphere-syncer ./cmd/syncer
RUN go test -v -c -coverpkg=./... ./cmd/syncer/ -o /build/vsphere-syncer.test
################################################################################
## MAIN STAGE ##
################################################################################
Expand All @@ -56,7 +56,7 @@ LABEL git_commit=$GIT_COMMIT

RUN tdnf -y upgrade

COPY --from=builder /build/vsphere-syncer /bin/vsphere-syncer
##COPY --from=builder /build/vsphere-syncer /bin/vsphere-syncer

# Remove cached data
RUN tdnf clean all
Expand Down
10 changes: 5 additions & 5 deletions pkg/syncer/metadatasyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,10 @@ func InitMetadataSyncer(ctx context.Context, clusterFlavor cnstypes.CnsClusterFl
metadataSyncer.pvLister = metadataSyncer.k8sInformerManager.GetPVLister()
metadataSyncer.pvcLister = metadataSyncer.k8sInformerManager.GetPVCLister()
metadataSyncer.podLister = metadataSyncer.k8sInformerManager.GetPodLister()
stopCh := metadataSyncer.k8sInformerManager.Listen()
if stopCh == nil {
return logger.LogNewError(log, "Failed to sync informer caches")
}
// stopCh := metadataSyncer.k8sInformerManager.Listen()
// if stopCh == nil {
// return logger.LogNewError(log, "Failed to sync informer caches")
// }
log.Infof("Initialized metadata syncer")

fullSyncTicker := time.NewTicker(time.Duration(getFullSyncIntervalInMin(ctx)) * time.Minute)
Expand Down Expand Up @@ -982,7 +982,7 @@ func InitMetadataSyncer(ctx context.Context, clusterFlavor cnstypes.CnsClusterFl
}()
}

<-stopCh
//<-stopCh
return nil
}

Expand Down

0 comments on commit 77d0591

Please sign in to comment.