fix(flakey-test): refactored getSortedBucketNames for more consistency and predictability. Finished DWP API functionality (#15802)
* fix(flakey-test): refactored getSortedBucketNames for more consistency and predictability. Finished DWP API functionality * fix(FilterRow): removed unnecessary FeatureFlag from component * chore: updated yml and tests to reflect API changespull/15713/head
parent
5eb29e9ed9
commit
5ba9142f2f
|
@ -6314,7 +6314,7 @@ components:
|
||||||
type: string
|
type: string
|
||||||
predicate:
|
predicate:
|
||||||
description: sql where like delete statement
|
description: sql where like delete statement
|
||||||
example: tag1="value1" and (tag2="value2" and tag3="value3")
|
example: tag1="value1" and (tag2="value2" and tag3!="value3")
|
||||||
type: string
|
type: string
|
||||||
Node:
|
Node:
|
||||||
oneOf:
|
oneOf:
|
||||||
|
|
|
@ -21,7 +21,7 @@ func TestDataTypeConversion(t *testing.T) {
|
||||||
name: "empty node",
|
name: "empty node",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "tag rule",
|
name: "equal tag rule",
|
||||||
node: &TagRuleNode{
|
node: &TagRuleNode{
|
||||||
Operator: influxdb.Equal,
|
Operator: influxdb.Equal,
|
||||||
Tag: influxdb.Tag{
|
Tag: influxdb.Tag{
|
||||||
|
@ -47,7 +47,33 @@ func TestDataTypeConversion(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "measurement tag rule",
|
name: "not equal tag rule",
|
||||||
|
node: &TagRuleNode{
|
||||||
|
Operator: influxdb.NotEqual,
|
||||||
|
Tag: influxdb.Tag{
|
||||||
|
Key: "k1",
|
||||||
|
Value: "v1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dataType: &datatypes.Node{
|
||||||
|
NodeType: datatypes.NodeTypeComparisonExpression,
|
||||||
|
Value: &datatypes.Node_Comparison_{Comparison: datatypes.ComparisonNotEqual},
|
||||||
|
Children: []*datatypes.Node{
|
||||||
|
{
|
||||||
|
NodeType: datatypes.NodeTypeTagRef,
|
||||||
|
Value: &datatypes.Node_TagRefValue{TagRefValue: "k1"},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
NodeType: datatypes.NodeTypeLiteral,
|
||||||
|
Value: &datatypes.Node_StringValue{
|
||||||
|
StringValue: "v1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "measurement equal tag rule",
|
||||||
node: &TagRuleNode{
|
node: &TagRuleNode{
|
||||||
Operator: influxdb.Equal,
|
Operator: influxdb.Equal,
|
||||||
Tag: influxdb.Tag{
|
Tag: influxdb.Tag{
|
||||||
|
@ -73,7 +99,33 @@ func TestDataTypeConversion(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "field tag rule",
|
name: "measurement not equal tag rule",
|
||||||
|
node: &TagRuleNode{
|
||||||
|
Operator: influxdb.NotEqual,
|
||||||
|
Tag: influxdb.Tag{
|
||||||
|
Key: "_measurement",
|
||||||
|
Value: "cpu",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dataType: &datatypes.Node{
|
||||||
|
NodeType: datatypes.NodeTypeComparisonExpression,
|
||||||
|
Value: &datatypes.Node_Comparison_{Comparison: datatypes.ComparisonNotEqual},
|
||||||
|
Children: []*datatypes.Node{
|
||||||
|
{
|
||||||
|
NodeType: datatypes.NodeTypeTagRef,
|
||||||
|
Value: &datatypes.Node_TagRefValue{TagRefValue: models.MeasurementTagKey},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
NodeType: datatypes.NodeTypeLiteral,
|
||||||
|
Value: &datatypes.Node_StringValue{
|
||||||
|
StringValue: "cpu",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "equal field tag rule",
|
||||||
node: &TagRuleNode{
|
node: &TagRuleNode{
|
||||||
Operator: influxdb.Equal,
|
Operator: influxdb.Equal,
|
||||||
Tag: influxdb.Tag{
|
Tag: influxdb.Tag{
|
||||||
|
@ -98,6 +150,32 @@ func TestDataTypeConversion(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "not equal field tag rule",
|
||||||
|
node: &TagRuleNode{
|
||||||
|
Operator: influxdb.NotEqual,
|
||||||
|
Tag: influxdb.Tag{
|
||||||
|
Key: "_field",
|
||||||
|
Value: "cpu",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dataType: &datatypes.Node{
|
||||||
|
NodeType: datatypes.NodeTypeComparisonExpression,
|
||||||
|
Value: &datatypes.Node_Comparison_{Comparison: datatypes.ComparisonNotEqual},
|
||||||
|
Children: []*datatypes.Node{
|
||||||
|
{
|
||||||
|
NodeType: datatypes.NodeTypeTagRef,
|
||||||
|
Value: &datatypes.Node_TagRefValue{TagRefValue: models.FieldKeyTagKey},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
NodeType: datatypes.NodeTypeLiteral,
|
||||||
|
Value: &datatypes.Node_StringValue{
|
||||||
|
StringValue: "cpu",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "logical",
|
name: "logical",
|
||||||
node: &LogicalNode{
|
node: &LogicalNode{
|
||||||
|
|
|
@ -44,7 +44,7 @@ func NodeComparison(op influxdb.Operator) (datatypes.Node_Comparison, error) {
|
||||||
case influxdb.Equal:
|
case influxdb.Equal:
|
||||||
return datatypes.ComparisonEqual, nil
|
return datatypes.ComparisonEqual, nil
|
||||||
case influxdb.NotEqual:
|
case influxdb.NotEqual:
|
||||||
fallthrough
|
return datatypes.ComparisonNotEqual, nil
|
||||||
case influxdb.RegexEqual:
|
case influxdb.RegexEqual:
|
||||||
fallthrough
|
fallthrough
|
||||||
case influxdb.NotRegexEqual:
|
case influxdb.NotRegexEqual:
|
||||||
|
|
|
@ -13,9 +13,7 @@ describe('Bucket Selector', () => {
|
||||||
expect(isSystemBucket(`naming_${SYSTEM}`)).toEqual(false)
|
expect(isSystemBucket(`naming_${SYSTEM}`)).toEqual(false)
|
||||||
expect(isSystemBucket('SYSTEM')).toEqual(false)
|
expect(isSystemBucket('SYSTEM')).toEqual(false)
|
||||||
})
|
})
|
||||||
// skipping this test for now as it's flakey. Issue has been raise:
|
it('should sort the bucket names alphabetically', () => {
|
||||||
// https://github.com/influxdata/influxdb/issues/15798
|
|
||||||
it.skip('should sort the bucket names alphabetically', () => {
|
|
||||||
const buckets: Bucket[] = [
|
const buckets: Bucket[] = [
|
||||||
{
|
{
|
||||||
id: '7902bd683453c00c',
|
id: '7902bd683453c00c',
|
||||||
|
|
|
@ -5,28 +5,36 @@ export const SYSTEM = 'system'
|
||||||
|
|
||||||
export const isSystemBucket = (type: string): boolean => type === SYSTEM
|
export const isSystemBucket = (type: string): boolean => type === SYSTEM
|
||||||
|
|
||||||
export const getSortedBucketNames = (buckets: Bucket[]) =>
|
const sortFunc = (a: Bucket, b: Bucket) => {
|
||||||
buckets
|
const firstBucket = `${a.name}`.toLowerCase()
|
||||||
.sort((a, b) => {
|
const secondBucket = `${b.name}`.toLowerCase()
|
||||||
const firstBucket = `${a.name}`.toLowerCase()
|
if (firstBucket === secondBucket) {
|
||||||
const secondBucket = `${b.name}`.toLowerCase()
|
return 0
|
||||||
if (firstBucket === secondBucket) {
|
}
|
||||||
return 0
|
if (firstBucket < secondBucket) {
|
||||||
}
|
return -1
|
||||||
if (isSystemBucket(a.type)) {
|
}
|
||||||
// ensures that the default system types are the last buckets
|
if (firstBucket > secondBucket) {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if (isSystemBucket(b.type)) {
|
return 0
|
||||||
// ensures that the default system types are the last buckets
|
}
|
||||||
return -1
|
|
||||||
}
|
export const getSortedBucketNames = (buckets: Bucket[]) => {
|
||||||
if (firstBucket < secondBucket) {
|
const systemBuckets = []
|
||||||
return -1
|
const otherBuckets = []
|
||||||
}
|
buckets.forEach(bucket => {
|
||||||
if (firstBucket > secondBucket) {
|
// separate system buckets from the rest
|
||||||
return 1
|
if (isSystemBucket(bucket.type)) {
|
||||||
}
|
systemBuckets.push(bucket)
|
||||||
return 0
|
} else {
|
||||||
})
|
otherBuckets.push(bucket)
|
||||||
.map(bucket => bucket.name)
|
}
|
||||||
|
})
|
||||||
|
// alphabetize system buckets
|
||||||
|
systemBuckets.sort(sortFunc)
|
||||||
|
// alphabetize other buckets
|
||||||
|
otherBuckets.sort(sortFunc)
|
||||||
|
// concat the system buckets to the end of the other buckets and map results
|
||||||
|
return otherBuckets.concat(systemBuckets).map(bucket => bucket.name)
|
||||||
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
Input,
|
Input,
|
||||||
SelectDropdown,
|
SelectDropdown,
|
||||||
} from '@influxdata/clockface'
|
} from '@influxdata/clockface'
|
||||||
import {FeatureFlag} from 'src/shared/utils/featureFlag'
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {Filter} from 'src/types'
|
import {Filter} from 'src/types'
|
||||||
|
@ -46,20 +45,17 @@ const FilterRow: FC<Props> = ({
|
||||||
>
|
>
|
||||||
<Input onChange={onChangeKey} value={key} testID="key-input" />
|
<Input onChange={onChangeKey} value={key} testID="key-input" />
|
||||||
</Form.Element>
|
</Form.Element>
|
||||||
<div className="delete-data-filter--equals">==</div>
|
<Form.Element
|
||||||
<FeatureFlag name="deleteWithPredicateEquality">
|
label="Equality Filter"
|
||||||
<Form.Element
|
required={true}
|
||||||
label="Equality Filter"
|
errorMessage={equalityErrorMessage}
|
||||||
required={true}
|
>
|
||||||
errorMessage={equalityErrorMessage}
|
<SelectDropdown
|
||||||
>
|
options={['=', '!=']}
|
||||||
<SelectDropdown
|
selectedOption={equality}
|
||||||
options={['=', '!=']}
|
onSelect={onChangeEquality}
|
||||||
selectedOption={equality}
|
/>
|
||||||
onSelect={onChangeEquality}
|
</Form.Element>
|
||||||
/>
|
|
||||||
</Form.Element>
|
|
||||||
</FeatureFlag>
|
|
||||||
<Form.Element
|
<Form.Element
|
||||||
label="Tag Value"
|
label="Tag Value"
|
||||||
required={true}
|
required={true}
|
||||||
|
|
|
@ -5,7 +5,6 @@ const OSS_FLAGS = {
|
||||||
alerting: false,
|
alerting: false,
|
||||||
eventMarkers: false,
|
eventMarkers: false,
|
||||||
deleteWithPredicate: false,
|
deleteWithPredicate: false,
|
||||||
deleteWithPredicateEquality: false,
|
|
||||||
downloadCellCSV: false,
|
downloadCellCSV: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +12,6 @@ const CLOUD_FLAGS = {
|
||||||
alerting: true,
|
alerting: true,
|
||||||
eventMarkers: false,
|
eventMarkers: false,
|
||||||
deleteWithPredicate: false,
|
deleteWithPredicate: false,
|
||||||
deleteWithPredicateEquality: false,
|
|
||||||
cloudBilling: CLOUD_BILLING_VISIBLE, // should be visible in dev and acceptance, but not in cloud
|
cloudBilling: CLOUD_BILLING_VISIBLE, // should be visible in dev and acceptance, but not in cloud
|
||||||
downloadCellCSV: false,
|
downloadCellCSV: false,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue