Commit 229074c
authored
Unit tests for Notebook Instance (#83)
#82 is required for this PR.
This pull request has unit tests for the Notebook Instance, currently it has about 75% coverage and it takes about 0.1 seconds to run.
Here are all the tests:
Create:
- Create=InvalidInput - Given one of the parameters is invalid, ko.Status shows a terminal condition
- Create=Valid - Testing a successful create call
ReadOne:
- ReadOne=AfterCreate - Testing readOne right after create, the status should be in Pending with Resource synced being false.
- ReadOne=Deleting - Testing readOne when deleting, resource synced should be false.
- ReadOne=Fail - Testing readone when Describe fails, an error should be returned.
- ReadOne=FailedState - Testing how readone handles the Failed State, it should have a failure reason.
- ReadOne=InService - Testing how readone handles the InService state. Resource Synced should be true.
- ReadOne=StoppedAfterUpdateACK - Testing how readone handles the Stopped state after it's been updated. In this test the Notebook Instance has been stopped by the controller.
- ReadOne=StoppedAfterUpdateHuman - Testing how readone handles the Stopped state when stopped by a human for an update, StoppedByControllerMeta should not be in the status.
- ReadOne=StoppedBeforeUpdateACK - Testing how readone handles the Stopped state when it's stopped right before an update. The StoppedByControllerMetadata status should be in UpdatePending.
- ReadOne=StoppingDeleting - Testing how readone handles the Stopping state before going into deleting. The Resource synced condition should be set to False.
- ReadOne=StoppingUpdate - Testing how readone handles the Stopping state before going into Update. The resource synced condition should be False and the StoppedByControllerMetadata status should be set to UpdatePending.
- ReadOne=UpdatingUser - Testing how readone handles the Updating status when a user stops the Notebook. StoppedByControllerMetadata should not be in the status field.
- ReadOne=UpdatingUserStopping- Testing if the readone call updates the Notebook's status from stopped to updating, when it recieves information from the server.
- ReadOne=StartFail - Testing how readone would behave if start failed, test should return an error.
Update:
- Update=Pending - This test checks if the Notebook requeues while in Pending state.
- Update=Stopping - This test checks if the Notebook requeues while in Stopping state.
- Update=Updating - This test checks if the Notebook requeues while in updating state.
- Update=InService - This test checks if the controller stops the Notebook. Note: Although a stop controller call has been made runtime has not performed an sdk.Find() as a result the NotebookInstanceStatus will be InService.
- Update=Stopped - ByControllerUser - This test checks if the controller updates and does not set the StoppedByControllerMetadata status.
- Update=InvalidInput - This test checks what the controller would do if update failed. It should return an error.
- Update=Dissassociated - This test checks if the dissassociated parameters are being handled right.
- Update=StopError - This test checks if the controller returns an error if StopNotebookInstance fails.
Delete:
- Delete=InService - This test checks if the Notebook stops before deleting.
- Delete=Deleting - This test checks if the Notebook requeues while deleting
- Delete=Pending - This test checks if the Notebook requeues while in pending state
- Delete=Stopping - This test checks if the Notebook requeues while stopping
- Delete=Updating - This test checks if the Notebook requeues while updating.
- Delete=Stopped - This test checks if the Notebook requeues right after making the delete call.
- Delete=Fail - This test checks if the Notebook returns an error if delete fails.
- Delete=StopFail - This test checks if the Notebook returns an error if delete fails.
Nomenclature:
For readone/delete/update output
nb_(operation)__(suffix)
For update input:
nb_update_<desired/latest>_(suffix)
Directory structure:
testdata
- v1alpha - (folder which has yaml files)
- crud operation
- desired (folder which has input yaml files)
- observed (folder which has output yaml files)
- sdkapi
- readOne - (server responses for readone)
- create - (server responses for create)
TODO:
ReadOne
Replace status with annotation in the following files:
- testdata/v1alpha1/readone/desired/nb_readone_stopped_after_update_ack.yaml
- testdata/v1alpha1/readone/desired/nb_readone_stopped_before_update_ack.yaml
- testdata/v1alpha1/readone/desired/nb_readone_stopping_update.yaml
- testdata/v1alpha1/readone/observed/nb_readone_stopped_before_update_ack.yaml
- testdata/v1alpha1/readone/observed/nb_readone_stopped_before_update_ack.yaml
- testdata/v1alpha1/readone/observed/nb_readone_stopping_update.yaml
Update tests:
Replace status with annotation in the following files:
- testdata/v1alpha1/update/desired/nb_update_latest_stopped_controller_input.yaml
- testdata/v1alpha1/update/desired/nb_update_latest_stopped_dissassociated.yaml
- testdata/v1alpha1/update/desired/nb_update_latest_stopping_input.yaml
- testdata/v1alpha1/update/observed/nb_update_inservice.yaml
- testdata/v1alpha1/update/observed/nb_update_stopped_controller.yaml
Delete tests:
Add tests for complete deletion(once unit test supports that)1 parent fced166 commit 229074c
File tree
64 files changed
+1718
-0
lines changed- pkg/resource/notebook_instance
- testdata
- sdkapi
- create
- readone
- v1alpha1
- create
- desired
- observed
- delete/desired
- readone
- desired
- observed
- update
- desired
- observed
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
64 files changed
+1718
-0
lines changedLines changed: 137 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
Whitespace-only changes.
0 commit comments