Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Unit testing framework #10

Closed
jsafrane opened this issue Dec 4, 2017 · 5 comments
Closed

Unit testing framework #10

jsafrane opened this issue Dec 4, 2017 · 5 comments
Assignees
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@jsafrane
Copy link
Contributor

jsafrane commented Dec 4, 2017

All drivers should have unit tests that would check their correctness and save us from regressions. For that, there should be a simple framework that a driver author would use to poke the driver easily with different requests and check that the responses, mounted directories, executed commands and other driver behavior is correct.

There should be also a simple mock for the most common operation like mount, checking if a directory is mounted, executing stuff, scanning /dev and so on.

@lpabon lpabon self-assigned this Dec 8, 2017
@lpabon
Copy link
Contributor

lpabon commented Dec 11, 2017

I discussed this with @chakri-nelluri and here is my proposal.

I have a PoC of a framework just to do a "sanity" test of a driver. This can be expanded as it matures in the future

Usage

  • Use as a standard Unit Test where the driver does the following:
func TestDriver(t *testing.T) {
       // Setup the driver. Driver in this example needs to be adjusted for tesing
        d := NewDriver()
        err := d.Start()
        assert.NotNil(err)
        defer d.Stop()

        // Start Sanity test
        tester := driver.NewDriverSanityTester(t, d.Address())
        tester.Run()
}
  • As a program for non-Golang drivers
$ sanity --endpoint <...>

Implementation

Here is the pseudo-code of the implementation:

type DriverSanityTester struct {
        conn *grpc.ClientConn
        t    *testing.T
}

func NewDriverSanityTester(t *testing.T, address string) *DriverSanityTester {
        conn, err := grpc.Dial(address, grpc.WithInsecure())
        assert.Nil(t, err)
        return &DriverSanityTester{
                t:    t,
                conn: conn,
        }
}

func (d *DriverSanityTester) Run() {
        RegisterFailHandler(Fail)
        var _ = Describe("Identity Server", func() {
                var c csi.IdentityClient

                BeforeEach(func() {
                        c = csi.NewIdentityClient(d.conn)
                })

                It("should fail when no version is provided", func() {
                        _, err := c.GetPluginInfo(context.Background(), &csi.GetPluginInfoRequest{})
                        Expect(err).NotTo(HaveOccurred())
                })
        })
        RunSpecs(d.t, "CSI Driver Sanity Suite")
}

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 22, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 22, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants