Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ public Notebook(ZeppelinConfiguration conf, NotebookRepo notebookRepo,
quartzSched.start();
CronJob.notebook = this;

loadAllNotes();
AuthenticationInfo anonymous = AuthenticationInfo.ANONYMOUS;
loadAllNotes(anonymous);
if (this.noteSearchService != null) {
long start = System.nanoTime();
logger.info("Notebook indexing started...");
Expand Down Expand Up @@ -462,11 +463,11 @@ private Note loadNoteFromRepo(String id, AuthenticationInfo subject) {
return note;
}

private void loadAllNotes() throws IOException {
List<NoteInfo> noteInfos = notebookRepo.list(null);
void loadAllNotes(AuthenticationInfo subject) throws IOException {
List<NoteInfo> noteInfos = notebookRepo.list(subject);

for (NoteInfo info : noteInfos) {
loadNoteFromRepo(info.getId(), null);
loadNoteFromRepo(info.getId(), subject);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class NotebookTest implements JobListenerFactory{
private DependencyResolver depResolver;
private NotebookAuthorization notebookAuthorization;
private Credentials credentials;
private AuthenticationInfo anonymous = new AuthenticationInfo("anonymous");
private AuthenticationInfo anonymous = AuthenticationInfo.ANONYMOUS;

@Before
public void setUp() throws Exception {
Expand Down Expand Up @@ -196,6 +196,30 @@ public void testReloadAllNotes() throws IOException {
assertEquals(notes.size(), 0);
}

@Test
public void testLoadAllNotes() {
Note note;
try {
assertEquals(0, notebook.getAllNotes().size());
note = notebook.createNote(anonymous);
Paragraph p1 = note.addParagraph();
Map config = p1.getConfig();
config.put("enabled", true);
p1.setConfig(config);
p1.setText("hello world");
note.persist(anonymous);
} catch (IOException fe) {
logger.warn("Failed to create note and paragraph. Possible problem with persisting note, safe to ignore", fe);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message above implies that it is intended as failing condition for this test, but return will actually make test pass.

What was the intention? I think it's fine to explicitly fail the test if some pre-condition fail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually if precondition fails it means the problem is in file saving routine and not related to testing this certain function. In this case we have option of being 1) strict and fail this test as well, or 2) being less strict since failing precondition in this case means that note.persist is failing and probably test for that function should be failing as well. I chose here second option initially, but it makes sense to make it more strict; i'll change it then.


try {
notebook.loadAllNotes(anonymous);
assertEquals(1, notebook.getAllNotes().size());
} catch (IOException e) {
fail("Subject is non-emtpy anonymous, shouldn't fail");
}
}

@Test
public void testPersist() throws IOException, SchedulerException, RepositoryException {
Note note = notebook.createNote(anonymous);
Expand Down