func TestWrite_concurrentPermError(t *testing.T) {
	p := newPostgresqlTest(t)
	p.dbConfig.MaxConns = 2
	require.NoError(t, p.Connect())

	metrics := []telegraf.Metric{
		newMetric(t, "_a", MSS{}, MSI{"v": 1}),
	}
	require.NoError(t, p.Write(metrics))
	p.Logger.WaitForCopy(t.Name()+"_a", false)

	metrics = []telegraf.Metric{
		newMetric(t, "_a", MSS{}, MSI{"v": "a"}),
		newMetric(t, "_b", MSS{}, MSI{"v": 2}),
	}
	require.NoError(t, p.Write(metrics))
	p.Logger.WaitFor(func(l Log) bool {
		return strings.Contains(l.String(), "write error")
	}, false)
	p.Logger.WaitForCopy(t.Name()+"_b", false)

	dumpA := dbTableDump(t, p.db, "_a")
	dumpB := dbTableDump(t, p.db, "_b")
	assert.Len(t, dumpA, 1)
	assert.Len(t, dumpB, 1)
}
// Test that the bad metric is dropped, and the rest of the batch succeeds.
Test that the bad metric is dropped, and the rest of the batch succeeds.
// Test that the bad metric is dropped and the rest of the batch succeeds .
func TestWrite_concurrentPermError(t *testing.T) {
	p := newPostgresqlTest(t)
	p.dbConfig.MaxConns = 2
	require.NoError(t, p.Connect())
	metrics := []telegraf.Metric{
		newMetric(t, "_a", MSS{}, MSI{"v": 1}),
	}
	require.NoError(t, p.Write(metrics))
	p.Logger.WaitForCopy(t.Name()+"_a", false)
	metrics = []telegraf.Metric{
		newMetric(t, "_a", MSS{}, MSI{"v": "a"}),
		newMetric(t, "_b", MSS{}, MSI{"v": 2}),
	}
	require.NoError(t, p.Write(metrics))
	p.Logger.WaitFor(func(l Log) bool {
		return strings.Contains(l.String(), "write error")
	}, false)
	p.Logger.WaitForCopy(t.Name()+"_b", false)
	dumpA := dbTableDump(t, p.db, "_a")
	dumpB := dbTableDump(t, p.db, "_b")
	assert.Len(t, dumpA, 1)
	assert.Len(t, dumpB, 1)
}
func TestWrite_concurrentPermError ( t * testing . T ) { p := newPostgresqlTest ( t ) p . dbConfig . MaxConns = 2 require . NoError ( t , p . Connect ( ) ) metrics := [ ] telegraf . Metric { newMetric ( t , " " , MSS { } , MSI { " " : 1 } ) , } require . NoError ( t , p . Write ( metrics ) ) p . Logger . WaitForCopy ( t . Name ( ) + " " , false ) metrics = [ ] telegraf . Metric { newMetric ( t , " " , MSS { } , MSI { " " : " " } ) , newMetric ( t , " " , MSS { } , MSI { " " : 2 } ) , } require . NoError ( t , p . Write ( metrics ) ) p . Logger . WaitFor ( func ( l Log ) bool { return strings . Contains ( l . String ( ) , " " ) } , false ) p . Logger . WaitForCopy ( t . Name ( ) + " " , false ) dumpA := dbTableDump ( t , p . db , " " ) dumpB := dbTableDump ( t , p . db , " " ) assert . Len ( t , dumpA , 1 ) assert . Len ( t , dumpB , 1 ) }
Test that the bad metric is dropped, and the rest of the batch succeeds.
Test that the bad metric is dropped and the rest of the batch succeeds .