Commit graph

47 commits

Author SHA1 Message Date
Shayne Wang
19c16fd95e Change reading order of tailfile
change reading order from beginning at the end to beginning at a buffer start
added intergration tests for boundary cases
Removed whitespace
Signed-off-by: Shayne Wang <shaynexwang@gmail.com>
2016-11-14 11:58:01 -08:00
Brian Goff
bd9d14a07b Add support for reading logs extra attrs
The jsonlog logger currently allows specifying envs and labels that
should be propagated to the log message, however there has been no way
to read that back.

This adds a new API option to enable inserting these attrs back to the
log reader.

With timestamps, this looks like so:
```
92016-04-08T15:28:09.835913720Z foo=bar,hello=world hello
```

The extra attrs are comma separated before the log message but after
timestamps.

Without timestaps it looks like so:
```
foo=bar,hello=world hello
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-05-06 20:42:20 -04:00
John Howard
acaef7caaf Windows: Fix flakey LogsSinceFutureFollow
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-04-12 13:27:29 -07:00
John Howard
b0e24c7393 Windows: Remove TP4 support from test code
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-04-11 15:36:31 -07:00
Alexander Morozov
0c7c9df804 integration-cli: move goroutines info helpers to separate funcs
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-14 15:52:56 -07:00
Brian Goff
3d42393e7f Merge pull request #21161 from Microsoft/jjh/TestLogsPerformanceProblem
Windows: Improve TestLogsContainers performance
2016-03-14 13:04:16 -04:00
John Howard
8ff884548f Fix TestLogsContainers performance
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-03-12 16:15:14 -08:00
Christopher Jones
2a02914892 Fix error-checking when looking at empty log
Fixes a bug when the log output is empty.

The length of a slice containing an empty string is 1, not 0, so
the test fails to catch when the log is empty. Instead, take a look at
out, which is just a string.

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
2016-03-11 15:09:00 -05:00
Antonio Murdaca
e44689139d integration-cli: remove not necessary -d again
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-02-28 13:48:15 +01:00
John Howard
10bd587d77 Windows CI: Port docker_cli_logs_test.go
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-24 20:19:48 -08:00
Arnaud Porterie
4928121992 Fix flaky TestLogsSinceFutureFollow
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
2016-02-16 13:49:44 -08:00
David Calavera
27220ecc6b Move timeutils functions to the only places where they are used.
- Move time json marshaling to the jsonlog package: this is a docker
  internal hack that we should not promote as a library.
- Move Timestamp encoding/decoding functions to the API types: This is
  only used there. It could be a standalone library but I don't this
it's worth having a separated repo for this. It could introduce more
complexity than it solves.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-15 14:56:14 -05:00
David Calavera
0876742646 Implement docker logs with standalone client lib.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-09 12:04:55 -05:00
Aaron Lehmann
7ab0f9bf61 Fix flaky test TestLogsSince
This test can fail if it is run close to a second boundary:

    FAIL: docker_cli_logs_test.go:169: DockerSuite.TestLogsSince

    docker_cli_logs_test.go:183:
        c.Assert(out, checker.Not(checker.Contains), v,
    check.Commentf("unexpected log message returned, since=%v", since))
    ... obtained string = "" +
    ...     "2015-12-07T19:54:45.000551883Z 1449518084 log2\n" +
    ...     "2015-12-07T19:54:47.001310929Z 1449518086 log3\n"
    ... substring string = "log2"
    ... unexpected log message returned, since=1449518085

The problem is that it generates log lines using date +%s and uses that
timestamp as a reference for log filtering with (--since) later on in
the test. However, the timestamp that date +%s generates may not match
the log timestamp.

This commit changes the test to parse the log timestamp itself instead
of relying on a parallel timestamp.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2015-12-07 13:26:30 -08:00
Wen Cheng Ma
c424c8c32c Correct the message of ErrorCodeNoSuchContainer to "No such container"
Fixes issue #18424

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
2015-12-04 15:00:08 +08:00
Mike Brown
430d8ff611 modifying docker --since and --until to support nanoseconds and time zones
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2015-11-13 09:56:15 -06:00
Srini Brahmaroutu
2046ba3e3c GCCGO requires more memory and time to start containers, fixing GCCGO x86 CI
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
2015-10-26 19:09:00 +00:00
Jian Zhang
946e8cde53 Use c.Assert in integration-cli/docker_cli_logs_test.go
Signed-off-by: Jian Zhang <zhangjian.fnst@cn.fujitsu.com>
2015-10-15 10:53:19 +08:00
Morgan Bauer
1eecc1e7e5
refactor logs to not use internal data structures
- refactor to make it easier to split the api in the future
 - additional tests for non existent container case

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
2015-10-07 15:44:16 -07:00
John Howard
f9a3558a9d Windows: Get Integration CLI running
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-09-04 12:32:40 -07:00
Veres Lajos
5146232723 typofix - https://github.com/vlajos/misspell_fixer
Signed-off-by: Veres Lajos <vlajos@gmail.com>
2015-08-07 23:25:49 +01:00
David Calavera
1c6fe58efc Merge pull request #14442 from cpuguy83/refactor_logdrvier_reader
Refactor log driver reader
2015-07-22 11:54:35 -07:00
Brian Goff
c0391bf554 Split reader interface from logger interface
Implement new reader interface on jsonfile.
Moves jsonlog decoding from daemon to jsonfile logger.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-07-21 20:47:31 -04:00
Lei
2e7daffd7b Minor fix of TestLogsStderrInStdout
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-07-21 20:37:14 +08:00
Lei
eef6eda7d2 Recfactor: Use dockerCmd when possible in integration-cli tests
Part of #14603
integration-cli/docker_cli_links_test.go (coolljt0725)
integration-cli/docker_cli_links_unix_test.go (coolljt0725)
integration-cli/docker_cli_logs_test.go (coolljt0725)
integration-cli/docker_cli_nat_test.go (coolljt0725)
integration-cli/docker_cli_network_test.go (coolljt0725)
integration-cli/docker_cli_stats_test.go (coolljt0725)
integration-cli/docker_cli_tag_test.go (coolljt0725)
integration-cli/docker_cli_top_test.go (coolljt0725)
integration-cli/docker_cli_version_test.go (coolljt0725)
integration-cli/docker_cli_wait_test.go (coolljt0725

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-07-20 14:44:22 +08:00
Brian Goff
0c84604f54 Fix goroutine leak on logs -f with no output
Also noticed potential hang when only stdout or stderr are used with
follow=1

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-06-04 13:56:40 -07:00
Alexander Morozov
7fffcfff32 Merge pull request #13387 from cpuguy83/fix_ngroutine_test
Better checking for LogsFollowGoroutinesWithStdout
2015-05-21 12:31:57 -07:00
Brian Goff
2805ff1ece Better checking for LogsFollowGoroutinesWithStdout
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-05-21 14:13:01 -04:00
Lorenzo Fontana
086b514f6a Removed deleteContainer calls
Signed-off-by: Lorenzo Fontana <fontanalorenzo@me.com>
2015-05-20 08:38:23 +02:00
Brian Goff
f207322c0a Extend sleep/timeout for ngoroutine check
In cases where this is failing it's ok to have the test take extra time,
but we don't want it to fail because of some race/performance
differences between systems.
So make the timeout go to 30s and double the sleep time in between
checks so it's not pounding the daemon quite so fast.

Originally I couldn't make this test fail (pre-change), but changed
graphdrivers and saw a failure pretty quickly.
This change seems to smooth that out.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-05-15 09:54:43 -04:00
Ahmet Alp Balkan
2fe2f7a186 integ-cli: Fix race in TestLogsSince
TestLogsSince used to rely on time synchronization and precision of
the timestamps. This change provides a less flaky alternative.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
2015-05-13 02:59:11 +00:00
Brian Goff
e3ba3dd5b8 Make sure log pipes are closed
Pipes are still not closed (and goroutines leaked) if neither pipe is
used.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-05-12 13:50:51 -04:00
Ahmet Alp Balkan
cb9a6b9aed Add --since argument to docker logs cmd
Added --since argument to `docker logs` command. Accept unix
timestamps and shows logs only created after the specified date.

Default value is 0 and passing default value or not specifying
the value in the request causes parameter to be ignored (behavior
prior to this change).

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
2015-05-10 20:42:14 +00:00
Antonio Murdaca
4203230cbb c.Fatal won't fail and exit test inside a goroutine, errors should be handled outside with a channel
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
2015-04-29 17:02:22 +02:00
Vincent Demeester
c5ef2901d8 delete "defer deleteContainer" on tests
Since docker test suite is now using gocheck, ``defer
deleteContainer(…)`` is not needed anymore.

Fixes #12705

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-04-23 22:27:46 +02:00
Alexander Morozov
dc944ea7e4 Use suite for integration-cli
It prints test name and duration for each test.
Also performs deleteAllContainers after each test.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-04-21 10:28:52 -07:00
Brian Goff
475c65319b Remove stripTrailingCharacters from tests
This was just an alias to `strings.TrimSpace`

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-04-06 09:21:18 -04:00
Tonis Tiigi
c2cf97a074 Fix panic on slow log consumer.
Fixes #8832

All stdio streams need to finish writing before the
connection can be closed.

Signed-off-by: Tõnis Tiigi <tonistiigi@gmail.com> (github: tonistiigi)
2014-10-30 22:24:57 +02:00
Jessica Frazelle
842d4b6b0a Cleanup errorOut resp log tests
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
2014-10-16 15:06:20 -07:00
unclejack
9ae3134dc9 add the timeutils package
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-09-17 14:30:08 +03:00
Doug Davis
cd7a5f5c09 Fix for issue 7902.
Use utils.RFC3339NanoFixed ("2006-01-02T15:04:05.000000000Z07:00")
instead of time.RFC3339Nano to format our log timestamps - this way
things are aligned, in particular the nano seconds are padded with zeros

Signed-off-by: Doug Davis <dug@us.ibm.com>
2014-09-16 10:28:37 -07:00
Alexandr Morozov
f04ef96e07
Test for following logs for stopped container
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
2014-08-20 20:02:56 +04:00
James Turnbull
aa0eca03e6 Updated docker logs timestamp to RFC3339
Currently the docker logs timestamp flag generates log entries like:

    $ sudo docker logs -ft daemon_dave
    [May 10 13:06:17.934] hello world

It uses Go's StampMilli timestamp to generate the timestamp. The entry
is also wrapped in [ ].

This is non-standard operational timestamp and one that will require
custom parsing.

The new timestamp is RFC3999Nano and generates entries like:

    2014-05-10T17:42:14.999999999Z07:00 hello world

These are readily parsed by tools like ELK.

Docker-DCO-1.1-Signed-off-by: James Turnbull <james@lovedthanlost.net> (github: jamtur01)

Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
2014-07-09 11:59:06 -04:00
Alexandr Morozov
1dc0caf9c0 Implement tail for docker logs
Fixes #4330
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-07-01 23:44:12 +04:00
Alexandr Morozov
d1297feef8 Timestamps for docker logs.
Fixes #1165
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
2014-05-01 20:40:36 +04:00
unclejack
e09274476f cli integration: sync container & image deletion
This makes container and image removal in the tests run synchronously.

Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-04-04 03:22:32 +03:00
Guillaume J. Charmes
5fb28eab3e
Add regression test
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume@charmes.net> (github: creack)
2014-03-31 13:12:22 -07:00