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

code coverage for storagequota #3115

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions cmd/vsphere-csi/main.go
Original file line number Diff line number Diff line change
@@ -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"
@@ -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)

}

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
@@ -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
23 changes: 19 additions & 4 deletions images/driver/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 ##
################################################################################
@@ -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.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-dump.out"]

ENTRYPOINT ["/bin/vsphere-csi"]
18 changes: 14 additions & 4 deletions images/syncer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 ##
################################################################################
@@ -56,9 +56,19 @@ 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

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

RUN chmod 777 /tmp/cloud

RUN touch /tmp/cloud/contr-syncer-dump.out

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

ENTRYPOINT ["/bin/sh", "-c", "/bin/vsphere-syncer.test -test.coverprofile=/tmp/cloud/contr-syncer-dump.out"]

10 changes: 5 additions & 5 deletions pkg/syncer/metadatasyncer.go
Original file line number Diff line number Diff line change
@@ -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)
@@ -982,7 +982,7 @@ func InitMetadataSyncer(ctx context.Context, clusterFlavor cnstypes.CnsClusterFl
}()
}

<-stopCh
//<-stopCh
return nil
}