Skip to content

Commit

Permalink
Merge branch 'master' into 17899/telegramNotification2
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankudibal authored Aug 5, 2020
2 parents 1fa7ae0 + 46c7345 commit baaadc2
Show file tree
Hide file tree
Showing 83 changed files with 2,644 additions and 617 deletions.
21 changes: 11 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ commands:
steps:
- run:
name: Install clang
command: sudo apt-get install -y --no-install-recommends clang musl-tools
command: sudo apt-get update && sudo apt-get install -y --no-install-recommends clang musl-tools
- run:
name: Install rust compiler
command: |
Expand All @@ -22,13 +22,13 @@ commands:
- run:
name: Install linux cross compilers
command: >
sudo apt-get install -y --no-install-recommends
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
gcc-aarch64-linux-gnu libc6-dev-arm64-cross
sudo apt-get update && sudo apt-get install -y --no-install-recommends
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
gcc-aarch64-linux-gnu libc6-dev-arm64-cross
- run:
name: Install macOS cross compilers
command: |
sudo apt-get install -y --no-install-recommends \
sudo apt-get update && sudo apt-get install -y --no-install-recommends \
cmake patch libxml2-dev libssl-dev zlib1g-dev
sudo mkdir -p /opt/osxcross
cd /opt
Expand Down Expand Up @@ -143,6 +143,7 @@ jobs:
name: Restoring GOPATH/pkg/mod
keys:
- influxdb-gomod-{{ checksum "go.sum" }} # Just match the go.sum checksum cache.
- run: sudo apt-get update
- run: sudo apt-get install -y netcat-openbsd
- run: sudo apt-get install -y bzr
- install_rust_compiler
Expand Down Expand Up @@ -289,7 +290,7 @@ jobs:
name: Restoring GOPATH/pkg/mod
keys:
- influxdb-gomod-{{ checksum "go.sum" }} # Matches based on go.sum checksum.
- run: sudo apt-get install -y bzr
- run: sudo apt-get update && sudo apt-get install -y bzr
- install_rust_compiler
- run: mkdir -p $TEST_RESULTS
- run: make test-go # This uses the test cache so it may succeed or fail quickly.
Expand Down Expand Up @@ -340,7 +341,7 @@ jobs:
working_directory: /go/src/github.com/influxdata/influxdb
steps:
- checkout
- run: sudo apt-get install -y bzr
- run: sudo apt-get update && sudo apt-get install -y bzr
- install_rust_compiler
- run: mkdir -p $TEST_RESULTS
- run: |
Expand Down Expand Up @@ -373,7 +374,7 @@ jobs:
working_directory: /go/src/github.com/influxdata/influxdb
steps:
- checkout
- run: sudo apt-get install -y bzr
- run: sudo apt-get update && sudo apt-get install -y bzr
- install_rust_compiler
- run: make checkcommit

Expand Down Expand Up @@ -419,7 +420,7 @@ jobs:
- run:
name: "Docker Login"
command: docker login -u "$QUAY_USER" -p $QUAY_PASS quay.io
- run: sudo apt-get install -y bzr
- run: sudo apt-get update && sudo apt-get install -y bzr
- install_rust_compiler
- install_release_tools
- run: make protoc # installs protoc
Expand Down Expand Up @@ -456,7 +457,7 @@ jobs:
- run:
name: "Docker Login"
command: docker login -u "$QUAY_USER" -p $QUAY_PASS quay.io
- run: sudo apt-get install -y bzr
- run: sudo apt-get update && sudo apt-get install -y bzr
- install_rust_compiler
- install_release_tools
- run: make protoc # installs protoc
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@

1. [19075](https://github.com/influxdata/influxdb/pull/19075): Add resource links to a stack's resources from public HTTP API list/read calls
1. [19103](https://github.com/influxdata/influxdb/pull/19103): Enhance resource creation experience when limits are reached
1. [18218](https://github.com/influxdata/influxdb/pull/18218): Add Telegram notification.
1. [19135](https://github.com/influxdata/influxdb/pull/19135): Add Telegram notification.
1. [19223](https://github.com/influxdata/influxdb/pull/19223): Add dashboards command to influx CLI
1. [19225](https://github.com/influxdata/influxdb/pull/19225): Allow user onboarding to optionally set passwords

### Bug Fixes

1. [19043](https://github.com/influxdata/influxdb/pull/19043): Enforce all influx CLI flag args are valid
1. [19188](https://github.com/influxdata/influxdb/pull/19188): Dashboard cells correctly map results when multiple queries exist
1. [19146](https://github.com/influxdata/influxdb/pull/19146): Dashboard cells and overlay use UTC as query time when toggling to UTC timezone

## v2.0.0-beta.15 [2020-07-23]

Expand Down
154 changes: 154 additions & 0 deletions cmd/influx/dashboard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
package main

import (
"context"

"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/cmd/influx/internal"
"github.com/influxdata/influxdb/v2/http"
"github.com/influxdata/influxdb/v2/tenant"
"github.com/spf13/cobra"
)

func cmdDashboard(f *globalFlags, opts genericCLIOpts) *cobra.Command {
return newCmdDashboardBuilder(newDashboardSVCs, f, opts).cmdDashboards()
}

type dashboardSVCsFn func() (influxdb.DashboardService, influxdb.OrganizationService, error)

type cmdDashboardBuilder struct {
genericCLIOpts
*globalFlags

svcFn dashboardSVCsFn

ids []string
org organization
}

func newCmdDashboardBuilder(svcFn dashboardSVCsFn, f *globalFlags, opts genericCLIOpts) *cmdDashboardBuilder {
return &cmdDashboardBuilder{
genericCLIOpts: opts,
globalFlags: f,
svcFn: svcFn,
}
}

func (b *cmdDashboardBuilder) cmdDashboards() *cobra.Command {
cmd := b.newCmd("dashboards", b.listRunE)
cmd.Short = "List Dashboard(s)."
cmd.Long = `
List Dashboard(s).
Examples:
# list all known Dashboards
influx dashboards
# list all known Dashboards matching ids
influx dashboards --id $ID1 --id $ID2
# list all known Dashboards matching ids shorts
influx dashboards -i $ID1 -i $ID2
`

b.org.register(cmd, false)
cmd.Flags().StringArrayVarP(&b.ids, "id", "i", nil, "Dashboard ID to retrieve.")

return cmd
}

func (b *cmdDashboardBuilder) listRunE(cmd *cobra.Command, args []string) error {
svc, orgSVC, err := b.svcFn()
if err != nil {
return err
}

orgID, _ := b.org.getID(orgSVC)
if orgID == 0 && len(b.ids) == 0 {
return &influxdb.Error{
Code: influxdb.EUnprocessableEntity,
Msg: "at least one of org, org-id, or id must be provided",
}
}

var ids []*influxdb.ID
for _, rawID := range b.ids {
id, err := influxdb.IDFromString(rawID)
if err != nil {
return err
}
ids = append(ids, id)
}

var (
out []*influxdb.Dashboard
offset int
)
const limit = 100
for {
dashboards, _, err := svc.FindDashboards(context.Background(), influxdb.DashboardFilter{
IDs: ids,
OrganizationID: &orgID,
}, influxdb.FindOptions{
Limit: limit,
Offset: offset,
})
if err != nil && influxdb.ErrorCode(err) != influxdb.ENotFound {
return err
}
out = append(out, dashboards...)
if len(dashboards) < limit {
break
}
offset += len(dashboards)
}

return b.writeDashboards(out...)
}

func (b *cmdDashboardBuilder) writeDashboards(dashboards ...*influxdb.Dashboard) error {
if b.json {
return b.writeJSON(dashboards)
}

tabW := b.newTabWriter()
defer tabW.Flush()

writeDashboardRows(tabW, dashboards...)
return nil
}

func writeDashboardRows(tabW *internal.TabWriter, dashboards ...*influxdb.Dashboard) {
tabW.WriteHeaders("ID", "OrgID", "Name", "Description", "Num Cells")
for _, d := range dashboards {
tabW.Write(map[string]interface{}{
"ID": d.ID,
"OrgID": d.OrganizationID.String(),
"Name": d.Name,
"Description": d.Description,
"Num Cells": len(d.Cells),
})
}
}

func (b *cmdDashboardBuilder) newCmd(use string, runE func(*cobra.Command, []string) error) *cobra.Command {
cmd := b.genericCLIOpts.newCmd(use, runE, true)
b.genericCLIOpts.registerPrintOptions(cmd)
b.globalFlags.registerFlags(cmd)
return cmd
}

func newDashboardSVCs() (influxdb.DashboardService, influxdb.OrganizationService, error) {
httpClient, err := newHTTPClient()
if err != nil {
return nil, nil, err
}

orgSVC := &tenant.OrgClientService{
Client: httpClient,
}
dashSVC := &http.DashboardService{
Client: httpClient,
}
return dashSVC, orgSVC, nil
}
1 change: 1 addition & 0 deletions cmd/influx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ func influxCmd(opts ...genericCLIOptFn) *cobra.Command {
cmdBackup,
cmdBucket,
cmdConfig,
cmdDashboard,
cmdDelete,
cmdExport,
cmdOrganization,
Expand Down
2 changes: 1 addition & 1 deletion cmd/influx/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func writeTelegrafRows(tabW *internal.TabWriter, cfgs ...*influxdb.TelegrafConfi
for _, cfg := range cfgs {
tabW.Write(map[string]interface{}{
"ID": cfg.ID,
"OrgID": cfg.OrgID,
"OrgID": cfg.OrgID.String(),
"Name": cfg.Name,
"Description": cfg.Description,
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/influxd/launcher/pkger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3432,7 +3432,7 @@ spec:
}, varArgs.Values)
})

t.Run("error incurs during template application when resources already exist rollsback to prev state", func(t *testing.T) {
t.Run("error incurred during template application when resources already exist rollsback to prev state", func(t *testing.T) {
updatePkg, err := pkger.Parse(pkger.EncodingYAML, pkger.FromString(updatePkgYMLStr))
require.NoError(t, err)

Expand Down
79 changes: 75 additions & 4 deletions cmd/influxd/launcher/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2235,18 +2235,89 @@ from(bucket: v.bucket)
,result,table,kk,_value
,,0,kk0,32
,,1,kk1,35
`,
},
{
name: "min group",
data: []string{
"m0,k=k0,kk=kk0 f=0i 0",
"m0,k=k0,kk=kk1 f=1i 1000000000",
"m0,k=k0,kk=kk0 f=2i 2000000000",
"m0,k=k0,kk=kk1 f=3i 3000000000",
"m0,k=k0,kk=kk0 f=4i 4000000000",
"m0,k=k0,kk=kk1 f=5i 5000000000",
"m0,k=k0,kk=kk0 f=6i 6000000000",
"m0,k=k0,kk=kk1 f=5i 7000000000",
"m0,k=k0,kk=kk0 f=0i 8000000000",
"m0,k=k0,kk=kk1 f=6i 9000000000",
"m0,k=k0,kk=kk0 f=6i 10000000000",
"m0,k=k0,kk=kk1 f=7i 11000000000",
"m0,k=k0,kk=kk0 f=5i 12000000000",
"m0,k=k0,kk=kk1 f=8i 13000000000",
"m0,k=k0,kk=kk0 f=9i 14000000000",
"m0,k=k0,kk=kk1 f=5i 15000000000",
},
op: "readGroup(min)",
query: `
from(bucket: v.bucket)
|> range(start: 1970-01-01T00:00:00Z, stop: 1970-01-01T00:00:15Z)
|> group(columns: ["kk"])
|> min()
|> keep(columns: ["kk", "_value"])
`,
want: `
#datatype,string,long,string,long
#group,false,false,true,false
#default,_result,,,
,result,table,kk,_value
,,0,kk0,0
,,1,kk1,1
`,
},
{
name: "max group",
data: []string{
"m0,k=k0,kk=kk0 f=0i 0",
"m0,k=k0,kk=kk1 f=1i 1000000000",
"m0,k=k0,kk=kk0 f=2i 2000000000",
"m0,k=k0,kk=kk1 f=3i 3000000000",
"m0,k=k0,kk=kk0 f=4i 4000000000",
"m0,k=k0,kk=kk1 f=5i 5000000000",
"m0,k=k0,kk=kk0 f=6i 6000000000",
"m0,k=k0,kk=kk1 f=5i 7000000000",
"m0,k=k0,kk=kk0 f=0i 8000000000",
"m0,k=k0,kk=kk1 f=6i 9000000000",
"m0,k=k0,kk=kk0 f=6i 10000000000",
"m0,k=k0,kk=kk1 f=7i 11000000000",
"m0,k=k0,kk=kk0 f=5i 12000000000",
"m0,k=k0,kk=kk1 f=8i 13000000000",
"m0,k=k0,kk=kk0 f=9i 14000000000",
"m0,k=k0,kk=kk1 f=5i 15000000000",
},
op: "readGroup(max)",
query: `
from(bucket: v.bucket)
|> range(start: 1970-01-01T00:00:00Z, stop: 1970-01-01T00:00:15Z)
|> group(columns: ["kk"])
|> max()
|> keep(columns: ["kk", "_value"])
`,
want: `
#datatype,string,long,string,long
#group,false,false,true,false
#default,_result,,,
,result,table,kk,_value
,,0,kk0,9
,,1,kk1,8
`,
},
}
for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
l := launcher.RunTestLauncherOrFail(t, ctx, mock.NewFlagger(map[feature.Flag]interface{}{
feature.PushDownWindowAggregateCount(): true,
feature.PushDownWindowAggregateSum(): true,
feature.PushDownWindowAggregateMean(): true,
feature.PushDownWindowAggregateMin(): true,
feature.PushDownWindowAggregateMax(): true,
feature.PushDownGroupAggregateMinMax(): true,
}))

l.SetupOrFail(t)
Expand Down
8 changes: 8 additions & 0 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ test: docker-test docker-report
clean:
docker rm -f test-influxdb
rm -rf /tmp/report

bonitoo-prep:
npm run influx:setup

bonitoo-docker:
./scripts/containerTests.sh

bonitoo-test: bonitoo-prep bonitoo-docker
Loading

0 comments on commit baaadc2

Please sign in to comment.