diff --git a/api/adminmonitor/admin_monitor_test.go b/api/adminmonitor/admin_monitor_test.go index 543220da0b..6195d49c8c 100644 --- a/api/adminmonitor/admin_monitor_test.go +++ b/api/adminmonitor/admin_monitor_test.go @@ -11,17 +11,20 @@ import ( ) func Test_stopWithoutStarting(t *testing.T) { + t.Parallel() monitor := New(1*time.Minute, nil) monitor.Stop() } func Test_stopCouldBeCalledMultipleTimes(t *testing.T) { + t.Parallel() monitor := New(1*time.Minute, nil) monitor.Stop() monitor.Stop() } func Test_startOrStopCouldBeCalledMultipleTimesConcurrently(t *testing.T) { + t.Parallel() synctest.Test(t, test_startOrStopCouldBeCalledMultipleTimesConcurrently) } @@ -38,6 +41,7 @@ func test_startOrStopCouldBeCalledMultipleTimesConcurrently(t *testing.T) { } func Test_canStopStartedMonitor(t *testing.T) { + t.Parallel() monitor := New(1*time.Minute, nil) monitor.Start(t.Context()) assert.NotNil(t, monitor.cancellationFunc, "cancellation function is missing in started monitor") @@ -47,6 +51,7 @@ func Test_canStopStartedMonitor(t *testing.T) { } func Test_start_shouldDisableInstanceAfterTimeout_ifNotInitialized(t *testing.T) { + t.Parallel() timeout := 10 * time.Millisecond datastore := i.NewDatastore(i.WithUsers([]portainer.User{})) diff --git a/api/apikey/apikey_test.go b/api/apikey/apikey_test.go index b3f8027d5e..b85c9ce2ca 100644 --- a/api/apikey/apikey_test.go +++ b/api/apikey/apikey_test.go @@ -7,6 +7,7 @@ import ( ) func Test_generateRandomKey(t *testing.T) { + t.Parallel() is := assert.New(t) tests := []struct { diff --git a/api/apikey/cache_test.go b/api/apikey/cache_test.go index 040423a635..b6ccb86dc7 100644 --- a/api/apikey/cache_test.go +++ b/api/apikey/cache_test.go @@ -8,6 +8,7 @@ import ( ) func Test_apiKeyCacheGet(t *testing.T) { + t.Parallel() is := assert.New(t) keyCache := NewAPIKeyCache(10, compareUser) @@ -43,6 +44,7 @@ func Test_apiKeyCacheGet(t *testing.T) { } func Test_apiKeyCacheSet(t *testing.T) { + t.Parallel() is := assert.New(t) keyCache := NewAPIKeyCache(10, compareUser) @@ -68,6 +70,7 @@ func Test_apiKeyCacheSet(t *testing.T) { } func Test_apiKeyCacheDelete(t *testing.T) { + t.Parallel() is := assert.New(t) keyCache := NewAPIKeyCache(10, compareUser) @@ -87,6 +90,7 @@ func Test_apiKeyCacheDelete(t *testing.T) { } func Test_apiKeyCacheLRU(t *testing.T) { + t.Parallel() is := assert.New(t) tests := []struct { @@ -148,6 +152,7 @@ func Test_apiKeyCacheLRU(t *testing.T) { } func Test_apiKeyCacheInvalidateUserKeyCache(t *testing.T) { + t.Parallel() is := assert.New(t) keyCache := NewAPIKeyCache(10, compareUser) diff --git a/api/apikey/service_test.go b/api/apikey/service_test.go index 4f884a20b3..b86468cd41 100644 --- a/api/apikey/service_test.go +++ b/api/apikey/service_test.go @@ -17,11 +17,13 @@ import ( ) func Test_SatisfiesAPIKeyServiceInterface(t *testing.T) { + t.Parallel() is := assert.New(t) is.Implements((*APIKeyService)(nil), NewAPIKeyService(nil, nil)) } func Test_GenerateApiKey(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -75,6 +77,7 @@ func Test_GenerateApiKey(t *testing.T) { } func Test_GetAPIKey(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -94,6 +97,7 @@ func Test_GetAPIKey(t *testing.T) { } func Test_GetAPIKeys(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -114,6 +118,7 @@ func Test_GetAPIKeys(t *testing.T) { } func Test_GetDigestUserAndKey(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -149,6 +154,7 @@ func Test_GetDigestUserAndKey(t *testing.T) { } func Test_UpdateAPIKey(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -197,6 +203,7 @@ func Test_UpdateAPIKey(t *testing.T) { } func Test_DeleteAPIKey(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -237,6 +244,7 @@ func Test_DeleteAPIKey(t *testing.T) { } func Test_InvalidateUserKeyCache(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/archive/targz_test.go b/api/archive/targz_test.go index 28598b208b..e375628e46 100644 --- a/api/archive/targz_test.go +++ b/api/archive/targz_test.go @@ -34,6 +34,7 @@ func listFiles(dir string) []string { } func Test_shouldCreateArchive(t *testing.T) { + t.Parallel() tmpdir := t.TempDir() content := []byte("content") @@ -74,6 +75,7 @@ func Test_shouldCreateArchive(t *testing.T) { } func Test_shouldCreateArchive2(t *testing.T) { + t.Parallel() tmpdir := t.TempDir() content := []byte("content") @@ -113,6 +115,7 @@ func Test_shouldCreateArchive2(t *testing.T) { } func TestExtractTarGzPathTraversal(t *testing.T) { + t.Parallel() testDir := t.TempDir() // Create an evil file with a path traversal attempt diff --git a/api/archive/zip_test.go b/api/archive/zip_test.go index bfc0d06a88..01a2999f70 100644 --- a/api/archive/zip_test.go +++ b/api/archive/zip_test.go @@ -9,6 +9,7 @@ import ( ) func TestUnzipFile(t *testing.T) { + t.Parallel() dir := t.TempDir() /* Archive structure. diff --git a/api/aws/ecr/parse_endpoints_test.go b/api/aws/ecr/parse_endpoints_test.go index 3c05dec915..4f256972d9 100644 --- a/api/aws/ecr/parse_endpoints_test.go +++ b/api/aws/ecr/parse_endpoints_test.go @@ -5,6 +5,7 @@ import ( ) func TestParseECREndpoint(t *testing.T) { + t.Parallel() tests := []struct { name string url string diff --git a/api/chisel/crypto/crypto_test.go b/api/chisel/crypto/crypto_test.go index 2dfc28dbdb..652fd42af9 100644 --- a/api/chisel/crypto/crypto_test.go +++ b/api/chisel/crypto/crypto_test.go @@ -6,6 +6,7 @@ import ( ) func TestGenerateGo119CompatibleKey(t *testing.T) { + t.Parallel() type args struct { seed string } diff --git a/api/chisel/service_test.go b/api/chisel/service_test.go index aa849a5052..fadd9c9406 100644 --- a/api/chisel/service_test.go +++ b/api/chisel/service_test.go @@ -18,6 +18,7 @@ func init() { } func TestPingAgentPanic(t *testing.T) { + t.Parallel() endpoint := &portainer.Endpoint{ ID: 1, EdgeID: "test-edge-id", diff --git a/api/chisel/tunnel_test.go b/api/chisel/tunnel_test.go index 6959bfa3ae..079d5dbd94 100644 --- a/api/chisel/tunnel_test.go +++ b/api/chisel/tunnel_test.go @@ -28,6 +28,7 @@ func (s *testStore) Settings() dataservices.SettingsService { } func TestGetUnusedPort(t *testing.T) { + t.Parallel() testCases := []struct { name string existingTunnels map[portainer.EndpointID]*portainer.TunnelDetails diff --git a/api/cmd/portainer/main_test.go b/api/cmd/portainer/main_test.go index 90fd827cd0..08ff0952ae 100644 --- a/api/cmd/portainer/main_test.go +++ b/api/cmd/portainer/main_test.go @@ -18,6 +18,7 @@ func createPasswordFile(t *testing.T, secretPath, password string) string { } func TestLoadEncryptionSecretKey(t *testing.T) { + t.Parallel() tempDir := t.TempDir() secretPath := path.Join(tempDir, secretFileName) @@ -39,6 +40,7 @@ func TestLoadEncryptionSecretKey(t *testing.T) { } func TestDBSecretPath(t *testing.T) { + t.Parallel() tests := []struct { keyFilenameFlag string expected string diff --git a/api/crypto/aes_test.go b/api/crypto/aes_test.go index 80b688ee1c..57f45afca6 100644 --- a/api/crypto/aes_test.go +++ b/api/crypto/aes_test.go @@ -141,6 +141,7 @@ func Test_encryptAndDecrypt_withTheSamePassword(t *testing.T) { } func Test_encryptAndDecrypt_withStrongPassphrase(t *testing.T) { + t.Parallel() const passphrase = "A strong passphrase with special characters: !@#$%^&*()_+" testFunc := func(t *testing.T, encrypt encryptFunc, decrypt decryptFunc) { @@ -200,6 +201,7 @@ func Test_encryptAndDecrypt_withStrongPassphrase(t *testing.T) { } func Test_encryptAndDecrypt_withTheSamePasswordSmallFile(t *testing.T) { + t.Parallel() testFunc := func(t *testing.T, encrypt encryptFunc, decrypt decryptFunc) { tmpdir := t.TempDir() @@ -257,6 +259,7 @@ func Test_encryptAndDecrypt_withTheSamePasswordSmallFile(t *testing.T) { } func Test_encryptAndDecrypt_withEmptyPassword(t *testing.T) { + t.Parallel() testFunc := func(t *testing.T, encrypt encryptFunc, decrypt decryptFunc) { tmpdir := t.TempDir() @@ -314,6 +317,7 @@ func Test_encryptAndDecrypt_withEmptyPassword(t *testing.T) { } func Test_decryptWithDifferentPassphrase_shouldProduceWrongResult(t *testing.T) { + t.Parallel() testFunc := func(t *testing.T, encrypt encryptFunc, decrypt decryptFunc) { tmpdir := t.TempDir() @@ -385,6 +389,7 @@ func legacyAesEncrypt(input io.Reader, output io.Writer, passphrase []byte) erro } func Test_hasEncryptedHeader(t *testing.T) { + t.Parallel() tests := []struct { name string data []byte diff --git a/api/crypto/ecdsa_test.go b/api/crypto/ecdsa_test.go index adc3f9188e..a45e83a061 100644 --- a/api/crypto/ecdsa_test.go +++ b/api/crypto/ecdsa_test.go @@ -7,6 +7,7 @@ import ( ) func TestCreateSignature(t *testing.T) { + t.Parallel() var s = NewECDSAService("secret") privKey, pubKey, err := s.GenerateKeyPair() diff --git a/api/crypto/hash_test.go b/api/crypto/hash_test.go index 5847165d5e..b5e5857131 100644 --- a/api/crypto/hash_test.go +++ b/api/crypto/hash_test.go @@ -7,6 +7,7 @@ import ( ) func TestService_Hash(t *testing.T) { + t.Parallel() var s = Service{} type args struct { @@ -55,6 +56,7 @@ func TestService_Hash(t *testing.T) { } func TestHash(t *testing.T) { + t.Parallel() s := Service{} hash, err := s.Hash("Passw0rd!") diff --git a/api/crypto/tls_test.go b/api/crypto/tls_test.go index cf00b08ebc..52c643a568 100644 --- a/api/crypto/tls_test.go +++ b/api/crypto/tls_test.go @@ -10,6 +10,7 @@ import ( ) func TestCreateTLSConfiguration(t *testing.T) { + t.Parallel() // InsecureSkipVerify = false config := CreateTLSConfiguration(false) require.Equal(t, config.MinVersion, uint16(tls.VersionTLS12)) //nolint:forbidigo @@ -22,6 +23,7 @@ func TestCreateTLSConfiguration(t *testing.T) { } func TestCreateTLSConfigurationFIPS(t *testing.T) { + t.Parallel() fips := true fipsCipherSuites := []uint16{ @@ -42,6 +44,7 @@ func TestCreateTLSConfigurationFIPS(t *testing.T) { } func TestCreateTLSConfigurationFromBytes(t *testing.T) { + t.Parallel() // No TLS config, err := CreateTLSConfigurationFromBytes(false, nil, nil, nil, false, false) require.NoError(t, err) @@ -59,6 +62,7 @@ func TestCreateTLSConfigurationFromBytes(t *testing.T) { } func TestCreateTLSConfigurationFromDisk(t *testing.T) { + t.Parallel() // No TLS config, err := CreateTLSConfigurationFromDisk(portainer.TLSConfiguration{}) require.NoError(t, err) @@ -74,6 +78,7 @@ func TestCreateTLSConfigurationFromDisk(t *testing.T) { } func TestCreateTLSConfigurationFromDiskFIPS(t *testing.T) { + t.Parallel() fips := true // Skipping TLS verifications cannot be done in FIPS mode diff --git a/api/database/boltdb/db_test.go b/api/database/boltdb/db_test.go index 259dce46ca..68232c39b6 100644 --- a/api/database/boltdb/db_test.go +++ b/api/database/boltdb/db_test.go @@ -13,6 +13,7 @@ import ( ) func Test_NeedsEncryptionMigration(t *testing.T) { + t.Parallel() // Test the specific scenarios mentioned in NeedsEncryptionMigration // i.e. @@ -143,6 +144,7 @@ func Test_NeedsEncryptionMigration(t *testing.T) { } func TestDBCompaction(t *testing.T) { + t.Parallel() db := &DbConnection{Path: t.TempDir()} err := db.Open() diff --git a/api/database/boltdb/json_test.go b/api/database/boltdb/json_test.go index 83867aebb3..b0f1b4bd2f 100644 --- a/api/database/boltdb/json_test.go +++ b/api/database/boltdb/json_test.go @@ -27,6 +27,7 @@ func secretToEncryptionKey(passphrase string) []byte { } func Test_MarshalObjectUnencrypted(t *testing.T) { + t.Parallel() is := assert.New(t) uuid := uuid.New() @@ -101,6 +102,7 @@ func Test_MarshalObjectUnencrypted(t *testing.T) { } func Test_UnMarshalObjectUnencrypted(t *testing.T) { + t.Parallel() is := assert.New(t) // Based on actual data entering and what we expect out of the function @@ -142,6 +144,7 @@ func Test_UnMarshalObjectUnencrypted(t *testing.T) { } func Test_ObjectMarshallingEncrypted(t *testing.T) { + t.Parallel() is := assert.New(t) // Based on actual data entering and what we expect out of the function @@ -184,6 +187,7 @@ func Test_ObjectMarshallingEncrypted(t *testing.T) { } func Test_NonceSources(t *testing.T) { + t.Parallel() // ensure that the new go 1.24 NewGCMWithRandomNonce works correctly with // the old way of creating and including the nonce diff --git a/api/database/boltdb/tx_test.go b/api/database/boltdb/tx_test.go index 0b9a86fbc8..ebcc8a07ed 100644 --- a/api/database/boltdb/tx_test.go +++ b/api/database/boltdb/tx_test.go @@ -18,6 +18,7 @@ type testStruct struct { } func TestTxs(t *testing.T) { + t.Parallel() conn := DbConnection{Path: t.TempDir()} err := conn.Open() diff --git a/api/database/database_test.go b/api/database/database_test.go index 11607b8543..340f69c194 100644 --- a/api/database/database_test.go +++ b/api/database/database_test.go @@ -10,6 +10,7 @@ import ( ) func TestNewDatabase(t *testing.T) { + t.Parallel() dbPath := filesystem.JoinPaths(t.TempDir(), "test.db") connection, err := NewDatabase("boltdb", dbPath, nil, false) require.NoError(t, err) diff --git a/api/dataservices/base_test.go b/api/dataservices/base_test.go index 701565fded..da849b4798 100644 --- a/api/dataservices/base_test.go +++ b/api/dataservices/base_test.go @@ -51,6 +51,7 @@ func (m mockConnection) ConvertToKey(v int) []byte { return []byte(strconv.Itoa(v)) } func TestReadAll(t *testing.T) { + t.Parallel() service := BaseDataService[testObject, int]{ Bucket: "testBucket", Connection: mockConnection{store: make(map[int]testObject)}, diff --git a/api/dataservices/customtemplate/customtemplate_test.go b/api/dataservices/customtemplate/customtemplate_test.go index 09f60965c1..b72ece62dc 100644 --- a/api/dataservices/customtemplate/customtemplate_test.go +++ b/api/dataservices/customtemplate/customtemplate_test.go @@ -9,6 +9,7 @@ import ( ) func TestCustomTemplateCreate(t *testing.T) { + t.Parallel() _, ds := datastore.MustNewTestStore(t, false, false) require.NotNil(t, ds) diff --git a/api/dataservices/customtemplate/tx_test.go b/api/dataservices/customtemplate/tx_test.go index 7fd91b1492..8f87cf090d 100644 --- a/api/dataservices/customtemplate/tx_test.go +++ b/api/dataservices/customtemplate/tx_test.go @@ -10,6 +10,7 @@ import ( ) func TestCustomTemplateCreateTx(t *testing.T) { + t.Parallel() _, ds := datastore.MustNewTestStore(t, false, false) require.NotNil(t, ds) diff --git a/api/dataservices/edgestack/edgestack_test.go b/api/dataservices/edgestack/edgestack_test.go index dc2eea304a..82413b0bde 100644 --- a/api/dataservices/edgestack/edgestack_test.go +++ b/api/dataservices/edgestack/edgestack_test.go @@ -11,6 +11,7 @@ import ( ) func TestUpdate(t *testing.T) { + t.Parallel() var conn portainer.Connection = &boltdb.DbConnection{Path: t.TempDir()} err := conn.Open() require.NoError(t, err) diff --git a/api/dataservices/endpointrelation/endpointrelation_test.go b/api/dataservices/endpointrelation/endpointrelation_test.go index 6f5640dbb1..c906150fb0 100644 --- a/api/dataservices/endpointrelation/endpointrelation_test.go +++ b/api/dataservices/endpointrelation/endpointrelation_test.go @@ -13,6 +13,7 @@ import ( ) func TestUpdateRelation(t *testing.T) { + t.Parallel() const endpointID = 1 const edgeStackID1 = 1 const edgeStackID2 = 2 @@ -106,6 +107,7 @@ func TestUpdateRelation(t *testing.T) { } func TestAddEndpointRelationsForEdgeStack(t *testing.T) { + t.Parallel() var conn portainer.Connection = &boltdb.DbConnection{Path: t.TempDir()} err := conn.Open() require.NoError(t, err) @@ -125,6 +127,7 @@ func TestAddEndpointRelationsForEdgeStack(t *testing.T) { } func TestEndpointRelations(t *testing.T) { + t.Parallel() var conn portainer.Connection = &boltdb.DbConnection{Path: t.TempDir()} err := conn.Open() require.NoError(t, err) diff --git a/api/dataservices/pendingactions/pendingactions_test.go b/api/dataservices/pendingactions/pendingactions_test.go index d30ea3cd53..a9583f86a8 100644 --- a/api/dataservices/pendingactions/pendingactions_test.go +++ b/api/dataservices/pendingactions/pendingactions_test.go @@ -10,6 +10,7 @@ import ( ) func TestDeleteByEndpoint(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) // Create Endpoint 1 diff --git a/api/dataservices/stack/tests/stack_test.go b/api/dataservices/stack/tests/stack_test.go index 5793d0c72c..f58c04ed94 100644 --- a/api/dataservices/stack/tests/stack_test.go +++ b/api/dataservices/stack/tests/stack_test.go @@ -27,6 +27,7 @@ type stackBuilder struct { } func TestService_StackByWebhookID(t *testing.T) { + t.Parallel() if testing.Short() { t.Skip("skipping test in short mode. Normally takes ~1s to run.") } @@ -84,6 +85,7 @@ func (b *stackBuilder) createNewStack(webhookID string) portainer.Stack { } func Test_RefreshableStacks(t *testing.T) { + t.Parallel() if testing.Short() { t.Skip("skipping test in short mode. Normally takes ~1s to run.") } diff --git a/api/dataservices/team/tests/team_test.go b/api/dataservices/team/tests/team_test.go index 55d21a981f..fa08a5bb3f 100644 --- a/api/dataservices/team/tests/team_test.go +++ b/api/dataservices/team/tests/team_test.go @@ -31,6 +31,7 @@ func (b *teamBuilder) createNew(name string) *portainer.Team { } func Test_teamByName(t *testing.T) { + t.Parallel() t.Run("When store is empty should return ErrObjectNotFound", func(t *testing.T) { _, store := datastore.MustNewTestStore(t, false, true) diff --git a/api/datastore/backup_test.go b/api/datastore/backup_test.go index 3d72208e91..17f13143fe 100644 --- a/api/datastore/backup_test.go +++ b/api/datastore/backup_test.go @@ -13,6 +13,7 @@ import ( ) func TestStoreCreation(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, true, true) require.NotNil(t, store) @@ -31,6 +32,7 @@ func TestStoreCreation(t *testing.T) { } func TestBackup(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, true, true) backupFileName := store.backupFilename() t.Run("Backup should create "+backupFileName, func(t *testing.T) { @@ -52,6 +54,7 @@ func TestBackup(t *testing.T) { } func TestRestore(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, true, false) t.Run("Basic Restore", func(t *testing.T) { @@ -93,6 +96,7 @@ func TestRestore(t *testing.T) { } func TestBackupDBFile(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, true, false) t.Run("creates backup file without managing connection state", func(t *testing.T) { @@ -122,6 +126,7 @@ func TestBackupDBFile(t *testing.T) { } func TestBackupDBFileUsesCorrectPath(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, true, false) t.Run("backs up unencrypted db when encrypted flag is false", func(t *testing.T) { diff --git a/api/datastore/datastore_test.go b/api/datastore/datastore_test.go index 2037d957c3..51fc4b644a 100644 --- a/api/datastore/datastore_test.go +++ b/api/datastore/datastore_test.go @@ -29,6 +29,7 @@ const ( // TestStoreFull an eventually comprehensive set of tests for the Store. // The idea is what we write to the store, we should read back. func TestStoreFull(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, true, true) testCases := map[string]func(t *testing.T){ diff --git a/api/datastore/migrate_data_test.go b/api/datastore/migrate_data_test.go index fbf4593e1e..232a5a4107 100644 --- a/api/datastore/migrate_data_test.go +++ b/api/datastore/migrate_data_test.go @@ -174,6 +174,7 @@ func TestMigrateData(t *testing.T) { } func TestRollback(t *testing.T) { + t.Parallel() t.Run("Rollback should restore upgrade after backup", func(t *testing.T) { version := "2.11" diff --git a/api/datastore/migrate_dbversion29_test.go b/api/datastore/migrate_dbversion29_test.go index 5a0c12eb73..04c8167ea5 100644 --- a/api/datastore/migrate_dbversion29_test.go +++ b/api/datastore/migrate_dbversion29_test.go @@ -26,6 +26,7 @@ func setup(store *Store) error { } func TestMigrateSettings(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, false, true) err := setup(store) diff --git a/api/datastore/migrate_dbversion33_test.go b/api/datastore/migrate_dbversion33_test.go index f2fe61ad77..633094ae46 100644 --- a/api/datastore/migrate_dbversion33_test.go +++ b/api/datastore/migrate_dbversion33_test.go @@ -12,6 +12,7 @@ import ( ) func TestMigrateStackEntryPoint(t *testing.T) { + t.Parallel() _, store := MustNewTestStore(t, false, true) stackService := store.Stack() diff --git a/api/datastore/migrator/migrate_2_33_test.go b/api/datastore/migrator/migrate_2_33_test.go index 6a93237a29..f0e3443c94 100644 --- a/api/datastore/migrator/migrate_2_33_test.go +++ b/api/datastore/migrator/migrate_2_33_test.go @@ -12,6 +12,7 @@ import ( ) func TestMigrateEdgeGroupEndpointsToRoars_2_33_0Idempotency(t *testing.T) { + t.Parallel() var conn portainer.Connection = &boltdb.DbConnection{Path: t.TempDir()} err := conn.Open() require.NoError(t, err) diff --git a/api/datastore/migrator/migrate_2_40_test.go b/api/datastore/migrator/migrate_2_40_test.go index 6b95febe0a..39dc925467 100644 --- a/api/datastore/migrator/migrate_2_40_test.go +++ b/api/datastore/migrator/migrate_2_40_test.go @@ -15,6 +15,7 @@ import ( ) func TestMigrateRegistryAccessSASecrets_2_40_0(t *testing.T) { + t.Parallel() var conn portainer.Connection = &boltdb.DbConnection{Path: t.TempDir()} err := conn.Open() require.NoError(t, err) diff --git a/api/datastore/pendingactions_test.go b/api/datastore/pendingactions_test.go index 92407d6126..3c4d40e462 100644 --- a/api/datastore/pendingactions_test.go +++ b/api/datastore/pendingactions_test.go @@ -14,6 +14,7 @@ type cleanNAPWithOverridePolicies struct { } func Test_ConvertCleanNAPWithOverridePoliciesPayload(t *testing.T) { + t.Parallel() t.Run("test ConvertCleanNAPWithOverridePoliciesPayload", func(t *testing.T) { _, store := MustNewTestStore(t, true, false) diff --git a/api/datastore/postinit/migrate_post_init_test.go b/api/datastore/postinit/migrate_post_init_test.go index e5305fe9e5..69e35877a6 100644 --- a/api/datastore/postinit/migrate_post_init_test.go +++ b/api/datastore/postinit/migrate_post_init_test.go @@ -18,6 +18,7 @@ import ( ) func TestMigrateGPUs(t *testing.T) { + t.Parallel() srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if strings.HasSuffix(r.URL.Path, "/containers/json") { containerSummary := []container.Summary{{ID: "container1"}} @@ -79,6 +80,7 @@ func TestMigrateGPUs(t *testing.T) { } func TestPostInitMigrate_PendingActionsCreated(t *testing.T) { + t.Parallel() tests := []struct { name string existingPendingActions []*portainer.PendingAction diff --git a/api/docker/client/client_test.go b/api/docker/client/client_test.go index ff0de82d10..cf1f1bd9e9 100644 --- a/api/docker/client/client_test.go +++ b/api/docker/client/client_test.go @@ -10,6 +10,7 @@ import ( ) func TestHttpClient(t *testing.T) { + t.Parallel() fips.InitFIPS(false) // Valid TLS configuration diff --git a/api/docker/container_test.go b/api/docker/container_test.go index e3d9e0bd85..58aa60507d 100644 --- a/api/docker/container_test.go +++ b/api/docker/container_test.go @@ -8,6 +8,7 @@ import ( ) func TestApplyVersionConstraint(t *testing.T) { + t.Parallel() initialNet := network.NetworkingConfig{ EndpointsConfig: map[string]*network.EndpointSettings{ "key1": { diff --git a/api/docker/images/digest_test.go b/api/docker/images/digest_test.go index 52e624caa2..dc1a4e0c21 100644 --- a/api/docker/images/digest_test.go +++ b/api/docker/images/digest_test.go @@ -8,6 +8,7 @@ import ( ) func TestParseLocalImage(t *testing.T) { + t.Parallel() // Test with a regular image img, err := ParseLocalImage(image.InspectResponse{ diff --git a/api/docker/images/image_test.go b/api/docker/images/image_test.go index 22ba27a2eb..46bdd44653 100644 --- a/api/docker/images/image_test.go +++ b/api/docker/images/image_test.go @@ -8,6 +8,7 @@ import ( ) func TestImageParser(t *testing.T) { + t.Parallel() is := assert.New(t) // portainer/portainer-ee @@ -62,6 +63,7 @@ func TestImageParser(t *testing.T) { } func TestUpdateParsedImage(t *testing.T) { + t.Parallel() is := assert.New(t) // gcr.io/k8s-minikube/kicbase:v0.0.30@sha256:02c921df998f95e849058af14de7045efc3954d90320967418a0d1f182bbc0b2 diff --git a/api/docker/images/registry_test.go b/api/docker/images/registry_test.go index 6b0a1bd65f..ad32070a82 100644 --- a/api/docker/images/registry_test.go +++ b/api/docker/images/registry_test.go @@ -10,6 +10,7 @@ import ( ) func TestFindBestMatchNeedAuthRegistry(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("", func(t *testing.T) { diff --git a/api/docker/stats/container_stats_test.go b/api/docker/stats/container_stats_test.go index e25cec395f..1a034eda0f 100644 --- a/api/docker/stats/container_stats_test.go +++ b/api/docker/stats/container_stats_test.go @@ -25,6 +25,7 @@ func (m *MockDockerClient) ContainerInspect(ctx context.Context, containerID str } func TestCalculateContainerStats(t *testing.T) { + t.Parallel() mockClient := new(MockDockerClient) // Test containers - using enough containers to test concurrent processing @@ -105,6 +106,7 @@ func TestCalculateContainerStats(t *testing.T) { } func TestCalculateContainerStatsAllErrors(t *testing.T) { + t.Parallel() mockClient := new(MockDockerClient) // Test containers @@ -140,6 +142,7 @@ func TestCalculateContainerStatsAllErrors(t *testing.T) { } func TestGetContainerStatus(t *testing.T) { + t.Parallel() testCases := []struct { name string state *container.State @@ -232,6 +235,7 @@ func TestGetContainerStatus(t *testing.T) { } func TestCalculateContainerStatsForSwarm(t *testing.T) { + t.Parallel() containers := []container.Summary{ {State: "running"}, {State: "running", Status: "Up 5 minutes (healthy)"}, diff --git a/api/exec/compose_stack_integration_test.go b/api/exec/compose_stack_integration_test.go index 39e3ed97e6..bbbc7bbb73 100644 --- a/api/exec/compose_stack_integration_test.go +++ b/api/exec/compose_stack_integration_test.go @@ -41,6 +41,7 @@ func setup(t *testing.T) (*portainer.Stack, *portainer.Endpoint) { } func Test_UpAndDown(t *testing.T) { + t.Parallel() testhelpers.IntegrationTest(t) stack, endpoint := setup(t) diff --git a/api/exec/compose_stack_test.go b/api/exec/compose_stack_test.go index f52ef72493..6c994fe931 100644 --- a/api/exec/compose_stack_test.go +++ b/api/exec/compose_stack_test.go @@ -14,6 +14,7 @@ import ( ) func Test_createEnvFile(t *testing.T) { + t.Parallel() dir := t.TempDir() tests := []struct { @@ -70,6 +71,7 @@ func Test_createEnvFile(t *testing.T) { } func Test_createEnvFile_mergesDefultAndInplaceEnvVars(t *testing.T) { + t.Parallel() dir := t.TempDir() err := os.WriteFile(path.Join(dir, ".env"), []byte("VAR1=VAL1\nVAR2=VAL2\n"), 0600) require.NoError(t, err) diff --git a/api/exec/kubernetes_deploy_test.go b/api/exec/kubernetes_deploy_test.go index ce4534098b..8fb357e8bb 100644 --- a/api/exec/kubernetes_deploy_test.go +++ b/api/exec/kubernetes_deploy_test.go @@ -57,6 +57,7 @@ func testExecuteKubectlOperation(client *mockKubectlClient, operation string, ma } func TestExecuteKubectlOperation_Apply_Success(t *testing.T) { + t.Parallel() called := false mockClient := &mockKubectlClient{ applyFunc: func(ctx context.Context, files []string) error { @@ -74,6 +75,7 @@ func TestExecuteKubectlOperation_Apply_Success(t *testing.T) { } func TestExecuteKubectlOperation_Apply_Error(t *testing.T) { + t.Parallel() expectedErr := errors.New("kubectl apply failed") called := false mockClient := &mockKubectlClient{ @@ -93,6 +95,7 @@ func TestExecuteKubectlOperation_Apply_Error(t *testing.T) { } func TestExecuteKubectlOperation_Delete_Success(t *testing.T) { + t.Parallel() called := false mockClient := &mockKubectlClient{ deleteFunc: func(ctx context.Context, files []string) error { @@ -110,6 +113,7 @@ func TestExecuteKubectlOperation_Delete_Success(t *testing.T) { } func TestExecuteKubectlOperation_Delete_Error(t *testing.T) { + t.Parallel() expectedErr := errors.New("kubectl delete failed") called := false mockClient := &mockKubectlClient{ @@ -129,6 +133,7 @@ func TestExecuteKubectlOperation_Delete_Error(t *testing.T) { } func TestExecuteKubectlOperation_RolloutRestart_Success(t *testing.T) { + t.Parallel() called := false mockClient := &mockKubectlClient{ rolloutRestartFunc: func(ctx context.Context, resources []string) error { @@ -146,6 +151,7 @@ func TestExecuteKubectlOperation_RolloutRestart_Success(t *testing.T) { } func TestExecuteKubectlOperation_RolloutRestart_Error(t *testing.T) { + t.Parallel() expectedErr := errors.New("kubectl rollout restart failed") called := false mockClient := &mockKubectlClient{ @@ -165,6 +171,7 @@ func TestExecuteKubectlOperation_RolloutRestart_Error(t *testing.T) { } func TestExecuteKubectlOperation_UnsupportedOperation(t *testing.T) { + t.Parallel() mockClient := &mockKubectlClient{} err := testExecuteKubectlOperation(mockClient, "unsupported", []string{}) diff --git a/api/exec/swarm_stack_test.go b/api/exec/swarm_stack_test.go index 3316199705..643e24a330 100644 --- a/api/exec/swarm_stack_test.go +++ b/api/exec/swarm_stack_test.go @@ -9,6 +9,7 @@ import ( ) func TestConfigFilePaths(t *testing.T) { + t.Parallel() args := []string{"stack", "deploy", "--with-registry-auth"} filePaths := []string{"dir/file", "dir/file-two", "dir/file-three"} expected := []string{"stack", "deploy", "--with-registry-auth", "--compose-file", "dir/file", "--compose-file", "dir/file-two", "--compose-file", "dir/file-three"} @@ -17,6 +18,7 @@ func TestConfigFilePaths(t *testing.T) { } func TestPrepareDockerCommandAndArgs(t *testing.T) { + t.Parallel() binaryPath := "/test/dist" configPath := "/test/config" manager := &SwarmStackManager{ diff --git a/api/filesystem/copy_test.go b/api/filesystem/copy_test.go index a02c572c41..92b94ed012 100644 --- a/api/filesystem/copy_test.go +++ b/api/filesystem/copy_test.go @@ -11,12 +11,14 @@ import ( ) func Test_copyFile_returnsError_whenSourceDoesNotExist(t *testing.T) { + t.Parallel() tmpdir := t.TempDir() err := copyFile("does-not-exist", tmpdir) require.Error(t, err) } func Test_copyFile_shouldMakeAbackup(t *testing.T) { + t.Parallel() tmpdir := t.TempDir() content := []byte("content") @@ -32,6 +34,7 @@ func Test_copyFile_shouldMakeAbackup(t *testing.T) { } func Test_CopyDir_shouldCopyAllFilesAndDirectories(t *testing.T) { + t.Parallel() destination := t.TempDir() err := CopyDir("./testdata/copy_test", destination, true) require.NoError(t, err) @@ -42,6 +45,7 @@ func Test_CopyDir_shouldCopyAllFilesAndDirectories(t *testing.T) { } func Test_CopyDir_shouldCopyOnlyDirContents(t *testing.T) { + t.Parallel() destination := t.TempDir() err := CopyDir("./testdata/copy_test", destination, false) require.NoError(t, err) @@ -52,6 +56,7 @@ func Test_CopyDir_shouldCopyOnlyDirContents(t *testing.T) { } func Test_CopyPath_shouldSkipWhenNotExist(t *testing.T) { + t.Parallel() tmpdir := t.TempDir() err := CopyPath("does-not-exists", tmpdir) require.NoError(t, err) @@ -60,6 +65,7 @@ func Test_CopyPath_shouldSkipWhenNotExist(t *testing.T) { } func Test_CopyPath_shouldCopyFile(t *testing.T) { + t.Parallel() tmpdir := t.TempDir() content := []byte("content") @@ -78,6 +84,7 @@ func Test_CopyPath_shouldCopyFile(t *testing.T) { } func Test_CopyPath_shouldCopyDir(t *testing.T) { + t.Parallel() destination := t.TempDir() err := CopyPath("./testdata/copy_test", destination) require.NoError(t, err) @@ -88,6 +95,7 @@ func Test_CopyPath_shouldCopyDir(t *testing.T) { } func TestCopyPathPanic(t *testing.T) { + t.Parallel() dir := t.TempDir() p := filepath.Join(dir, "myfile") diff --git a/api/filesystem/filesystem_fileexists_test.go b/api/filesystem/filesystem_fileexists_test.go index 732aaa3fe2..f559c8407c 100644 --- a/api/filesystem/filesystem_fileexists_test.go +++ b/api/filesystem/filesystem_fileexists_test.go @@ -12,20 +12,24 @@ import ( ) func Test_fileSystemService_FileExists_whenFileExistsShouldReturnTrue(t *testing.T) { + t.Parallel() service := createService(t) testHelperFileExists_fileExists(t, service.FileExists) } func Test_fileSystemService_FileExists_whenFileNotExistsShouldReturnFalse(t *testing.T) { + t.Parallel() service := createService(t) testHelperFileExists_fileNotExists(t, service.FileExists) } func Test_FileExists_whenFileExistsShouldReturnTrue(t *testing.T) { + t.Parallel() testHelperFileExists_fileExists(t, FileExists) } func Test_FileExists_whenFileNotExistsShouldReturnFalse(t *testing.T) { + t.Parallel() testHelperFileExists_fileNotExists(t, FileExists) } diff --git a/api/filesystem/filesystem_linux_test.go b/api/filesystem/filesystem_linux_test.go index dad55c951f..58c77bd187 100644 --- a/api/filesystem/filesystem_linux_test.go +++ b/api/filesystem/filesystem_linux_test.go @@ -3,6 +3,7 @@ package filesystem import "testing" func TestJoinPaths(t *testing.T) { + t.Parallel() var ts = []struct { trusted string untrusted string diff --git a/api/filesystem/filesystem_move_test.go b/api/filesystem/filesystem_move_test.go index 6998715b0f..0c440f0f75 100644 --- a/api/filesystem/filesystem_move_test.go +++ b/api/filesystem/filesystem_move_test.go @@ -12,6 +12,7 @@ import ( var content = []byte("content") func Test_movePath_shouldFailIfSourceDirDoesNotExist(t *testing.T) { + t.Parallel() sourceDir := "missing" destinationDir := t.TempDir() file1 := addFile(t, destinationDir, "dir", "file") @@ -24,6 +25,7 @@ func Test_movePath_shouldFailIfSourceDirDoesNotExist(t *testing.T) { } func Test_movePath_shouldFailIfDestinationDirExists(t *testing.T) { + t.Parallel() sourceDir := t.TempDir() file1 := addFile(t, sourceDir, "dir", "file") file2 := addFile(t, sourceDir, "file") @@ -40,6 +42,7 @@ func Test_movePath_shouldFailIfDestinationDirExists(t *testing.T) { } func Test_movePath_succesIfOverwriteSetWhenDestinationDirExists(t *testing.T) { + t.Parallel() sourceDir := t.TempDir() file1 := addFile(t, sourceDir, "dir", "file") file2 := addFile(t, sourceDir, "file") @@ -56,6 +59,7 @@ func Test_movePath_succesIfOverwriteSetWhenDestinationDirExists(t *testing.T) { } func Test_movePath_successWhenSourceExistsAndDestinationIsMissing(t *testing.T) { + t.Parallel() tmp := t.TempDir() sourceDir := path.Join(tmp, "source") err := os.Mkdir(sourceDir, 0766) diff --git a/api/filesystem/filesystem_windows_test.go b/api/filesystem/filesystem_windows_test.go index 70187dd59f..06f83780f5 100644 --- a/api/filesystem/filesystem_windows_test.go +++ b/api/filesystem/filesystem_windows_test.go @@ -3,6 +3,7 @@ package filesystem import "testing" func TestJoinPaths(t *testing.T) { + t.Parallel() var ts = []struct { trusted string untrusted string diff --git a/api/filesystem/serialize_per_dev_configs_test.go b/api/filesystem/serialize_per_dev_configs_test.go index 61136d457c..84e739a62c 100644 --- a/api/filesystem/serialize_per_dev_configs_test.go +++ b/api/filesystem/serialize_per_dev_configs_test.go @@ -10,6 +10,7 @@ import ( ) func TestMultiFilterDirForPerDevConfigs(t *testing.T) { + t.Parallel() f := func(dirEntries []DirEntry, configPath string, multiFilterArgs MultiFilterArgs, wantDirEntries []DirEntry) { t.Helper() @@ -80,6 +81,7 @@ func TestMultiFilterDirForPerDevConfigs(t *testing.T) { } func TestMultiFilterDirForPerDevConfigsWithDefaults(t *testing.T) { + t.Parallel() f := func(dirEntries []DirEntry, configPath string, multiFilterArgs MultiFilterArgs, defaultFilenames []string, wantDirEntries []DirEntry) { t.Helper() @@ -180,6 +182,7 @@ func TestMultiFilterDirForPerDevConfigsWithDefaults(t *testing.T) { } func TestMultiFilterDirForPerDevConfigsEnvFiles(t *testing.T) { + t.Parallel() f := func(dirEntries []DirEntry, configPath string, multiFilterArgs MultiFilterArgs, wantEnvFiles []string) { t.Helper() @@ -204,6 +207,7 @@ func TestMultiFilterDirForPerDevConfigsEnvFiles(t *testing.T) { } func TestIsInConfigDir(t *testing.T) { + t.Parallel() f := func(dirEntry DirEntry, configPath string, expect bool) { t.Helper() @@ -225,6 +229,7 @@ func TestIsInConfigDir(t *testing.T) { } func TestShouldIncludeDir(t *testing.T) { + t.Parallel() f := func(dirEntry DirEntry, deviceName, configPath string, expect bool) { t.Helper() diff --git a/api/filesystem/write_test.go b/api/filesystem/write_test.go index 7e839a2485..1877cca2a0 100644 --- a/api/filesystem/write_test.go +++ b/api/filesystem/write_test.go @@ -10,6 +10,7 @@ import ( ) func Test_WriteFile_CanStoreContentInANewFile(t *testing.T) { + t.Parallel() tmpDir := t.TempDir() tmpFilePath := path.Join(tmpDir, "dummy") @@ -22,6 +23,7 @@ func Test_WriteFile_CanStoreContentInANewFile(t *testing.T) { } func Test_WriteFile_CanOverwriteExistingFile(t *testing.T) { + t.Parallel() tmpDir := t.TempDir() tmpFilePath := path.Join(tmpDir, "dummy") @@ -37,6 +39,7 @@ func Test_WriteFile_CanOverwriteExistingFile(t *testing.T) { } func Test_WriteFile_CanWriteANestedPath(t *testing.T) { + t.Parallel() tmpDir := t.TempDir() tmpFilePath := path.Join(tmpDir, "dir", "sub-dir", "dummy") diff --git a/api/git/azure_integration_test.go b/api/git/azure_integration_test.go index 727dfaa478..6b0fcec6b5 100644 --- a/api/git/azure_integration_test.go +++ b/api/git/azure_integration_test.go @@ -17,6 +17,7 @@ import ( const privateAzureRepoURL = "https://portainer.visualstudio.com/gitops-test/_git/gitops-test" func TestService_ClonePublicRepository_Azure(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) pat := getRequiredValue(t, "AZURE_DEVOPS_PAT") @@ -74,6 +75,7 @@ func TestService_ClonePublicRepository_Azure(t *testing.T) { } func TestService_ClonePrivateRepository_Azure(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) pat := getRequiredValue(t, "AZURE_DEVOPS_PAT") @@ -95,6 +97,7 @@ func TestService_ClonePrivateRepository_Azure(t *testing.T) { } func TestService_LatestCommitID_Azure(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) pat := getRequiredValue(t, "AZURE_DEVOPS_PAT") @@ -113,6 +116,7 @@ func TestService_LatestCommitID_Azure(t *testing.T) { } func TestService_ListRefs_Azure(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "AZURE_DEVOPS_PAT") @@ -132,6 +136,7 @@ func TestService_ListRefs_Azure(t *testing.T) { } func TestService_ListRefs_Azure_Concurrently(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "AZURE_DEVOPS_PAT") @@ -149,6 +154,7 @@ func TestService_ListRefs_Azure_Concurrently(t *testing.T) { } func TestService_ListFiles_Azure(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) type args struct { @@ -303,6 +309,7 @@ func TestService_ListFiles_Azure(t *testing.T) { } func TestService_ListFiles_Azure_Concurrently(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "AZURE_DEVOPS_PAT") diff --git a/api/git/azure_test.go b/api/git/azure_test.go index 2cfcd2faec..b3468c7712 100644 --- a/api/git/azure_test.go +++ b/api/git/azure_test.go @@ -18,6 +18,7 @@ import ( ) func Test_buildDownloadUrl(t *testing.T) { + t.Parallel() a := NewAzureClient() u, err := a.buildDownloadUrl(&azureOptions{ organisation: "organisation", @@ -39,6 +40,7 @@ func Test_buildDownloadUrl(t *testing.T) { } func Test_buildRootItemUrl(t *testing.T) { + t.Parallel() a := NewAzureClient() u, err := a.buildRootItemUrl(&azureOptions{ organisation: "organisation", @@ -56,6 +58,7 @@ func Test_buildRootItemUrl(t *testing.T) { } func Test_buildRefsUrl(t *testing.T) { + t.Parallel() a := NewAzureClient() u, err := a.buildRefsUrl(&azureOptions{ organisation: "organisation", @@ -73,6 +76,7 @@ func Test_buildRefsUrl(t *testing.T) { } func Test_buildTreeUrl(t *testing.T) { + t.Parallel() a := NewAzureClient() u, err := a.buildTreeUrl(&azureOptions{ organisation: "organisation", @@ -90,6 +94,7 @@ func Test_buildTreeUrl(t *testing.T) { } func Test_parseAzureUrl(t *testing.T) { + t.Parallel() type args struct { url string } @@ -205,6 +210,7 @@ func Test_parseAzureUrl(t *testing.T) { } func Test_isAzureUrl(t *testing.T) { + t.Parallel() type args struct { s string } @@ -243,6 +249,7 @@ func Test_isAzureUrl(t *testing.T) { } func Test_azureDownloader_downloadZipFromAzureDevOps(t *testing.T) { + t.Parallel() fips.InitFIPS(false) type args struct { @@ -319,6 +326,7 @@ func Test_azureDownloader_downloadZipFromAzureDevOps(t *testing.T) { } func Test_azureDownloader_latestCommitID(t *testing.T) { + t.Parallel() fips.InitFIPS(false) server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -399,6 +407,7 @@ func (t *testRepoManager) ListFiles(_ context.Context, _ bool, _ *git.CloneOptio } func Test_cloneRepository_azure(t *testing.T) { + t.Parallel() tests := []struct { name string url string @@ -438,6 +447,7 @@ func Test_cloneRepository_azure(t *testing.T) { } func Test_listRefs_azure(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) client := NewAzureClient() @@ -532,6 +542,7 @@ func Test_listRefs_azure(t *testing.T) { } func Test_listFiles_azure(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) client := NewAzureClient() diff --git a/api/git/git_integration_test.go b/api/git/git_integration_test.go index 17a7c81ea8..75fdc950ac 100644 --- a/api/git/git_integration_test.go +++ b/api/git/git_integration_test.go @@ -18,6 +18,7 @@ const ( ) func TestService_ClonePrivateRepository_GitHub(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "GITHUB_PAT") @@ -41,6 +42,7 @@ func TestService_ClonePrivateRepository_GitHub(t *testing.T) { } func TestService_LatestCommitID_GitHub(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "GITHUB_PAT") @@ -61,6 +63,7 @@ func TestService_LatestCommitID_GitHub(t *testing.T) { } func TestService_ListRefs_GitHub(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "GITHUB_PAT") @@ -74,6 +77,7 @@ func TestService_ListRefs_GitHub(t *testing.T) { } func TestService_ListRefs_Github_Concurrently(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "GITHUB_PAT") @@ -92,6 +96,7 @@ func TestService_ListRefs_Github_Concurrently(t *testing.T) { } func TestService_ListFiles_GitHub(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) type args struct { @@ -244,6 +249,7 @@ func TestService_ListFiles_GitHub(t *testing.T) { } func TestService_ListFiles_Github_Concurrently(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) repositoryUrl := privateGitRepoURL @@ -282,6 +288,7 @@ func TestService_ListFiles_Github_Concurrently(t *testing.T) { } func TestService_purgeCache_Github(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) repositoryUrl := privateGitRepoURL @@ -314,6 +321,7 @@ func TestService_purgeCache_Github(t *testing.T) { } func TestService_purgeCacheByTTL_Github(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) timeout := 100 * time.Millisecond @@ -347,6 +355,7 @@ func TestService_purgeCacheByTTL_Github(t *testing.T) { } func TestService_HardRefresh_ListRefs_GitHub(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "GITHUB_PAT") @@ -365,6 +374,7 @@ func TestService_HardRefresh_ListRefs_GitHub(t *testing.T) { } func TestService_HardRefresh_ListRefs_And_RemoveAllCaches_GitHub(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "GITHUB_PAT") @@ -419,6 +429,7 @@ func TestService_HardRefresh_ListRefs_And_RemoveAllCaches_GitHub(t *testing.T) { } func TestService_HardRefresh_ListFiles_GitHub(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) service := newService(t.Context(), 2, 0) @@ -456,6 +467,7 @@ func TestService_HardRefresh_ListFiles_GitHub(t *testing.T) { } func TestService_CloneRepository_TokenAuth(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) service := newService(t.Context(), 2, 0) diff --git a/api/git/git_test.go b/api/git/git_test.go index 529be48e66..3aa2b94358 100644 --- a/api/git/git_test.go +++ b/api/git/git_test.go @@ -34,6 +34,7 @@ func setup(t *testing.T) string { } func Test_checkGitError(t *testing.T) { + t.Parallel() tests := []struct { name string err error @@ -70,6 +71,7 @@ func Test_checkGitError(t *testing.T) { } func Test_ClonePublicRepository_Shallow(t *testing.T) { + t.Parallel() service := Service{git: NewGitClient(true)} // no need for http client since the test access the repo via file system. repositoryURL := setup(t) referenceName := "refs/heads/main" @@ -82,6 +84,7 @@ func Test_ClonePublicRepository_Shallow(t *testing.T) { } func Test_ClonePublicRepository_NoGitDirectory(t *testing.T) { + t.Parallel() service := Service{git: NewGitClient(false)} // no need for http client since the test access the repo via file system. repositoryURL := setup(t) referenceName := "refs/heads/main" @@ -94,6 +97,7 @@ func Test_ClonePublicRepository_NoGitDirectory(t *testing.T) { } func Test_latestCommitID(t *testing.T) { + t.Parallel() service := Service{git: NewGitClient(true)} // no need for http client since the test access the repo via file system. repositoryURL := setup(t) @@ -106,6 +110,7 @@ func Test_latestCommitID(t *testing.T) { } func Test_ListRefs(t *testing.T) { + t.Parallel() service := Service{git: NewGitClient(true)} repositoryURL := setup(t) @@ -117,6 +122,7 @@ func Test_ListRefs(t *testing.T) { } func Test_ListFiles(t *testing.T) { + t.Parallel() service := Service{git: NewGitClient(true)} repositoryURL := setup(t) @@ -161,6 +167,7 @@ func getCommitHistoryLength(t *testing.T, dir string) int { } func Test_listRefsPrivateRepository(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) accessToken := getRequiredValue(t, "GITHUB_PAT") @@ -255,6 +262,7 @@ func Test_listRefsPrivateRepository(t *testing.T) { } func Test_listFilesPrivateRepository(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) client := NewGitClient(false) diff --git a/api/git/update/validate_test.go b/api/git/update/validate_test.go index ec1654d2d1..1628626dec 100644 --- a/api/git/update/validate_test.go +++ b/api/git/update/validate_test.go @@ -8,6 +8,7 @@ import ( ) func Test_ValidateAutoUpdate(t *testing.T) { + t.Parallel() tests := []struct { name string value *portainer.AutoUpdateSettings diff --git a/api/hostmanagement/openamt/openamt_test.go b/api/hostmanagement/openamt/openamt_test.go index d3c006018b..5ed684646a 100644 --- a/api/hostmanagement/openamt/openamt_test.go +++ b/api/hostmanagement/openamt/openamt_test.go @@ -10,6 +10,7 @@ import ( ) func TestNewService(t *testing.T) { + t.Parallel() fips.InitFIPS(false) service := NewService(true) diff --git a/api/http/client/client_test.go b/api/http/client/client_test.go index 728ece8f2a..be328e4846 100644 --- a/api/http/client/client_test.go +++ b/api/http/client/client_test.go @@ -12,6 +12,7 @@ import ( ) func TestExecutePingOperationFailure(t *testing.T) { + t.Parallel() fips.InitFIPS(false) host := "http://localhost:1" @@ -36,6 +37,7 @@ func TestExecutePingOperationFailure(t *testing.T) { } func TestPingOperation(t *testing.T) { + t.Parallel() srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Add(portainer.PortainerAgentHeader, "1") })) diff --git a/api/http/handler/auth/logout_test.go b/api/http/handler/auth/logout_test.go index 3a6fa54a3b..f13c238538 100644 --- a/api/http/handler/auth/logout_test.go +++ b/api/http/handler/auth/logout_test.go @@ -31,6 +31,7 @@ func (*mockBouncer) CookieAuthLookup(r *http.Request) (*portainer.TokenData, err } func TestLogout(t *testing.T) { + t.Parallel() h := NewHandler(NewMockBouncer(), nil, nil, nil) h.KubernetesTokenCacheManager = kubernetes.NewTokenCacheManager() k, err := cli.NewClientFactory(nil, nil, nil, "", "", "") @@ -45,6 +46,7 @@ func TestLogout(t *testing.T) { } func TestLogoutNoPanic(t *testing.T) { + t.Parallel() h := NewHandler(testhelpers.NewTestRequestBouncer(), nil, nil, nil) rr := httptest.NewRecorder() diff --git a/api/http/handler/customtemplates/customtemplate_file_test.go b/api/http/handler/customtemplates/customtemplate_file_test.go index 397d663fb8..a6697c5b5f 100644 --- a/api/http/handler/customtemplates/customtemplate_file_test.go +++ b/api/http/handler/customtemplates/customtemplate_file_test.go @@ -18,6 +18,7 @@ import ( ) func TestCustomTemplateFile(t *testing.T) { + t.Parallel() _, ds := datastore.MustNewTestStore(t, true, false) require.NotNil(t, ds) diff --git a/api/http/handler/customtemplates/customtemplate_git_fetch_test.go b/api/http/handler/customtemplates/customtemplate_git_fetch_test.go index d138e44879..fb3f2bca5a 100644 --- a/api/http/handler/customtemplates/customtemplate_git_fetch_test.go +++ b/api/http/handler/customtemplates/customtemplate_git_fetch_test.go @@ -155,6 +155,7 @@ func singleAPIRequest(h *Handler, jwt string, expect string) error { } func Test_customTemplateGitFetch(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/http/handler/customtemplates/customtemplate_inspect_test.go b/api/http/handler/customtemplates/customtemplate_inspect_test.go index 9c7f47f6e7..1bd4d153a0 100644 --- a/api/http/handler/customtemplates/customtemplate_inspect_test.go +++ b/api/http/handler/customtemplates/customtemplate_inspect_test.go @@ -18,6 +18,7 @@ import ( ) func TestInspectHandler(t *testing.T) { + t.Parallel() _, ds := datastore.MustNewTestStore(t, true, false) require.NotNil(t, ds) diff --git a/api/http/handler/docker/utils/get_stacks_test.go b/api/http/handler/docker/utils/get_stacks_test.go index 7a319a55b1..8a01ee9cb4 100644 --- a/api/http/handler/docker/utils/get_stacks_test.go +++ b/api/http/handler/docker/utils/get_stacks_test.go @@ -16,6 +16,7 @@ import ( ) func TestHandler_getDockerStacks(t *testing.T) { + t.Parallel() is := require.New(t) environment := &portainer.Endpoint{ diff --git a/api/http/handler/edgegroups/edgegroup_create_test.go b/api/http/handler/edgegroups/edgegroup_create_test.go index 54a8190c63..e9875baf74 100644 --- a/api/http/handler/edgegroups/edgegroup_create_test.go +++ b/api/http/handler/edgegroups/edgegroup_create_test.go @@ -16,6 +16,7 @@ import ( ) func TestEdgeGroupCreateHandler(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) @@ -62,6 +63,7 @@ func TestEdgeGroupCreateHandler(t *testing.T) { } func TestEdgeGroupCreatePanic(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) diff --git a/api/http/handler/edgegroups/edgegroup_inspect_test.go b/api/http/handler/edgegroups/edgegroup_inspect_test.go index b25f074c68..c2baec0a18 100644 --- a/api/http/handler/edgegroups/edgegroup_inspect_test.go +++ b/api/http/handler/edgegroups/edgegroup_inspect_test.go @@ -17,6 +17,7 @@ import ( ) func TestEdgeGroupInspectHandler(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) @@ -70,6 +71,7 @@ func TestEdgeGroupInspectHandler(t *testing.T) { } func TestEmptyEdgeGroupInspectHandler(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) @@ -109,6 +111,7 @@ func TestEmptyEdgeGroupInspectHandler(t *testing.T) { } func TestDynamicEdgeGroupInspectHandler(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) @@ -176,6 +179,7 @@ func TestDynamicEdgeGroupInspectHandler(t *testing.T) { } func TestEdgeGroupInspectPanic(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) diff --git a/api/http/handler/edgegroups/edgegroup_list_test.go b/api/http/handler/edgegroups/edgegroup_list_test.go index cf3cb54b6d..c9c863bbb7 100644 --- a/api/http/handler/edgegroups/edgegroup_list_test.go +++ b/api/http/handler/edgegroups/edgegroup_list_test.go @@ -17,6 +17,7 @@ import ( ) func Test_getEndpointTypes(t *testing.T) { + t.Parallel() endpoints := []portainer.Endpoint{ {ID: 1, Type: portainer.DockerEnvironment}, {ID: 2, Type: portainer.AgentOnDockerEnvironment}, @@ -54,6 +55,7 @@ func Test_getEndpointTypes(t *testing.T) { } func Test_getEndpointTypes_failWhenEndpointDontExist(t *testing.T) { + t.Parallel() datastore := testhelpers.NewDatastore(testhelpers.WithEndpoints([]portainer.Endpoint{})) _, err := getEndpointTypes(datastore, roar.FromSlice([]portainer.EndpointID{1})) @@ -61,6 +63,7 @@ func Test_getEndpointTypes_failWhenEndpointDontExist(t *testing.T) { } func TestEdgeGroupListHandler(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) diff --git a/api/http/handler/edgegroups/edgegroup_update_test.go b/api/http/handler/edgegroups/edgegroup_update_test.go index 9f2ac7a7cb..2b50a64b0d 100644 --- a/api/http/handler/edgegroups/edgegroup_update_test.go +++ b/api/http/handler/edgegroups/edgegroup_update_test.go @@ -17,6 +17,7 @@ import ( ) func TestEdgeGroupUpdateHandler(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) @@ -70,6 +71,7 @@ func TestEdgeGroupUpdateHandler(t *testing.T) { } func TestEdgeGroupUpdatePanic(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) handler := NewHandler(testhelpers.NewTestRequestBouncer()) diff --git a/api/http/handler/edgejobs/edgejob_create_test.go b/api/http/handler/edgejobs/edgejob_create_test.go index db9d69ff18..e0aee3a274 100644 --- a/api/http/handler/edgejobs/edgejob_create_test.go +++ b/api/http/handler/edgejobs/edgejob_create_test.go @@ -70,6 +70,7 @@ func initStore(t *testing.T) *datastore.Store { } func Test_edgeJobCreate_StringMethod_Success(t *testing.T) { + t.Parallel() store := initStore(t) fileService := &mockFileService{} @@ -113,6 +114,7 @@ func Test_edgeJobCreate_StringMethod_Success(t *testing.T) { } func Test_edgeJobCreate_FileMethod_Success(t *testing.T) { + t.Parallel() store := initStore(t) fileService := &mockFileService{} diff --git a/api/http/handler/edgejobs/edgejob_tasks_list_test.go b/api/http/handler/edgejobs/edgejob_tasks_list_test.go index 9e962d4bee..3c729f0ca1 100644 --- a/api/http/handler/edgejobs/edgejob_tasks_list_test.go +++ b/api/http/handler/edgejobs/edgejob_tasks_list_test.go @@ -17,6 +17,7 @@ import ( ) func Test_EdgeJobTasksListHandler(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, false) handler := NewHandler(testhelpers.NewTestRequestBouncer()) diff --git a/api/http/handler/edgestacks/edgestack_create_test.go b/api/http/handler/edgestacks/edgestack_create_test.go index 70252c25d6..b9c46f9684 100644 --- a/api/http/handler/edgestacks/edgestack_create_test.go +++ b/api/http/handler/edgestacks/edgestack_create_test.go @@ -16,6 +16,7 @@ import ( // Create func TestCreateAndInspect(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) // Create Endpoint, EdgeGroup and EndpointRelation @@ -90,6 +91,7 @@ func TestCreateAndInspect(t *testing.T) { } func TestCreateWithInvalidPayload(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) endpoint := createEndpoint(t, handler.DataStore) diff --git a/api/http/handler/edgestacks/edgestack_delete_test.go b/api/http/handler/edgestacks/edgestack_delete_test.go index ca334c7ce6..b2ffe1136d 100644 --- a/api/http/handler/edgestacks/edgestack_delete_test.go +++ b/api/http/handler/edgestacks/edgestack_delete_test.go @@ -16,6 +16,7 @@ import ( // Delete func TestDeleteAndInspect(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) // Create @@ -68,6 +69,7 @@ func TestDeleteAndInspect(t *testing.T) { } func TestDeleteInvalidEdgeStack(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) cases := []struct { @@ -98,6 +100,7 @@ func TestDeleteInvalidEdgeStack(t *testing.T) { } func TestDeleteEdgeStack_RemoveProjectFolder(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) edgeGroup := createEdgeGroup(t, handler.DataStore) diff --git a/api/http/handler/edgestacks/edgestack_inspect_test.go b/api/http/handler/edgestacks/edgestack_inspect_test.go index c73f536fae..6253de6283 100644 --- a/api/http/handler/edgestacks/edgestack_inspect_test.go +++ b/api/http/handler/edgestacks/edgestack_inspect_test.go @@ -8,6 +8,7 @@ import ( // Inspect func TestInspectInvalidEdgeID(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) cases := []struct { diff --git a/api/http/handler/edgestacks/edgestack_status_update_test.go b/api/http/handler/edgestacks/edgestack_status_update_test.go index 4d94368fe1..2017363d0a 100644 --- a/api/http/handler/edgestacks/edgestack_status_update_test.go +++ b/api/http/handler/edgestacks/edgestack_status_update_test.go @@ -15,6 +15,7 @@ import ( // Update Status func TestUpdateStatusAndInspect(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) endpoint := createEndpoint(t, handler.DataStore) @@ -78,6 +79,7 @@ func TestUpdateStatusAndInspect(t *testing.T) { } func TestUpdateStatusWithInvalidPayload(t *testing.T) { + t.Parallel() handler, _ := setupHandler(t) endpoint := createEndpoint(t, handler.DataStore) diff --git a/api/http/handler/edgestacks/edgestack_update_test.go b/api/http/handler/edgestacks/edgestack_update_test.go index 8040af3293..1665f39ac1 100644 --- a/api/http/handler/edgestacks/edgestack_update_test.go +++ b/api/http/handler/edgestacks/edgestack_update_test.go @@ -17,6 +17,7 @@ import ( // Update func TestUpdateAndInspect(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) endpoint := createEndpoint(t, handler.DataStore) @@ -103,6 +104,7 @@ func TestUpdateAndInspect(t *testing.T) { } func TestUpdateWithInvalidEdgeGroups(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) endpoint := createEndpoint(t, handler.DataStore) @@ -182,6 +184,7 @@ func TestUpdateWithInvalidEdgeGroups(t *testing.T) { } func TestUpdateWithInvalidPayload(t *testing.T) { + t.Parallel() handler, rawAPIKey := setupHandler(t) endpoint := createEndpoint(t, handler.DataStore) diff --git a/api/http/handler/edgestacks/endpoints_test.go b/api/http/handler/edgestacks/endpoints_test.go index 064ad98391..07f623b352 100644 --- a/api/http/handler/edgestacks/endpoints_test.go +++ b/api/http/handler/edgestacks/endpoints_test.go @@ -11,6 +11,7 @@ import ( ) func Test_hasKubeEndpoint(t *testing.T) { + t.Parallel() endpoints := []portainer.Endpoint{ {ID: 1, Type: portainer.DockerEnvironment}, {ID: 2, Type: portainer.AgentOnDockerEnvironment}, @@ -49,6 +50,7 @@ func Test_hasKubeEndpoint(t *testing.T) { } func Test_hasKubeEndpoint_failWhenEndpointDontExist(t *testing.T) { + t.Parallel() datastore := testhelpers.NewDatastore(testhelpers.WithEndpoints([]portainer.Endpoint{})) _, err := hasKubeEndpoint(datastore.Endpoint(), []portainer.EndpointID{1}) @@ -56,6 +58,7 @@ func Test_hasKubeEndpoint_failWhenEndpointDontExist(t *testing.T) { } func Test_hasDockerEndpoint(t *testing.T) { + t.Parallel() endpoints := []portainer.Endpoint{ {ID: 1, Type: portainer.DockerEnvironment}, {ID: 2, Type: portainer.AgentOnDockerEnvironment}, @@ -94,6 +97,7 @@ func Test_hasDockerEndpoint(t *testing.T) { } func Test_hasDockerEndpoint_failWhenEndpointDontExist(t *testing.T) { + t.Parallel() datastore := testhelpers.NewDatastore(testhelpers.WithEndpoints([]portainer.Endpoint{})) _, err := hasDockerEndpoint(datastore.Endpoint(), []portainer.EndpointID{1}) diff --git a/api/http/handler/endpointedge/endpointedge_job_logs_test.go b/api/http/handler/endpointedge/endpointedge_job_logs_test.go index d6feb38872..740dfb5ccf 100644 --- a/api/http/handler/endpointedge/endpointedge_job_logs_test.go +++ b/api/http/handler/endpointedge/endpointedge_job_logs_test.go @@ -11,6 +11,7 @@ import ( ) func TestUpdateUnrelatedEdgeJobLogs(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) h := &Handler{DataStore: store} diff --git a/api/http/handler/endpointedge/endpointedge_status_inspect_test.go b/api/http/handler/endpointedge/endpointedge_status_inspect_test.go index 2d5e54bf76..8b07f92b10 100644 --- a/api/http/handler/endpointedge/endpointedge_status_inspect_test.go +++ b/api/http/handler/endpointedge/endpointedge_status_inspect_test.go @@ -128,6 +128,7 @@ func createEndpoint(handler *Handler, endpoint portainer.Endpoint, endpointRelat } func TestMissingEdgeIdentifier(t *testing.T) { + t.Parallel() handler := mustSetupHandler(t) endpointID := portainer.EndpointID(45) @@ -155,6 +156,7 @@ func TestMissingEdgeIdentifier(t *testing.T) { } func TestWithEndpoints(t *testing.T) { + t.Parallel() handler := mustSetupHandler(t) for _, test := range endpointTestCases { @@ -181,6 +183,7 @@ func TestWithEndpoints(t *testing.T) { } func TestLastCheckInDateIncreases(t *testing.T) { + t.Parallel() synctest.Test(t, testLastCheckInDateIncreases) } @@ -231,6 +234,7 @@ func testLastCheckInDateIncreases(t *testing.T) { } func TestEmptyEdgeIdWithAgentPlatformHeader(t *testing.T) { + t.Parallel() handler := mustSetupHandler(t) endpointID := portainer.EndpointID(44) @@ -274,6 +278,7 @@ func TestEmptyEdgeIdWithAgentPlatformHeader(t *testing.T) { } func TestEdgeStackStatus(t *testing.T) { + t.Parallel() handler := mustSetupHandler(t) endpointID := portainer.EndpointID(7) @@ -339,6 +344,7 @@ func TestEdgeStackStatus(t *testing.T) { } func TestEdgeJobsResponse(t *testing.T) { + t.Parallel() handler := mustSetupHandler(t) localCreateEndpoint := func(endpointID portainer.EndpointID, tagIDs []portainer.TagID) *portainer.Endpoint { diff --git a/api/http/handler/endpoints/endpoint_create_global_key_test.go b/api/http/handler/endpoints/endpoint_create_global_key_test.go index a1613891c2..bdde9d808c 100644 --- a/api/http/handler/endpoints/endpoint_create_global_key_test.go +++ b/api/http/handler/endpoints/endpoint_create_global_key_test.go @@ -10,6 +10,7 @@ import ( ) func TestEmptyGlobalKey(t *testing.T) { + t.Parallel() handler := NewHandler(testhelpers.NewTestRequestBouncer()) req, err := http.NewRequest(http.MethodPost, "https://portainer.io:9443/endpoints/global-key", nil) diff --git a/api/http/handler/endpoints/endpoint_create_test.go b/api/http/handler/endpoints/endpoint_create_test.go index 65442f55bb..9452fe2769 100644 --- a/api/http/handler/endpoints/endpoint_create_test.go +++ b/api/http/handler/endpoints/endpoint_create_test.go @@ -17,6 +17,7 @@ import ( // EE-only kubeconfig validation tests removed for CE func TestSaveEndpointAndUpdateAuthorizations(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, false) endpointGroup := &portainer.EndpointGroup{ @@ -93,6 +94,7 @@ func TestSaveEndpointAndUpdateAuthorizations(t *testing.T) { } func TestCreateEndpointFailure(t *testing.T) { + t.Parallel() fips.InitFIPS(false) _, store := datastore.MustNewTestStore(t, true, false) @@ -115,6 +117,7 @@ func TestCreateEndpointFailure(t *testing.T) { } func TestCreateEdgeAgentEndpoint_ContainerEngineMapping(t *testing.T) { + t.Parallel() fips.InitFIPS(false) _, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/http/handler/endpoints/endpoint_delete_test.go b/api/http/handler/endpoints/endpoint_delete_test.go index 73b2b878bf..8537d3b041 100644 --- a/api/http/handler/endpoints/endpoint_delete_test.go +++ b/api/http/handler/endpoints/endpoint_delete_test.go @@ -15,6 +15,7 @@ import ( ) func TestEndpointDeleteEdgeGroupsConcurrently(t *testing.T) { + t.Parallel() const endpointsCount = 100 _, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/http/handler/endpoints/endpoint_list_test.go b/api/http/handler/endpoints/endpoint_list_test.go index 7ecc68851b..1cfe4f9fe5 100644 --- a/api/http/handler/endpoints/endpoint_list_test.go +++ b/api/http/handler/endpoints/endpoint_list_test.go @@ -25,6 +25,7 @@ type endpointListTest struct { } func Test_EndpointList_AgentVersion(t *testing.T) { + t.Parallel() version1Endpoint := portainer.Endpoint{ ID: 1, GroupID: 1, @@ -107,6 +108,7 @@ func Test_EndpointList_AgentVersion(t *testing.T) { } func Test_endpointList_edgeFilter(t *testing.T) { + t.Parallel() trustedEdgeAsync := portainer.Endpoint{ID: 1, UserTrusted: true, Edge: portainer.EnvironmentEdgeSettings{AsyncMode: true}, GroupID: 1, Type: portainer.EdgeAgentOnDockerEnvironment} untrustedEdgeAsync := portainer.Endpoint{ID: 2, UserTrusted: false, Edge: portainer.EnvironmentEdgeSettings{AsyncMode: true}, GroupID: 1, Type: portainer.EdgeAgentOnDockerEnvironment} regularUntrustedEdgeStandard := portainer.Endpoint{ID: 3, UserTrusted: false, Edge: portainer.EnvironmentEdgeSettings{AsyncMode: false}, GroupID: 1, Type: portainer.EdgeAgentOnDockerEnvironment} diff --git a/api/http/handler/endpoints/endpoint_registry_access_test.go b/api/http/handler/endpoints/endpoint_registry_access_test.go index 27260adf71..f2a305894f 100644 --- a/api/http/handler/endpoints/endpoint_registry_access_test.go +++ b/api/http/handler/endpoints/endpoint_registry_access_test.go @@ -58,6 +58,7 @@ func (s *spyKubeClient) RemoveImagePullSecretFromServiceAccount(namespace, _, _ var testRegistry = &portainer.Registry{ID: 3, URL: "registry.example.com"} func TestApplyKubeRegistryAccess_Grant(t *testing.T) { + t.Parallel() t.Run("single namespace granted creates secret then patches SA", func(t *testing.T) { spy := newSpyKubeClient() err := applyKubeRegistryAccess(spy, testRegistry, nil, []string{"ns-a"}) @@ -96,6 +97,7 @@ func TestApplyKubeRegistryAccess_Grant(t *testing.T) { } func TestApplyKubeRegistryAccess_Revoke(t *testing.T) { + t.Parallel() t.Run("single namespace revoked removes from SA then deletes secret", func(t *testing.T) { spy := newSpyKubeClient() err := applyKubeRegistryAccess(spy, testRegistry, []string{"ns-a"}, nil) @@ -134,6 +136,7 @@ func TestApplyKubeRegistryAccess_Revoke(t *testing.T) { } func TestApplyKubeRegistryAccess_Mixed(t *testing.T) { + t.Parallel() t.Run("one namespace added and one removed in same call", func(t *testing.T) { spy := newSpyKubeClient() err := applyKubeRegistryAccess(spy, testRegistry, []string{"ns-old"}, []string{"ns-new"}) diff --git a/api/http/handler/endpoints/endpoint_snapshots_test.go b/api/http/handler/endpoints/endpoint_snapshots_test.go index f4e5c0a93a..332393a549 100644 --- a/api/http/handler/endpoints/endpoint_snapshots_test.go +++ b/api/http/handler/endpoints/endpoint_snapshots_test.go @@ -18,6 +18,7 @@ import ( ) func Test_endpointSnapshots(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) endpointID := portainer.EndpointID(123) diff --git a/api/http/handler/endpoints/filter_test.go b/api/http/handler/endpoints/filter_test.go index 6e3558dfee..dbc5534efe 100644 --- a/api/http/handler/endpoints/filter_test.go +++ b/api/http/handler/endpoints/filter_test.go @@ -23,6 +23,7 @@ type filterTest struct { } func Test_Filter_AgentVersion(t *testing.T) { + t.Parallel() version1Endpoint := portainer.Endpoint{ID: 1, GroupID: 1, Type: portainer.AgentOnDockerEnvironment, Agent: struct { @@ -78,6 +79,7 @@ func Test_Filter_AgentVersion(t *testing.T) { } func Test_Filter_edgeFilter(t *testing.T) { + t.Parallel() trustedEdgeAsync := portainer.Endpoint{ID: 1, UserTrusted: true, Edge: portainer.EnvironmentEdgeSettings{AsyncMode: true}, GroupID: 1, Type: portainer.EdgeAgentOnDockerEnvironment} untrustedEdgeAsync := portainer.Endpoint{ID: 2, UserTrusted: false, Edge: portainer.EnvironmentEdgeSettings{AsyncMode: true}, GroupID: 1, Type: portainer.EdgeAgentOnDockerEnvironment} regularUntrustedEdgeStandard := portainer.Endpoint{ID: 3, UserTrusted: false, Edge: portainer.EnvironmentEdgeSettings{AsyncMode: false}, GroupID: 1, Type: portainer.EdgeAgentOnDockerEnvironment} @@ -130,6 +132,7 @@ func Test_Filter_edgeFilter(t *testing.T) { } func Test_Filter_excludeIDs(t *testing.T) { + t.Parallel() ids := []portainer.EndpointID{1, 2, 3, 4, 5, 6, 7, 8, 9} environments := slicesx.Map(ids, func(id portainer.EndpointID) portainer.Endpoint { @@ -152,6 +155,7 @@ func Test_Filter_excludeIDs(t *testing.T) { } func Test_Filter_excludeGroupIDs(t *testing.T) { + t.Parallel() groupA := portainer.EndpointGroupID(10) groupB := portainer.EndpointGroupID(20) groupC := portainer.EndpointGroupID(30) @@ -335,6 +339,7 @@ func setupFilterTest(t *testing.T, endpoints []portainer.Endpoint) *Handler { } func TestFilterEndpointsByEdgeStack(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) endpoints := []portainer.Endpoint{ @@ -403,6 +408,7 @@ func TestFilterEndpointsByEdgeStack(t *testing.T) { } func TestErrorsFilterEndpointsByEdgeStack(t *testing.T) { + t.Parallel() t.Run("must error by edge stack not found", func(t *testing.T) { _, store := datastore.MustNewTestStore(t, false, false) require.NotNil(t, store) @@ -438,6 +444,7 @@ func TestErrorsFilterEndpointsByEdgeStack(t *testing.T) { } func TestFilterEndpointsByEdgeGroup(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) endpoints := []portainer.Endpoint{ @@ -479,6 +486,7 @@ func TestFilterEndpointsByEdgeGroup(t *testing.T) { } func TestFilterEndpointsByExcludeEdgeGroupIDs(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) endpoints := []portainer.Endpoint{ @@ -520,6 +528,7 @@ func TestFilterEndpointsByExcludeEdgeGroupIDs(t *testing.T) { } func TestGetShortestAsyncInterval(t *testing.T) { + t.Parallel() endpoint := &portainer.Endpoint{ ID: 1, Name: "Test Endpoint", diff --git a/api/http/handler/endpoints/sort_test.go b/api/http/handler/endpoints/sort_test.go index 2eb748e331..3bd4cc2a8f 100644 --- a/api/http/handler/endpoints/sort_test.go +++ b/api/http/handler/endpoints/sort_test.go @@ -10,6 +10,7 @@ import ( ) func TestSortEndpointsByField(t *testing.T) { + t.Parallel() environments := []portainer.Endpoint{ {ID: 0, Name: "Environment 1", GroupID: 1, Status: 1, LastCheckInDate: 3, EdgeID: "edge32"}, {ID: 1, Name: "Environment 2", GroupID: 2, Status: 2, LastCheckInDate: 6, EdgeID: "edge57"}, diff --git a/api/http/handler/endpoints/utils_update_edge_groups_test.go b/api/http/handler/endpoints/utils_update_edge_groups_test.go index e392153091..6812124300 100644 --- a/api/http/handler/endpoints/utils_update_edge_groups_test.go +++ b/api/http/handler/endpoints/utils_update_edge_groups_test.go @@ -12,6 +12,7 @@ import ( ) func Test_updateEdgeGroups(t *testing.T) { + t.Parallel() createGroups := func(store *datastore.Store, names []string) ([]portainer.EdgeGroup, error) { groups := make([]portainer.EdgeGroup, len(names)) for index, name := range names { diff --git a/api/http/handler/endpoints/utils_update_tags_test.go b/api/http/handler/endpoints/utils_update_tags_test.go index 48ff420300..7c045a0346 100644 --- a/api/http/handler/endpoints/utils_update_tags_test.go +++ b/api/http/handler/endpoints/utils_update_tags_test.go @@ -12,6 +12,7 @@ import ( ) func Test_updateTags(t *testing.T) { + t.Parallel() createTags := func(store *datastore.Store, tagNames []string) ([]portainer.Tag, error) { tags := make([]portainer.Tag, len(tagNames)) for index, tagName := range tagNames { diff --git a/api/http/handler/file/handler_test.go b/api/http/handler/file/handler_test.go index 411272882e..3f3502f542 100644 --- a/api/http/handler/file/handler_test.go +++ b/api/http/handler/file/handler_test.go @@ -10,6 +10,7 @@ import ( ) func TestNormalServe(t *testing.T) { + t.Parallel() handler := file.NewHandler("", false, func() bool { return false }) require.NotNil(t, handler) @@ -32,6 +33,7 @@ func TestNormalServe(t *testing.T) { } func TestPermissionsPolicyHeader(t *testing.T) { + t.Parallel() handler := file.NewHandler("", false, func() bool { return false }) require.NotNil(t, handler) @@ -50,6 +52,7 @@ func TestPermissionsPolicyHeader(t *testing.T) { } func TestRedirectInstanceDisabled(t *testing.T) { + t.Parallel() handler := file.NewHandler("", false, func() bool { return true }) require.NotNil(t, handler) diff --git a/api/http/handler/kubernetes/config_test.go b/api/http/handler/kubernetes/config_test.go index f349760bca..e113a73201 100644 --- a/api/http/handler/kubernetes/config_test.go +++ b/api/http/handler/kubernetes/config_test.go @@ -8,6 +8,7 @@ import ( ) func TestIsSelfSignedCertificate(t *testing.T) { + t.Parallel() tc := []struct { name string diff --git a/api/http/handler/kubernetes/event_test.go b/api/http/handler/kubernetes/event_test.go index 54992a9377..2c46cd2efc 100644 --- a/api/http/handler/kubernetes/event_test.go +++ b/api/http/handler/kubernetes/event_test.go @@ -22,6 +22,7 @@ import ( // Currently this test just tests the HTTP Handler is setup correctly, in the future we should move the ClientFactory to a mock in order // test the logic in event.go func TestGetKubernetesEvents(t *testing.T) { + t.Parallel() is := assert.New(t) srv := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/api/http/handler/kubernetes/service_accounts_test.go b/api/http/handler/kubernetes/service_accounts_test.go index e50716ad13..d7d2302831 100644 --- a/api/http/handler/kubernetes/service_accounts_test.go +++ b/api/http/handler/kubernetes/service_accounts_test.go @@ -85,6 +85,7 @@ func newServiceAccountRequest(t *testing.T, method, path string, body []byte, u } func TestDeleteKubernetesServiceAccounts_ValidPayload(t *testing.T) { + t.Parallel() handler, u, tk := newServiceAccountTestHandler(t) payload := models.K8sServiceAccountDeleteRequests{ @@ -102,6 +103,7 @@ func TestDeleteKubernetesServiceAccounts_ValidPayload(t *testing.T) { } func TestDeleteKubernetesServiceAccounts_InvalidPayload(t *testing.T) { + t.Parallel() handler, u, tk := newServiceAccountTestHandler(t) payload := models.K8sServiceAccountDeleteRequests{} @@ -120,6 +122,7 @@ func TestDeleteKubernetesServiceAccounts_InvalidPayload(t *testing.T) { } func TestDeleteKubernetesServiceAccounts_EmptyNamespace(t *testing.T) { + t.Parallel() handler, u, tk := newServiceAccountTestHandler(t) payload := models.K8sServiceAccountDeleteRequests{ diff --git a/api/http/handler/registries/registry_access_test.go b/api/http/handler/registries/registry_access_test.go index e55411db4c..4ccf714d50 100644 --- a/api/http/handler/registries/registry_access_test.go +++ b/api/http/handler/registries/registry_access_test.go @@ -16,6 +16,7 @@ import ( ) func Test_RegistryAccess_RequiresAuthentication(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) registry := &portainer.Registry{ ID: 1, @@ -37,6 +38,7 @@ func Test_RegistryAccess_RequiresAuthentication(t *testing.T) { } func Test_RegistryAccess_InvalidRegistryID(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) user := &portainer.User{ID: 1, Username: "test", Role: portainer.StandardUserRole} err := store.User().Create(user) @@ -57,6 +59,7 @@ func Test_RegistryAccess_InvalidRegistryID(t *testing.T) { } func Test_RegistryAccess_RegistryNotFound(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) user := &portainer.User{ID: 1, Username: "test", Role: portainer.StandardUserRole} diff --git a/api/http/handler/registries/registry_configure_test.go b/api/http/handler/registries/registry_configure_test.go index 945a5f4047..3b91604e9b 100644 --- a/api/http/handler/registries/registry_configure_test.go +++ b/api/http/handler/registries/registry_configure_test.go @@ -50,6 +50,7 @@ func newConfigureRequest(t *testing.T, tls bool, skipVerify bool, includeCert bo } func Test_registryConfigurePayload_Validate_TLSBundleRules(t *testing.T) { + t.Parallel() // passes when all three are uploaded { req := newConfigureRequest(t, true, false, true, true, true) diff --git a/api/http/handler/registries/registry_create_test.go b/api/http/handler/registries/registry_create_test.go index e21c4e4d83..52350c2769 100644 --- a/api/http/handler/registries/registry_create_test.go +++ b/api/http/handler/registries/registry_create_test.go @@ -17,6 +17,7 @@ import ( ) func Test_registryCreatePayload_Validate(t *testing.T) { + t.Parallel() basePayload := registryCreatePayload{Name: "Test registry", URL: "http://example.com"} t.Run("Can't create a ProGet registry if BaseURL is empty", func(t *testing.T) { payload := basePayload @@ -54,6 +55,7 @@ func Test_registryCreatePayload_Validate(t *testing.T) { } func TestHandler_registryCreate(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) payload := registryCreatePayload{ diff --git a/api/http/handler/registries/registry_delete_test.go b/api/http/handler/registries/registry_delete_test.go index 9436625f15..589685e2eb 100644 --- a/api/http/handler/registries/registry_delete_test.go +++ b/api/http/handler/registries/registry_delete_test.go @@ -48,6 +48,7 @@ func (s *deleteSpyKubeClient) RemoveImagePullSecretFromServiceAccount(namespace, // --- cleanupRegistryFromNamespaces unit tests --- func TestCleanupRegistryFromNamespaces(t *testing.T) { + t.Parallel() const registryID portainer.RegistryID = 3 const endpointID portainer.EndpointID = 1 @@ -98,6 +99,7 @@ func TestCleanupRegistryFromNamespaces(t *testing.T) { // --- deleteKubernetesSecrets integration tests --- func TestDeleteKubernetesSecrets(t *testing.T) { + t.Parallel() const registryID portainer.RegistryID = 3 const endpointID portainer.EndpointID = 1 diff --git a/api/http/handler/registries/registry_ping_test.go b/api/http/handler/registries/registry_ping_test.go index ff1c2cd54b..3d0f3cb0a0 100644 --- a/api/http/handler/registries/registry_ping_test.go +++ b/api/http/handler/registries/registry_ping_test.go @@ -20,6 +20,7 @@ import ( ) func Test_categorizeRegistryError(t *testing.T) { + t.Parallel() tests := []struct { name string err error @@ -109,6 +110,7 @@ func Test_categorizeRegistryError(t *testing.T) { } func Test_registryPingPayload_Validate(t *testing.T) { + t.Parallel() tests := []struct { name string payload registryPingPayload @@ -187,6 +189,7 @@ func Test_registryPingPayload_Validate(t *testing.T) { } func TestHandler_pingRegistry(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) handler := NewHandler(testhelpers.NewTestRequestBouncer()) @@ -289,6 +292,7 @@ func TestHandler_pingRegistry(t *testing.T) { } func TestHandler_pingRegistry_DockerHubURL(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) handler := NewHandler(testhelpers.NewTestRequestBouncer()) diff --git a/api/http/handler/registries/registry_update_test.go b/api/http/handler/registries/registry_update_test.go index a85c69a50b..ade82803af 100644 --- a/api/http/handler/registries/registry_update_test.go +++ b/api/http/handler/registries/registry_update_test.go @@ -17,6 +17,7 @@ import ( ) func TestHandler_registryUpdate(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) registry := &portainer.Registry{Type: portainer.ProGetRegistry} diff --git a/api/http/handler/stacks/stack_file_test.go b/api/http/handler/stacks/stack_file_test.go index 2f49bf06e3..89c0fe72ff 100644 --- a/api/http/handler/stacks/stack_file_test.go +++ b/api/http/handler/stacks/stack_file_test.go @@ -20,6 +20,7 @@ import ( ) func TestStackFile_GitPendingRedeploy_Returns409(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) _, err := mockCreateUser(store) @@ -63,6 +64,7 @@ func TestStackFile_GitPendingRedeploy_Returns409(t *testing.T) { } func TestStackFile_MatchingGitSettings_ReturnsFileContent(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) _, err := mockCreateUser(store) diff --git a/api/http/handler/stacks/stack_list_test.go b/api/http/handler/stacks/stack_list_test.go index bad5dfae80..86e6a87abe 100644 --- a/api/http/handler/stacks/stack_list_test.go +++ b/api/http/handler/stacks/stack_list_test.go @@ -9,6 +9,7 @@ import ( ) func TestFilterStacks(t *testing.T) { + t.Parallel() t.Run("filter stacks against particular endpoint and all orphaned stacks", func(t *testing.T) { stacks := []portainer.Stack{ {ID: 1, EndpointID: 3, Name: "normal_stack", Type: portainer.DockerComposeStack}, diff --git a/api/http/handler/stacks/stack_update_git_test.go b/api/http/handler/stacks/stack_update_git_test.go index beecb44027..0d6bfc1b73 100644 --- a/api/http/handler/stacks/stack_update_git_test.go +++ b/api/http/handler/stacks/stack_update_git_test.go @@ -19,6 +19,7 @@ import ( ) func TestStackUpdateGitWebhookUniqueness(t *testing.T) { + t.Parallel() webhook, err := uuid.NewRandom() require.NoError(t, err) diff --git a/api/http/handler/stacks/stack_update_test.go b/api/http/handler/stacks/stack_update_test.go index 1901fcc494..6f2449491d 100644 --- a/api/http/handler/stacks/stack_update_test.go +++ b/api/http/handler/stacks/stack_update_test.go @@ -24,6 +24,7 @@ import ( ) func Test_updateStackInTx(t *testing.T) { + t.Parallel() t.Run("Transaction commits successfully - changes are persisted", func(t *testing.T) { payload := &updateComposeStackPayload{ StackFileContent: "version: '3'\nservices:\n web:\n image: nginx:latest", @@ -197,6 +198,7 @@ func Test_updateStackInTx(t *testing.T) { } func TestStackUpdate(t *testing.T) { + t.Parallel() t.Helper() _, store := datastore.MustNewTestStore(t, false, true) @@ -402,6 +404,7 @@ func (manager swarmStackManager) NormalizeStackName(name string) string { } func Test_updateSwarmStack_Prune(t *testing.T) { + t.Parallel() fips.InitFIPS(false) payload := &updateSwarmStackPayload{ @@ -438,6 +441,7 @@ func Test_updateSwarmStack_Prune(t *testing.T) { } func Test_updateComposeStack_Prune(t *testing.T) { + t.Parallel() fips.InitFIPS(false) payload := &updateComposeStackPayload{ diff --git a/api/http/handler/stacks/webhook_invoke_test.go b/api/http/handler/stacks/webhook_invoke_test.go index c67a61ed32..49a8eec347 100644 --- a/api/http/handler/stacks/webhook_invoke_test.go +++ b/api/http/handler/stacks/webhook_invoke_test.go @@ -15,6 +15,7 @@ import ( ) func TestHandler_webhookInvoke(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) webhookID := newGuidString(t) diff --git a/api/http/handler/system/version_test.go b/api/http/handler/system/version_test.go index d3027d12f9..383b9523e4 100644 --- a/api/http/handler/system/version_test.go +++ b/api/http/handler/system/version_test.go @@ -20,6 +20,7 @@ import ( ) func Test_getSystemVersion(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/http/handler/tags/tag_delete_test.go b/api/http/handler/tags/tag_delete_test.go index 3887475bae..bb8fb61854 100644 --- a/api/http/handler/tags/tag_delete_test.go +++ b/api/http/handler/tags/tag_delete_test.go @@ -19,6 +19,7 @@ import ( ) func TestTagDeleteEdgeGroupsConcurrently(t *testing.T) { + t.Parallel() const tagsCount = 100 handler, store := setUpHandler(t) @@ -83,6 +84,7 @@ func TestTagDeleteEdgeGroupsConcurrently(t *testing.T) { } func TestHandler_tagDelete(t *testing.T) { + t.Parallel() t.Run("should delete tag and update related endpoints and edge groups", func(t *testing.T) { handler, store := setUpHandler(t) diff --git a/api/http/handler/teammemberships/teammembership_update_test.go b/api/http/handler/teammemberships/teammembership_update_test.go index 9a5021ec8c..2ad666352d 100644 --- a/api/http/handler/teammemberships/teammembership_update_test.go +++ b/api/http/handler/teammemberships/teammembership_update_test.go @@ -16,6 +16,7 @@ import ( ) func TestUpdate(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, false) err := store.TeamMembershipService.Create(&portainer.TeamMembership{ diff --git a/api/http/handler/teams/team_create_test.go b/api/http/handler/teams/team_create_test.go index 354ca77ab5..003c22eb12 100644 --- a/api/http/handler/teams/team_create_test.go +++ b/api/http/handler/teams/team_create_test.go @@ -14,6 +14,7 @@ import ( ) func TestConcurrentTeamCreation(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, false) h := &Handler{ diff --git a/api/http/handler/teams/team_list_test.go b/api/http/handler/teams/team_list_test.go index b77187b8d6..6dbf1b736d 100644 --- a/api/http/handler/teams/team_list_test.go +++ b/api/http/handler/teams/team_list_test.go @@ -22,6 +22,7 @@ import ( ) func Test_teamList(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/http/handler/users/user_create_access_token_test.go b/api/http/handler/users/user_create_access_token_test.go index a6aa0e2c31..157130ee76 100644 --- a/api/http/handler/users/user_create_access_token_test.go +++ b/api/http/handler/users/user_create_access_token_test.go @@ -21,6 +21,7 @@ import ( ) func Test_userCreateAccessToken(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -113,6 +114,7 @@ func Test_userCreateAccessToken(t *testing.T) { } func Test_userAccessTokenCreatePayload(t *testing.T) { + t.Parallel() tests := []struct { payload userAccessTokenCreatePayload shouldFail bool diff --git a/api/http/handler/users/user_create_test.go b/api/http/handler/users/user_create_test.go index 109a0f1602..abb5a3c4b6 100644 --- a/api/http/handler/users/user_create_test.go +++ b/api/http/handler/users/user_create_test.go @@ -22,6 +22,7 @@ func (m mockPasswordStrengthChecker) Check(string) bool { } func TestConcurrentUserCreation(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, false) h := &Handler{ diff --git a/api/http/handler/users/user_delete_test.go b/api/http/handler/users/user_delete_test.go index 731365c17b..2d47c2f8b4 100644 --- a/api/http/handler/users/user_delete_test.go +++ b/api/http/handler/users/user_delete_test.go @@ -17,6 +17,7 @@ import ( ) func Test_deleteUserRemovesAccessTokens(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/http/handler/users/user_get_access_tokens_test.go b/api/http/handler/users/user_get_access_tokens_test.go index 82a215650b..f83a466bc3 100644 --- a/api/http/handler/users/user_get_access_tokens_test.go +++ b/api/http/handler/users/user_get_access_tokens_test.go @@ -20,6 +20,7 @@ import ( ) func Test_userGetAccessTokens(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -123,6 +124,7 @@ func Test_userGetAccessTokens(t *testing.T) { } func Test_hideAPIKeyFields(t *testing.T) { + t.Parallel() apiKey := &portainer.APIKey{ ID: 1, UserID: 2, diff --git a/api/http/handler/users/user_list_test.go b/api/http/handler/users/user_list_test.go index 6c017e88b1..43dcbbf98f 100644 --- a/api/http/handler/users/user_list_test.go +++ b/api/http/handler/users/user_list_test.go @@ -23,6 +23,7 @@ import ( ) func Test_userList(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/http/handler/users/user_remove_access_token_test.go b/api/http/handler/users/user_remove_access_token_test.go index 94e8d9b469..74248e9eea 100644 --- a/api/http/handler/users/user_remove_access_token_test.go +++ b/api/http/handler/users/user_remove_access_token_test.go @@ -19,6 +19,7 @@ import ( ) func Test_userRemoveAccessToken(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/http/handler/users/user_update_test.go b/api/http/handler/users/user_update_test.go index 4d976df9ed..4793011838 100644 --- a/api/http/handler/users/user_update_test.go +++ b/api/http/handler/users/user_update_test.go @@ -17,6 +17,7 @@ import ( ) func Test_updateUserRemovesAccessTokens(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) diff --git a/api/http/handler/websocket/initdial_test.go b/api/http/handler/websocket/initdial_test.go index 68569958ea..24cee95e00 100644 --- a/api/http/handler/websocket/initdial_test.go +++ b/api/http/handler/websocket/initdial_test.go @@ -13,6 +13,7 @@ import ( ) func TestInitDial(t *testing.T) { + t.Parallel() fips.InitFIPS(false) srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) diff --git a/api/http/logger_test.go b/api/http/logger_test.go index 0d4acc8a86..7828b4869c 100644 --- a/api/http/logger_test.go +++ b/api/http/logger_test.go @@ -10,6 +10,7 @@ import ( ) func TestLogger(t *testing.T) { + t.Parallel() msg := "Testing HTTP logger" buf := &bytes.Buffer{} diff --git a/api/http/middlewares/deprecated_test.go b/api/http/middlewares/deprecated_test.go index cc553b3717..b0749252eb 100644 --- a/api/http/middlewares/deprecated_test.go +++ b/api/http/middlewares/deprecated_test.go @@ -12,6 +12,7 @@ import ( ) func TestDeprecated(t *testing.T) { + t.Parallel() tests := []struct { name string urlBuilder func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) @@ -116,6 +117,7 @@ func TestDeprecated(t *testing.T) { } func TestDeprecatedSimple(t *testing.T) { + t.Parallel() // Create a test handler testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) @@ -142,6 +144,7 @@ func TestDeprecatedSimple(t *testing.T) { } func TestDeprecated_PreservesRequestContext(t *testing.T) { + t.Parallel() // Test that the middleware preserves request context when redirecting urlBuilder := func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) { return "/new-path", nil @@ -165,6 +168,7 @@ func TestDeprecated_PreservesRequestContext(t *testing.T) { } func TestDeprecated_PreservesRequestMethod(t *testing.T) { + t.Parallel() methods := []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch} urlBuilder := func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) { @@ -192,6 +196,7 @@ func TestDeprecated_PreservesRequestMethod(t *testing.T) { } func TestDeprecated_PreservesRequestHeaders(t *testing.T) { + t.Parallel() urlBuilder := func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) { return "/new-path", nil } @@ -216,6 +221,7 @@ func TestDeprecated_PreservesRequestHeaders(t *testing.T) { } func TestDeprecated_PreservesRequestBody(t *testing.T) { + t.Parallel() urlBuilder := func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) { return "/new-path", nil } @@ -239,6 +245,7 @@ func TestDeprecated_PreservesRequestBody(t *testing.T) { } func TestDeprecated_ErrorResponseFormat(t *testing.T) { + t.Parallel() urlBuilder := func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) { return "", httperror.BadRequest("test error message", nil) } @@ -266,6 +273,7 @@ func TestDeprecated_ErrorResponseFormat(t *testing.T) { } func TestDeprecated_WithQueryParameters(t *testing.T) { + t.Parallel() urlBuilder := func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) { return "/api/v2/resource", nil } @@ -287,6 +295,7 @@ func TestDeprecated_WithQueryParameters(t *testing.T) { } func TestDeprecated_WithMultipleRedirects(t *testing.T) { + t.Parallel() // Test that multiple deprecated middleware can be chained urlBuilder1 := func(w http.ResponseWriter, r *http.Request) (string, *httperror.HandlerError) { return "/v2" + r.URL.Path, nil diff --git a/api/http/middlewares/plaintext_http_request_test.go b/api/http/middlewares/plaintext_http_request_test.go index 33912be80f..58650ffad0 100644 --- a/api/http/middlewares/plaintext_http_request_test.go +++ b/api/http/middlewares/plaintext_http_request_test.go @@ -152,6 +152,7 @@ var tests = []struct { } func TestParseForwardedHeaderProto(t *testing.T) { + t.Parallel() for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := parseForwardedHeaderProto(tt.forwarded) diff --git a/api/http/models/kubernetes/service_accounts_test.go b/api/http/models/kubernetes/service_accounts_test.go index 0de5a30b9b..6e27cca3b1 100644 --- a/api/http/models/kubernetes/service_accounts_test.go +++ b/api/http/models/kubernetes/service_accounts_test.go @@ -10,6 +10,7 @@ import ( ) func TestK8sServiceAccountDeleteRequests_Validate(t *testing.T) { + t.Parallel() tests := []struct { name string payload K8sServiceAccountDeleteRequests @@ -80,6 +81,7 @@ func TestK8sServiceAccountDeleteRequests_Validate(t *testing.T) { } func TestK8sServiceAccount_Structure(t *testing.T) { + t.Parallel() sa := K8sServiceAccount{ Name: "test-sa", Namespace: "default", @@ -95,6 +97,7 @@ func TestK8sServiceAccount_Structure(t *testing.T) { } func TestK8sServiceAccount_WithAllFields(t *testing.T) { + t.Parallel() automountToken := true sa := K8sServiceAccount{ Name: "full-sa", diff --git a/api/http/offlinegate/offlinegate_test.go b/api/http/offlinegate/offlinegate_test.go index 0a3a78faec..daf7b0583d 100644 --- a/api/http/offlinegate/offlinegate_test.go +++ b/api/http/offlinegate/offlinegate_test.go @@ -15,6 +15,7 @@ import ( ) func Test_canLockAndUnlock(t *testing.T) { + t.Parallel() o := NewOfflineGate() unlock := o.Lock() @@ -22,6 +23,7 @@ func Test_canLockAndUnlock(t *testing.T) { } func Test_hasToBeUnlockedToLockAgain(t *testing.T) { + t.Parallel() // scenario: // 1. first routine starts and locks the gate // 2. first routine starts a second and wait for the second to start @@ -62,6 +64,7 @@ func Test_hasToBeUnlockedToLockAgain(t *testing.T) { } func Test_waitingMiddleware_executesImmediately_whenNotLocked(t *testing.T) { + t.Parallel() // scenario: // 1. create an gate // 2. kick off a waiting middleware that will release immediately as gate wasn't locked @@ -90,6 +93,7 @@ func Test_waitingMiddleware_executesImmediately_whenNotLocked(t *testing.T) { } func Test_waitingMiddleware_waitsForTheLockToBeReleased(t *testing.T) { + t.Parallel() synctest.Test(t, test_waitingMiddleware_waitsForTheLockToBeReleased) } @@ -129,6 +133,7 @@ func test_waitingMiddleware_waitsForTheLockToBeReleased(t *testing.T) { } func Test_waitingMiddleware_mayTimeout_whenLockedForTooLong(t *testing.T) { + t.Parallel() /* scenario: 1. create an gate and lock it @@ -155,6 +160,7 @@ func Test_waitingMiddleware_mayTimeout_whenLockedForTooLong(t *testing.T) { } func Test_waitingMiddleware_handlerPanics(t *testing.T) { + t.Parallel() o := NewOfflineGate() request := httptest.NewRequest(http.MethodPost, "/", nil) diff --git a/api/http/proxy/factory/docker/access_control_test.go b/api/http/proxy/factory/docker/access_control_test.go index 7fe0de46d7..038ba9afb0 100644 --- a/api/http/proxy/factory/docker/access_control_test.go +++ b/api/http/proxy/factory/docker/access_control_test.go @@ -7,6 +7,7 @@ import ( ) func Test_getUniqueElements(t *testing.T) { + t.Parallel() cases := []struct { description string input string diff --git a/api/http/proxy/factory/docker/transport_test.go b/api/http/proxy/factory/docker/transport_test.go index 11dc56326e..22b0afbd1c 100644 --- a/api/http/proxy/factory/docker/transport_test.go +++ b/api/http/proxy/factory/docker/transport_test.go @@ -22,6 +22,7 @@ import ( ) func TestTransport_updateDefaultGitBranch(t *testing.T) { + t.Parallel() type fields struct { gitService portainer.GitService } @@ -109,6 +110,7 @@ func mockDockerAPIServer(t *testing.T, routes RoutesDefinition) (*httptest.Serve } func TestTransport_getRealResourceID(t *testing.T) { + t.Parallel() srv, _ := mockDockerAPIServer(t, RoutesDefinition{ {http.MethodGet, "/networks"}: []network.Summary{{ID: "16e37c629e88694663791dc738fd37affb908d7b85ce00a20680675d10554fd4", Name: "mynetwork"}}, {http.MethodGet, "/networks/mynetwork"}: network.Inspect{ID: "16e37c629e88694663791dc738fd37affb908d7b85ce00a20680675d10554fd4", Name: "mynetwork"}, @@ -165,6 +167,7 @@ func TestTransport_getRealResourceID(t *testing.T) { } func TestTransport_proxyNetworkRequest(t *testing.T) { + t.Parallel() admin := portainer.User{ID: 1, Username: "admin", Role: portainer.AdministratorRole} std1 := portainer.User{ID: 2, Username: "std1", Role: portainer.StandardUserRole} std2 := portainer.User{ID: 3, Username: "std2", Role: portainer.StandardUserRole} diff --git a/api/http/proxy/factory/kubernetes/local_transport_test.go b/api/http/proxy/factory/kubernetes/local_transport_test.go index 855300b986..88726dda1d 100644 --- a/api/http/proxy/factory/kubernetes/local_transport_test.go +++ b/api/http/proxy/factory/kubernetes/local_transport_test.go @@ -9,6 +9,7 @@ import ( ) func TestNewLocalTransport(t *testing.T) { + t.Parallel() fips.InitFIPS(false) transport, err := NewLocalTransport(nil, nil, nil, nil, nil) diff --git a/api/http/proxy/factory/kubernetes/token_cache_test.go b/api/http/proxy/factory/kubernetes/token_cache_test.go index 972421be28..23231b261e 100644 --- a/api/http/proxy/factory/kubernetes/token_cache_test.go +++ b/api/http/proxy/factory/kubernetes/token_cache_test.go @@ -25,6 +25,7 @@ func failFunc(t *testing.T) func() (string, error) { } func TestTokenCacheDataRace(t *testing.T) { + t.Parallel() ch := make(chan struct{}) for range 1000 { @@ -52,6 +53,7 @@ func TestTokenCacheDataRace(t *testing.T) { } func TestTokenCache(t *testing.T) { + t.Parallel() mgr := NewTokenCacheManager() tc1 := mgr.GetOrCreateTokenCache(1) tc2 := mgr.GetOrCreateTokenCache(2) diff --git a/api/http/proxy/factory/kubernetes/transport_test.go b/api/http/proxy/factory/kubernetes/transport_test.go index 9b1b29eeb7..9eb32f82fa 100644 --- a/api/http/proxy/factory/kubernetes/transport_test.go +++ b/api/http/proxy/factory/kubernetes/transport_test.go @@ -48,6 +48,7 @@ func (m *MockJWTService) SetUserSessionDuration(userSessionDuration time.Duratio } func TestBaseTransport_AddTokenForExec(t *testing.T) { + t.Parallel() // Setup test store and JWT service _, store := datastore.MustNewTestStore(t, true, false) @@ -274,6 +275,7 @@ func TestBaseTransport_AddTokenForExec(t *testing.T) { } func TestBaseTransport_AddTokenForExec_Integration(t *testing.T) { + t.Parallel() // Create a test HTTP server to capture requests var capturedRequest *http.Request var capturedHeaders http.Header diff --git a/api/http/proxy/factory/reverse_proxy_test.go b/api/http/proxy/factory/reverse_proxy_test.go index 3636e13329..fdb1aab60d 100644 --- a/api/http/proxy/factory/reverse_proxy_test.go +++ b/api/http/proxy/factory/reverse_proxy_test.go @@ -11,6 +11,7 @@ import ( ) func Test_createRewriteFn(t *testing.T) { + t.Parallel() testCases := []struct { name string target *url.URL diff --git a/api/http/proxy/factory/utils/response_test.go b/api/http/proxy/factory/utils/response_test.go index c2a5bab30d..6b82b1f638 100644 --- a/api/http/proxy/factory/utils/response_test.go +++ b/api/http/proxy/factory/utils/response_test.go @@ -8,6 +8,7 @@ import ( ) func TestWriteAccessDeniedResponse(t *testing.T) { + t.Parallel() r, err := WriteAccessDeniedResponse() require.NoError(t, err) defer func() { diff --git a/api/http/security/bouncer_test.go b/api/http/security/bouncer_test.go index bd0a3948de..ab3e1ba33c 100644 --- a/api/http/security/bouncer_test.go +++ b/api/http/security/bouncer_test.go @@ -41,6 +41,7 @@ func tokenLookupEmpty(r *http.Request) (*portainer.TokenData, error) { } func Test_mwAuthenticateFirst(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, true) jwtService, err := jwt.NewService("1h", store) @@ -117,6 +118,7 @@ func Test_mwAuthenticateFirst(t *testing.T) { } func Test_extractKeyFromCookie(t *testing.T) { + t.Parallel() is := assert.New(t) tt := []struct { @@ -155,6 +157,7 @@ func Test_extractKeyFromCookie(t *testing.T) { } func Test_extractBearerToken(t *testing.T) { + t.Parallel() tt := []struct { name string requestHeader string @@ -205,6 +208,7 @@ func Test_extractBearerToken(t *testing.T) { } func Test_extractAPIKeyHeader(t *testing.T) { + t.Parallel() is := assert.New(t) tt := []struct { @@ -254,6 +258,7 @@ func Test_extractAPIKeyHeader(t *testing.T) { } func Test_extractAPIKeyQueryParam(t *testing.T) { + t.Parallel() is := assert.New(t) tt := []struct { @@ -306,6 +311,7 @@ func Test_extractAPIKeyQueryParam(t *testing.T) { } func Test_apiKeyLookup(t *testing.T) { + t.Parallel() is := assert.New(t) _, store := datastore.MustNewTestStore(t, true, true) @@ -394,6 +400,7 @@ func Test_apiKeyLookup(t *testing.T) { } func Test_ShouldSkipCSRFCheck(t *testing.T) { + t.Parallel() tt := []struct { name string cookieValue string @@ -470,6 +477,7 @@ func Test_ShouldSkipCSRFCheck(t *testing.T) { } func TestJWTRevocation(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, true) jwtService, err := jwt.NewService("1h", store) @@ -539,6 +547,7 @@ func TestJWTRevocation(t *testing.T) { } func TestCSPHeaderDefault(t *testing.T) { + t.Parallel() b := NewRequestBouncer(t.Context(), nil, nil, nil) srv := httptest.NewServer( @@ -557,6 +566,7 @@ func TestCSPHeaderDefault(t *testing.T) { } func TestCSPHeaderDisabled(t *testing.T) { + t.Parallel() b := NewRequestBouncer(t.Context(), nil, nil, nil) b.DisableCSP() diff --git a/api/http/security/filter_test.go b/api/http/security/filter_test.go index 5fa9e29112..956eda2ec4 100644 --- a/api/http/security/filter_test.go +++ b/api/http/security/filter_test.go @@ -7,6 +7,7 @@ import ( ) func TestFilterEndpointsPanic(t *testing.T) { + t.Parallel() endpoints := []portainer.Endpoint{{ID: 1}} groups := []portainer.EndpointGroup{} context := &RestrictedRequestContext{} diff --git a/api/http/security/passwordStrengthCheck_test.go b/api/http/security/passwordStrengthCheck_test.go index 0f96d230dd..53e735693b 100644 --- a/api/http/security/passwordStrengthCheck_test.go +++ b/api/http/security/passwordStrengthCheck_test.go @@ -7,6 +7,7 @@ import ( ) func TestStrengthCheck(t *testing.T) { + t.Parallel() checker := NewPasswordStrengthChecker(settingsStub{minLength: 12}) type args struct { diff --git a/api/http/security/rate_limiter_test.go b/api/http/security/rate_limiter_test.go index 42f98c9038..9a2817ffa9 100644 --- a/api/http/security/rate_limiter_test.go +++ b/api/http/security/rate_limiter_test.go @@ -11,6 +11,7 @@ import ( ) func TestLimitAccess(t *testing.T) { + t.Parallel() testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) t.Run("Request below the limit", func(t *testing.T) { @@ -57,6 +58,7 @@ func TestLimitAccess(t *testing.T) { } func TestStripAddrPort(t *testing.T) { + t.Parallel() t.Run("IP with port", func(t *testing.T) { result := StripAddrPort("127.0.0.1:1000") if result != "127.0.0.1" { diff --git a/api/http/utils/filters/filters_test.go b/api/http/utils/filters/filters_test.go index 021a723b2e..5f74582352 100644 --- a/api/http/utils/filters/filters_test.go +++ b/api/http/utils/filters/filters_test.go @@ -54,6 +54,7 @@ func productNameSort(a, b Product) int { } func TestSearchOrderAndPaginate(t *testing.T) { + t.Parallel() users := createUsers() products := createProducts() @@ -334,6 +335,7 @@ func TestSearchOrderAndPaginate(t *testing.T) { } func TestSearchOrderAndPaginateWithErrors(t *testing.T) { + t.Parallel() users := createUsers() // Config with error-prone accessor @@ -360,6 +362,7 @@ func TestSearchOrderAndPaginateWithErrors(t *testing.T) { } func TestApplyFilterResultsHeaders(t *testing.T) { + t.Parallel() t.Run("sets headers correctly", func(t *testing.T) { w := httptest.NewRecorder() var responseWriter http.ResponseWriter = w diff --git a/api/http/utils/filters/pagination_test.go b/api/http/utils/filters/pagination_test.go index 4b09ac9aaa..e8cb2e7f3c 100644 --- a/api/http/utils/filters/pagination_test.go +++ b/api/http/utils/filters/pagination_test.go @@ -7,6 +7,7 @@ import ( ) func TestPaginateFn_BasicPagination(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} // First page @@ -31,6 +32,7 @@ func TestPaginateFn_BasicPagination(t *testing.T) { } func TestPaginateFn_ZeroLimit(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} params := PaginationQueryParams{start: 2, limit: 0} @@ -41,6 +43,7 @@ func TestPaginateFn_ZeroLimit(t *testing.T) { } func TestPaginateFn_NegativeLimit(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} params := PaginationQueryParams{start: 2, limit: -5} @@ -51,6 +54,7 @@ func TestPaginateFn_NegativeLimit(t *testing.T) { } func TestPaginateFn_NegativeStart(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} params := PaginationQueryParams{start: -3, limit: 2} @@ -61,6 +65,7 @@ func TestPaginateFn_NegativeStart(t *testing.T) { } func TestPaginateFn_StartBeyondLength(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} params := PaginationQueryParams{start: 10, limit: 3} @@ -71,6 +76,7 @@ func TestPaginateFn_StartBeyondLength(t *testing.T) { } func TestPaginateFn_StartAtLength(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} params := PaginationQueryParams{start: 5, limit: 3} @@ -81,6 +87,7 @@ func TestPaginateFn_StartAtLength(t *testing.T) { } func TestPaginateFn_LimitLargerThanRemaining(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} params := PaginationQueryParams{start: 3, limit: 10} @@ -91,6 +98,7 @@ func TestPaginateFn_LimitLargerThanRemaining(t *testing.T) { } func TestPaginateFn_EmptySlice(t *testing.T) { + t.Parallel() items := []int{} params := PaginationQueryParams{start: 0, limit: 5} @@ -101,6 +109,7 @@ func TestPaginateFn_EmptySlice(t *testing.T) { } func TestPaginateFn_EmptySliceWithNegativeStart(t *testing.T) { + t.Parallel() items := []int{} params := PaginationQueryParams{start: -5, limit: 3} @@ -111,6 +120,7 @@ func TestPaginateFn_EmptySliceWithNegativeStart(t *testing.T) { } func TestPaginateFn_SingleElement(t *testing.T) { + t.Parallel() items := []int{42} // Take the single element @@ -125,6 +135,7 @@ func TestPaginateFn_SingleElement(t *testing.T) { } func TestPaginateFn_LimitOfOne(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} results := [][]int{} @@ -141,6 +152,7 @@ func TestPaginateFn_LimitOfOne(t *testing.T) { } func TestPaginateFn_StringSlice(t *testing.T) { + t.Parallel() items := []string{"apple", "banana", "cherry", "date", "elderberry"} params := PaginationQueryParams{start: 1, limit: 3} @@ -150,6 +162,7 @@ func TestPaginateFn_StringSlice(t *testing.T) { } func TestPaginateFn_StructSlice(t *testing.T) { + t.Parallel() type User struct { ID int Name string @@ -173,6 +186,7 @@ func TestPaginateFn_StructSlice(t *testing.T) { } func TestPaginateFn_BoundaryConditions(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} testCases := []struct { @@ -202,6 +216,7 @@ func TestPaginateFn_BoundaryConditions(t *testing.T) { } func TestPaginateFn_ReturnsSliceView(t *testing.T) { + t.Parallel() items := []int{1, 2, 3, 4, 5} params := PaginationQueryParams{start: 1, limit: 3} @@ -218,6 +233,7 @@ func TestPaginateFn_ReturnsSliceView(t *testing.T) { } func TestPaginateFn_TypicalAPIUseCases(t *testing.T) { + t.Parallel() // Simulate API responses with different page sizes items := make([]int, 100) for i := range items { diff --git a/api/http/utils/filters/query_params_test.go b/api/http/utils/filters/query_params_test.go index c75a796e41..c15286253a 100644 --- a/api/http/utils/filters/query_params_test.go +++ b/api/http/utils/filters/query_params_test.go @@ -9,6 +9,7 @@ import ( ) func TestExtractListModifiersQueryParams(t *testing.T) { + t.Parallel() tests := []struct { name string queryParams map[string]string @@ -199,11 +200,13 @@ func TestExtractListModifiersQueryParams(t *testing.T) { } func TestSortOrderConstants(t *testing.T) { + t.Parallel() require.Equal(t, SortAsc, SortOrder("asc"), "SortAsc constant should equal 'asc'") require.Equal(t, SortDesc, SortOrder("desc"), "SortDesc constant should equal 'desc'") } func TestQueryParamsStructEmbedding(t *testing.T) { + t.Parallel() qp := QueryParams{ SearchQueryParams: SearchQueryParams{search: "test"}, SortQueryParams: SortQueryParams{sort: "name", order: SortAsc}, @@ -219,6 +222,7 @@ func TestQueryParamsStructEmbedding(t *testing.T) { } func TestExtractListModifiersQueryParamsEdgeCases(t *testing.T) { + t.Parallel() t.Run("special characters in search", func(t *testing.T) { req := createRequestWithParams(map[string]string{ "search": "test & special chars %20", diff --git a/api/http/utils/filters/search_test.go b/api/http/utils/filters/search_test.go index d8f552563a..695a09143f 100644 --- a/api/http/utils/filters/search_test.go +++ b/api/http/utils/filters/search_test.go @@ -7,6 +7,7 @@ import ( ) func TestSearchFn_BasicSearch(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, @@ -23,6 +24,7 @@ func TestSearchFn_BasicSearch(t *testing.T) { } func TestSearchFn_EmptySearch(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, @@ -38,6 +40,7 @@ func TestSearchFn_EmptySearch(t *testing.T) { } func TestSearchFn_NoMatches(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, @@ -52,6 +55,7 @@ func TestSearchFn_NoMatches(t *testing.T) { } func TestSearchFn_MultipleMatches(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Smith", Email: "bob@company.com", Age: 30}, @@ -70,6 +74,7 @@ func TestSearchFn_MultipleMatches(t *testing.T) { } func TestSearchFn_MultipleAccessors(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, @@ -93,6 +98,7 @@ func TestSearchFn_MultipleAccessors(t *testing.T) { } func TestSearchFn_CaseSensitive(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, @@ -113,6 +119,7 @@ func TestSearchFn_CaseSensitive(t *testing.T) { } func TestSearchFn_PartialMatches(t *testing.T) { + t.Parallel() products := []Product{ {ID: 1, Name: "Wireless Mouse", Description: "Ergonomic wireless mouse", Price: 25, Category: "Electronics"}, {ID: 2, Name: "Mechanical Keyboard", Description: "RGB gaming keyboard", Price: 150, Category: "Electronics"}, @@ -135,6 +142,7 @@ func TestSearchFn_PartialMatches(t *testing.T) { } func TestSearchFn_EmptySlice(t *testing.T) { + t.Parallel() users := []User{} accessors := []SearchAccessor[User]{userNameAccessor, userEmailAccessor} params := SearchQueryParams{search: "anything"} @@ -145,6 +153,7 @@ func TestSearchFn_EmptySlice(t *testing.T) { } func TestSearchFn_EmptyAccessors(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, } @@ -159,6 +168,7 @@ func TestSearchFn_EmptyAccessors(t *testing.T) { } func TestSearchFn_SingleAccessor(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, @@ -175,6 +185,7 @@ func TestSearchFn_SingleAccessor(t *testing.T) { } func TestSearchFn_NumericSearch(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, @@ -192,6 +203,7 @@ func TestSearchFn_NumericSearch(t *testing.T) { } func TestSearchFn_FormattedAccessor(t *testing.T) { + t.Parallel() products := []Product{ {ID: 1, Name: "Mouse", Description: "Wireless mouse", Price: 25, Category: "Electronics"}, {ID: 2, Name: "Keyboard", Description: "Gaming keyboard", Price: 150, Category: "Electronics"}, @@ -208,6 +220,7 @@ func TestSearchFn_FormattedAccessor(t *testing.T) { } func TestSearchFn_FirstMatchOnly(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "test user", Email: "test@example.com", Age: 25}, } @@ -224,6 +237,7 @@ func TestSearchFn_FirstMatchOnly(t *testing.T) { } func TestSearchFn_PreservesOrder(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Test", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@test.com", Age: 30}, @@ -243,6 +257,7 @@ func TestSearchFn_PreservesOrder(t *testing.T) { } func TestSearchFn_ComplexSearch(t *testing.T) { + t.Parallel() products := []Product{ {ID: 1, Name: "Gaming Mouse", Description: "High-DPI gaming mouse", Price: 75, Category: "Gaming"}, {ID: 2, Name: "Office Mouse", Description: "Ergonomic office mouse", Price: 25, Category: "Office"}, @@ -268,6 +283,7 @@ func TestSearchFn_ComplexSearch(t *testing.T) { } func TestSearchFn_WhitespaceSearch(t *testing.T) { + t.Parallel() users := []User{ {ID: 1, Name: "Alice Smith", Email: "alice@example.com", Age: 25}, {ID: 2, Name: "Bob Johnson", Email: "bob@company.com", Age: 30}, diff --git a/api/http/utils/filters/sort_test.go b/api/http/utils/filters/sort_test.go index 66145fc1a0..97bf865c13 100644 --- a/api/http/utils/filters/sort_test.go +++ b/api/http/utils/filters/sort_test.go @@ -25,6 +25,7 @@ func compareProductByPrice(a, b Product) int { } func TestSortFn_BasicAscending(t *testing.T) { + t.Parallel() users := []User{ {Name: "Charlie", Age: 25}, {Name: "Alice", Age: 30}, @@ -47,6 +48,7 @@ func TestSortFn_BasicAscending(t *testing.T) { } func TestSortFn_BasicDescending(t *testing.T) { + t.Parallel() users := []User{ {Name: "Charlie", Age: 25}, {Name: "Alice", Age: 30}, @@ -69,6 +71,7 @@ func TestSortFn_BasicDescending(t *testing.T) { } func TestSortFn_SortByAge(t *testing.T) { + t.Parallel() users := []User{ {Name: "Charlie", Age: 25}, {Name: "Alice", Age: 30}, @@ -102,6 +105,7 @@ func TestSortFn_SortByAge(t *testing.T) { } func TestSortFn_UnknownSortKey(t *testing.T) { + t.Parallel() users := []User{ {Name: "Charlie", Age: 25}, {Name: "Alice", Age: 30}, @@ -124,6 +128,7 @@ func TestSortFn_UnknownSortKey(t *testing.T) { } func TestSortFn_EmptySlice(t *testing.T) { + t.Parallel() users := []User{} sorts := []SortBinding[User]{ @@ -137,6 +142,7 @@ func TestSortFn_EmptySlice(t *testing.T) { } func TestSortFn_SingleElement(t *testing.T) { + t.Parallel() users := []User{{Name: "Alice", Age: 30}} sorts := []SortBinding[User]{ @@ -150,6 +156,7 @@ func TestSortFn_SingleElement(t *testing.T) { } func TestSortFn_EmptySortBindings(t *testing.T) { + t.Parallel() users := []User{ {Name: "Charlie", Age: 25}, {Name: "Alice", Age: 30}, @@ -168,6 +175,7 @@ func TestSortFn_EmptySortBindings(t *testing.T) { } func TestSortFn_DifferentType(t *testing.T) { + t.Parallel() products := []Product{ {Name: "Laptop", Price: 1000}, {Name: "Mouse", Price: 25}, @@ -201,6 +209,7 @@ func TestSortFn_DifferentType(t *testing.T) { } func TestSortFn_StableSort(t *testing.T) { + t.Parallel() // Test that sorting is stable (maintains relative order of equal elements) users := []User{ {Name: "Alice", Age: 25}, @@ -226,6 +235,7 @@ func TestSortFn_StableSort(t *testing.T) { } func TestReverseSortFn(t *testing.T) { + t.Parallel() originalFn := compareUserByAge reversedFn := reverSortFn(originalFn) @@ -244,6 +254,7 @@ func TestReverseSortFn(t *testing.T) { } func TestSortFn_CaseSensitive(t *testing.T) { + t.Parallel() users := []User{ {Name: "alice", Age: 25}, {Name: "Bob", Age: 30}, @@ -266,6 +277,7 @@ func TestSortFn_CaseSensitive(t *testing.T) { } func TestSortFn_ModifiesOriginalSlice(t *testing.T) { + t.Parallel() users := []User{ {Name: "Charlie", Age: 25}, {Name: "Alice", Age: 30}, diff --git a/api/internal/edge/edgestacks/service_test.go b/api/internal/edge/edgestacks/service_test.go index 4e507fc774..8978c54731 100644 --- a/api/internal/edge/edgestacks/service_test.go +++ b/api/internal/edge/edgestacks/service_test.go @@ -11,6 +11,7 @@ import ( ) func Test_updateEndpointRelation_successfulRuns(t *testing.T) { + t.Parallel() edgeStackID := portainer.EdgeStackID(5) endpointRelations := []portainer.EndpointRelation{ {EndpointID: 1, EdgeStacks: map[portainer.EdgeStackID]bool{}}, diff --git a/api/internal/edge/endpoint_test.go b/api/internal/edge/endpoint_test.go index 2414085152..3891c58d56 100644 --- a/api/internal/edge/endpoint_test.go +++ b/api/internal/edge/endpoint_test.go @@ -11,6 +11,7 @@ import ( ) func TestEndpointInEdgeGroup(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, false) endpointGroups := []portainer.EndpointGroup{{ID: 1, Name: "test-group"}} diff --git a/api/internal/endpointutils/endpoint_setup_test.go b/api/internal/endpointutils/endpoint_setup_test.go index 64be9e2546..5848a34f7a 100644 --- a/api/internal/endpointutils/endpoint_setup_test.go +++ b/api/internal/endpointutils/endpoint_setup_test.go @@ -7,6 +7,7 @@ import ( ) func TestCreateOfflineUnsecuredEndpoint(t *testing.T) { + t.Parallel() err := createUnsecuredEndpoint("tcp://localhost:1", nil, nil) require.Error(t, err) } diff --git a/api/internal/endpointutils/endpoint_test.go b/api/internal/endpointutils/endpoint_test.go index 0fe7b8fd11..53ddc5437e 100644 --- a/api/internal/endpointutils/endpoint_test.go +++ b/api/internal/endpointutils/endpoint_test.go @@ -16,6 +16,7 @@ type isEndpointTypeTest struct { } func Test_IsDockerEndpoint(t *testing.T) { + t.Parallel() tests := []isEndpointTypeTest{ {endpointType: portainer.DockerEnvironment, expected: true}, {endpointType: portainer.AgentOnDockerEnvironment, expected: true}, @@ -33,6 +34,7 @@ func Test_IsDockerEndpoint(t *testing.T) { } func Test_IsKubernetesEndpoint(t *testing.T) { + t.Parallel() tests := []isEndpointTypeTest{ {endpointType: portainer.DockerEnvironment, expected: false}, {endpointType: portainer.AgentOnDockerEnvironment, expected: false}, @@ -50,6 +52,7 @@ func Test_IsKubernetesEndpoint(t *testing.T) { } func Test_IsAgentEndpoint(t *testing.T) { + t.Parallel() tests := []isEndpointTypeTest{ {endpointType: portainer.DockerEnvironment, expected: false}, {endpointType: portainer.AgentOnDockerEnvironment, expected: true}, @@ -67,6 +70,7 @@ func Test_IsAgentEndpoint(t *testing.T) { } func Test_FilterByExcludeIDs(t *testing.T) { + t.Parallel() tests := []struct { name string inputArray []portainer.Endpoint @@ -124,6 +128,7 @@ func Test_FilterByExcludeIDs(t *testing.T) { } func TestUpdateEdgeEndpointHeartbeat(t *testing.T) { + t.Parallel() endpoint := &portainer.Endpoint{ Type: portainer.EdgeAgentOnDockerEnvironment, LastCheckInDate: time.Now().Unix(), diff --git a/api/internal/randomstring/random_string_test.go b/api/internal/randomstring/random_string_test.go index d6f640ee4c..683707060a 100644 --- a/api/internal/randomstring/random_string_test.go +++ b/api/internal/randomstring/random_string_test.go @@ -12,6 +12,7 @@ func init() { } func TestRandomString(t *testing.T) { + t.Parallel() testCases := []struct { name string length int @@ -48,6 +49,7 @@ func TestRandomString(t *testing.T) { } func TestRandomStringUniqueness(t *testing.T) { + t.Parallel() // Generate multiple random strings and verify they are different const numStrings = 100 const stringLength = 10 diff --git a/api/jwt/jwt_kubeconfig_test.go b/api/jwt/jwt_kubeconfig_test.go index 696531ef64..cf88843130 100644 --- a/api/jwt/jwt_kubeconfig_test.go +++ b/api/jwt/jwt_kubeconfig_test.go @@ -13,6 +13,7 @@ import ( ) func TestService_GenerateTokenForKubeconfig(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, false) err := store.User().Create(&portainer.User{ID: 1}) diff --git a/api/jwt/jwt_test.go b/api/jwt/jwt_test.go index 94aaa92681..52c7d589cd 100644 --- a/api/jwt/jwt_test.go +++ b/api/jwt/jwt_test.go @@ -15,6 +15,7 @@ import ( ) func TestGenerateSignedToken(t *testing.T) { + t.Parallel() dataStore := testhelpers.NewDatastore(testhelpers.WithSettingsService(&portainer.Settings{})) svc, err := NewService("24h", dataStore) require.NoError(t, err, "failed to create a copy of service") @@ -44,6 +45,7 @@ func TestGenerateSignedToken(t *testing.T) { } func TestGenerateSignedToken_InvalidScope(t *testing.T) { + t.Parallel() dataStore := testhelpers.NewDatastore(testhelpers.WithSettingsService(&portainer.Settings{})) svc, err := NewService("24h", dataStore) require.NoError(t, err, "failed to create a copy of service") @@ -61,6 +63,7 @@ func TestGenerateSignedToken_InvalidScope(t *testing.T) { } func TestGenerationAndParsing(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, true, false) err := store.User().Create(&portainer.User{ID: 1}) @@ -86,6 +89,7 @@ func TestGenerationAndParsing(t *testing.T) { } func TestExpiration(t *testing.T) { + t.Parallel() synctest.Test(t, testExpiration) } diff --git a/api/kubernetes/cli/access_test.go b/api/kubernetes/cli/access_test.go index 25d19da550..c6f1ddc8f5 100644 --- a/api/kubernetes/cli/access_test.go +++ b/api/kubernetes/cli/access_test.go @@ -12,6 +12,7 @@ import ( ) func Test_NamespaceAccessPoliciesDeleteNamespace_updatesPortainerConfig_whenConfigExists(t *testing.T) { + t.Parallel() testcases := []struct { name string namespaceToDelete string @@ -69,6 +70,7 @@ func Test_NamespaceAccessPoliciesDeleteNamespace_updatesPortainerConfig_whenConf } func TestKubeAdmin(t *testing.T) { + t.Parallel() kcl := &KubeClient{} require.False(t, kcl.GetIsKubeAdmin()) @@ -80,6 +82,7 @@ func TestKubeAdmin(t *testing.T) { } func TestClientNonAdminNamespaces(t *testing.T) { + t.Parallel() kcl := &KubeClient{} require.Empty(t, kcl.GetClientNonAdminNamespaces()) diff --git a/api/kubernetes/cli/applications_test.go b/api/kubernetes/cli/applications_test.go index a931c7f168..dffb62fd42 100644 --- a/api/kubernetes/cli/applications_test.go +++ b/api/kubernetes/cli/applications_test.go @@ -230,6 +230,7 @@ func createTestService(name, namespace string, selector map[string]string) *core } func TestGetApplications(t *testing.T) { + t.Parallel() t.Run("Admin user - Mix of deployments, statefulsets and daemonsets with and without pods", func(t *testing.T) { // Create a fake K8s client fakeClient := fake.NewSimpleClientset() diff --git a/api/kubernetes/cli/client_test.go b/api/kubernetes/cli/client_test.go index 993a966e33..c8e91e2f96 100644 --- a/api/kubernetes/cli/client_test.go +++ b/api/kubernetes/cli/client_test.go @@ -5,6 +5,7 @@ import ( ) func TestClearUserClientCache(t *testing.T) { + t.Parallel() factory, _ := NewClientFactory(nil, nil, nil, "", "", "") kcl := &KubeClient{} factory.endpointProxyClients.Set("12.1", kcl, 0) diff --git a/api/kubernetes/cli/cronjob_test.go b/api/kubernetes/cli/cronjob_test.go index 9c20777649..b60147e21f 100644 --- a/api/kubernetes/cli/cronjob_test.go +++ b/api/kubernetes/cli/cronjob_test.go @@ -71,6 +71,7 @@ func (kcl *KubeClient) TestFetchCronJobs(t *testing.T) { // executions belonging to the CronJob's own namespace, even when same-named CronJobs // exist across multiple namespaces. func TestGetCronJobExecutionsNamespaceFilter(t *testing.T) { + t.Parallel() backoffLimit := int32(3) completions := int32(1) diff --git a/api/kubernetes/cli/event_test.go b/api/kubernetes/cli/event_test.go index 5c0a4091c8..684f086dbb 100644 --- a/api/kubernetes/cli/event_test.go +++ b/api/kubernetes/cli/event_test.go @@ -14,6 +14,7 @@ import ( // It creates a fake Kubernetes client and passes it to the GetEvents method // It then logs the fetched events and validated the data returned func TestGetEvents(t *testing.T) { + t.Parallel() t.Run("can get events for resource id when admin", func(t *testing.T) { kcl := &KubeClient{ cli: kfake.NewSimpleClientset(), diff --git a/api/kubernetes/cli/ingress_test.go b/api/kubernetes/cli/ingress_test.go index 0a186a3ee4..e6e36a6763 100644 --- a/api/kubernetes/cli/ingress_test.go +++ b/api/kubernetes/cli/ingress_test.go @@ -7,6 +7,7 @@ import ( ) func TestGetIngresses(t *testing.T) { + t.Parallel() kcl := &KubeClient{} ingresses, err := kcl.GetIngresses("default") diff --git a/api/kubernetes/cli/job_test.go b/api/kubernetes/cli/job_test.go index d26d0094d1..f1e7736f86 100644 --- a/api/kubernetes/cli/job_test.go +++ b/api/kubernetes/cli/job_test.go @@ -66,6 +66,7 @@ func (kcl *KubeClient) TestFetchJobs(t *testing.T) { } func TestParseJobTimes(t *testing.T) { + t.Parallel() // Empty job jobTimes := parseJobTimes(batchv1.Job{}) diff --git a/api/kubernetes/cli/namespace_test.go b/api/kubernetes/cli/namespace_test.go index bd74f713d6..b67afe2ff6 100644 --- a/api/kubernetes/cli/namespace_test.go +++ b/api/kubernetes/cli/namespace_test.go @@ -14,6 +14,7 @@ import ( ) func Test_ToggleSystemState(t *testing.T) { + t.Parallel() t.Run("should skip is default (exit without error)", func(t *testing.T) { nsName := "default" kcl := &KubeClient{ diff --git a/api/kubernetes/cli/nodes_limits_test.go b/api/kubernetes/cli/nodes_limits_test.go index 1dc689c962..044d1af6b6 100644 --- a/api/kubernetes/cli/nodes_limits_test.go +++ b/api/kubernetes/cli/nodes_limits_test.go @@ -90,6 +90,7 @@ func newPods() *v1.PodList { } func TestKubeClient_GetNodesLimits(t *testing.T) { + t.Parallel() type fields struct { cli kubernetes.Interface } diff --git a/api/kubernetes/cli/pod_test.go b/api/kubernetes/cli/pod_test.go index 694ff1dbe0..8a54e0665b 100644 --- a/api/kubernetes/cli/pod_test.go +++ b/api/kubernetes/cli/pod_test.go @@ -13,6 +13,7 @@ import ( ) func Test_waitForPodStatus(t *testing.T) { + t.Parallel() t.Run("successfully errors on cancelled context", func(t *testing.T) { k := &KubeClient{ diff --git a/api/kubernetes/cli/resource_quota_test.go b/api/kubernetes/cli/resource_quota_test.go index a930e3220b..50f0292711 100644 --- a/api/kubernetes/cli/resource_quota_test.go +++ b/api/kubernetes/cli/resource_quota_test.go @@ -7,6 +7,7 @@ import ( ) func TestGetResourceQuotas(t *testing.T) { + t.Parallel() kcl := &KubeClient{} resourceQuotas, err := kcl.GetResourceQuotas("default") diff --git a/api/kubernetes/cli/resource_test.go b/api/kubernetes/cli/resource_test.go index f10a7c3c9c..c56020950e 100644 --- a/api/kubernetes/cli/resource_test.go +++ b/api/kubernetes/cli/resource_test.go @@ -22,6 +22,7 @@ func compareYAMLStrings(in1, in2 string) int { } func Test_GenerateYAML(t *testing.T) { + t.Parallel() resourceYAMLTests := []struct { title string resource runtime.Object @@ -97,6 +98,7 @@ func Test_GenerateYAML(t *testing.T) { } func TestGetResourceQuotaFromNamespace(t *testing.T) { + t.Parallel() kcl := &KubeClient{} namespace := portainer.K8sNamespaceInfo{Name: "my-namespace"} diff --git a/api/kubernetes/cli/service_account_test.go b/api/kubernetes/cli/service_account_test.go index a7a0625dd9..6fbcfd98cc 100644 --- a/api/kubernetes/cli/service_account_test.go +++ b/api/kubernetes/cli/service_account_test.go @@ -12,6 +12,7 @@ import ( ) func Test_GetServiceAccount(t *testing.T) { + t.Parallel() t.Run("returns error if non-existent", func(t *testing.T) { k := &KubeClient{ @@ -100,6 +101,7 @@ func Test_GetServiceAccount(t *testing.T) { } func TestGetServiceAccountDetails(t *testing.T) { + t.Parallel() t.Run("returns service account details", func(t *testing.T) { automount := false sa := &v1.ServiceAccount{ @@ -172,6 +174,7 @@ func TestGetServiceAccountDetails(t *testing.T) { } func TestAddImagePullSecretToServiceAccount(t *testing.T) { + t.Parallel() newKCL := func(sa *v1.ServiceAccount) *KubeClient { return &KubeClient{cli: kfake.NewSimpleClientset(sa), instanceID: "test"} } @@ -239,6 +242,7 @@ func TestAddImagePullSecretToServiceAccount(t *testing.T) { } func TestRemoveImagePullSecretFromServiceAccount(t *testing.T) { + t.Parallel() newKCL := func(sa *v1.ServiceAccount) *KubeClient { return &KubeClient{cli: kfake.NewSimpleClientset(sa), instanceID: "test"} } @@ -307,6 +311,7 @@ func TestRemoveImagePullSecretFromServiceAccount(t *testing.T) { } func TestGetServiceAccount_CreatesAndFetches(t *testing.T) { + t.Parallel() t.Run("returns annotations when set", func(t *testing.T) { sa := &v1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{ diff --git a/api/kubernetes/cli/service_test.go b/api/kubernetes/cli/service_test.go index c7192ff1ce..6d49805da4 100644 --- a/api/kubernetes/cli/service_test.go +++ b/api/kubernetes/cli/service_test.go @@ -7,6 +7,7 @@ import ( ) func TestGetServices(t *testing.T) { + t.Parallel() kcl := &KubeClient{} services, err := kcl.GetServices("default") diff --git a/api/kubernetes/cli/volumes_test.go b/api/kubernetes/cli/volumes_test.go index 9a37e487c9..283fb7c498 100644 --- a/api/kubernetes/cli/volumes_test.go +++ b/api/kubernetes/cli/volumes_test.go @@ -7,6 +7,7 @@ import ( ) func TestGetVolumes(t *testing.T) { + t.Parallel() kcl := &KubeClient{} volumes, err := kcl.GetVolumes("default") diff --git a/api/kubernetes/kubeclusteraccess_service_test.go b/api/kubernetes/kubeclusteraccess_service_test.go index d13157532e..156c2a1d62 100644 --- a/api/kubernetes/kubeclusteraccess_service_test.go +++ b/api/kubernetes/kubeclusteraccess_service_test.go @@ -46,6 +46,7 @@ func createTempFile(filename, content string, t *testing.T) string { } func Test_getCertificateAuthorityData(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("getCertificateAuthorityData fails on tls cert not provided", func(t *testing.T) { @@ -75,6 +76,7 @@ func Test_getCertificateAuthorityData(t *testing.T) { } func TestKubeClusterAccessService_IsSecure(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("IsSecure should be false", func(t *testing.T) { @@ -91,6 +93,7 @@ func TestKubeClusterAccessService_IsSecure(t *testing.T) { } func TestKubeClusterAccessService_GetKubeConfigInternal(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("GetClusterDetails contains host address", func(t *testing.T) { diff --git a/api/kubernetes/yaml_test.go b/api/kubernetes/yaml_test.go index 56935fa381..cf267c6abd 100644 --- a/api/kubernetes/yaml_test.go +++ b/api/kubernetes/yaml_test.go @@ -8,6 +8,7 @@ import ( ) func Test_AddAppLabels(t *testing.T) { + t.Parallel() tests := []struct { name string input string @@ -437,6 +438,7 @@ spec: } func Test_AddAppLabels_HelmApp(t *testing.T) { + t.Parallel() labels := GetHelmAppLabels("best-name", "best-owner") tests := []struct { @@ -601,6 +603,7 @@ spec: } func Test_DocumentSeperator(t *testing.T) { + t.Parallel() labels := KubeAppLabels{ StackID: 123, StackName: "best-name", @@ -650,6 +653,7 @@ metadata: } func Test_GetNamespace(t *testing.T) { + t.Parallel() tests := []struct { name string input string @@ -683,6 +687,7 @@ kind: Namespace } func Test_ExtractDocuments(t *testing.T) { + t.Parallel() tests := []struct { name string input string diff --git a/api/ldap/ldap_test.go b/api/ldap/ldap_test.go index 1e791f3513..fcc254c2a6 100644 --- a/api/ldap/ldap_test.go +++ b/api/ldap/ldap_test.go @@ -13,6 +13,7 @@ import ( ) func TestCreateConnectionForURL(t *testing.T) { + t.Parallel() fips.InitFIPS(false) srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) @@ -71,6 +72,7 @@ func TestCreateConnectionForURL(t *testing.T) { } func TestFailures(t *testing.T) { + t.Parallel() s := Service{} err := s.AuthenticateUser("username", "password", &portainer.LDAPSettings{}) diff --git a/api/motd/service_test.go b/api/motd/service_test.go index 582a7113bf..283b47460b 100644 --- a/api/motd/service_test.go +++ b/api/motd/service_test.go @@ -9,11 +9,13 @@ import ( ) func TestGetCached_InitiallyEmpty(t *testing.T) { + t.Parallel() svc := NewService("http://unused") assert.Equal(t, Motd{}, svc.GetCached()) } func TestRefresh_Success_PopulatesCache(t *testing.T) { + t.Parallel() ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") _, _ = w.Write([]byte(`{"title":"Test title","message":["Hello","world"]}`)) @@ -30,6 +32,7 @@ func TestRefresh_Success_PopulatesCache(t *testing.T) { } func TestRefresh_FetchError_KeepsPreviousCache(t *testing.T) { + t.Parallel() // First populate cache with good data good := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") @@ -50,6 +53,7 @@ func TestRefresh_FetchError_KeepsPreviousCache(t *testing.T) { } func TestRefresh_InvalidJSON_KeepsPreviousCache(t *testing.T) { + t.Parallel() good := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") _, _ = w.Write([]byte(`{"title":"Cached","message":["Cached message"]}`)) @@ -73,6 +77,7 @@ func TestRefresh_InvalidJSON_KeepsPreviousCache(t *testing.T) { } func TestRefresh_FetchError_CacheRemainsEmpty(t *testing.T) { + t.Parallel() svc := NewService("http://127.0.0.1:0") // unreachable svc.refresh() assert.Equal(t, Motd{}, svc.GetCached()) diff --git a/api/oauth/oauth_resource_test.go b/api/oauth/oauth_resource_test.go index 745bcaea04..99685875ac 100644 --- a/api/oauth/oauth_resource_test.go +++ b/api/oauth/oauth_resource_test.go @@ -7,6 +7,7 @@ import ( ) func Test_getUsername(t *testing.T) { + t.Parallel() t.Run("fails for non-matching user identifier", func(t *testing.T) { oauthSettings := &portainer.OAuthSettings{UserIdentifier: "username"} datamap := map[string]any{"name": "john"} diff --git a/api/oauth/oauth_test.go b/api/oauth/oauth_test.go index 22cc80f158..823107b427 100644 --- a/api/oauth/oauth_test.go +++ b/api/oauth/oauth_test.go @@ -14,6 +14,7 @@ import ( ) func Test_getOAuthToken(t *testing.T) { + t.Parallel() validCode := "valid-code" srv, config := oauthtest.RunOAuthServer(validCode, &portainer.OAuthSettings{}) defer srv.Close() @@ -36,6 +37,7 @@ func Test_getOAuthToken(t *testing.T) { } func Test_getIdToken(t *testing.T) { + t.Parallel() verifiedToken := `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2NTM1NDA3MjksImV4cCI6MTY4NTA3NjcyOSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJHaXZlbk5hbWUiOiJKb2huIiwiU3VybmFtZSI6IkRvZSIsIkdyb3VwcyI6WyJGaXJzdCIsIlNlY29uZCJdfQ.GeU8XCV4Y4p5Vm-i63Aj7UP5zpb_0Zxb7-DjM2_z-s8` nonVerifiedToken := `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJPbmxpbmUgSldUIEJ1aWxkZXIiLCJpYXQiOjE2NTM1NDA3MjksImV4cCI6MTY4NTA3NjcyOSwiYXVkIjoid3d3LmV4YW1wbGUuY29tIiwic3ViIjoiam9obi5kb2VAZXhhbXBsZS5jb20iLCJHaXZlbk5hbWUiOiJKb2huIiwiU3VybmFtZSI6IkRvZSIsIkdyb3VwcyI6WyJGaXJzdCIsIlNlY29uZCJdfQ.` claims := map[string]any{ @@ -90,6 +92,7 @@ func Test_getIdToken(t *testing.T) { } func Test_getResource(t *testing.T) { + t.Parallel() srv, config := oauthtest.RunOAuthServer("", &portainer.OAuthSettings{}) defer srv.Close() @@ -113,6 +116,7 @@ func Test_getResource(t *testing.T) { } func Test_getResource_malformedContentType(t *testing.T) { + t.Parallel() body := `{"username":"test-oauth-user"}` tests := []struct { @@ -146,6 +150,7 @@ func Test_getResource_malformedContentType(t *testing.T) { } func Test_Authenticate(t *testing.T) { + t.Parallel() code := "valid-code" authService := NewService() diff --git a/api/pendingactions/handlers/delete_k8s_registry_secrets_test.go b/api/pendingactions/handlers/delete_k8s_registry_secrets_test.go index 1fd77101ed..2b5a4e901a 100644 --- a/api/pendingactions/handlers/delete_k8s_registry_secrets_test.go +++ b/api/pendingactions/handlers/delete_k8s_registry_secrets_test.go @@ -30,6 +30,7 @@ func buildPendingAction(endpointID portainer.EndpointID, registryID portainer.Re } func TestHandlerDeleteK8sRegistrySecrets_Execute(t *testing.T) { + t.Parallel() const endpointID portainer.EndpointID = 1 const registryID portainer.RegistryID = 3 diff --git a/api/pendingactions/pendingactions_test.go b/api/pendingactions/pendingactions_test.go index 89e3e98ca9..e0685e3b82 100644 --- a/api/pendingactions/pendingactions_test.go +++ b/api/pendingactions/pendingactions_test.go @@ -10,6 +10,7 @@ import ( ) func TestExecute(t *testing.T) { + t.Parallel() tests := []struct { name string endpoint *portainer.Endpoint diff --git a/api/roar/roar_test.go b/api/roar/roar_test.go index b9a25dd635..3f2ed73ba2 100644 --- a/api/roar/roar_test.go +++ b/api/roar/roar_test.go @@ -9,6 +9,7 @@ import ( ) func TestRoar(t *testing.T) { + t.Parallel() r := Roar[int]{} require.Equal(t, 0, r.Len()) @@ -62,6 +63,7 @@ func TestRoar(t *testing.T) { } func TestNilSafety(t *testing.T) { + t.Parallel() var r, s, u Roar[int] r.Iterate(func(id int) bool { @@ -104,6 +106,7 @@ func TestNilSafety(t *testing.T) { } func TestJSON(t *testing.T) { + t.Parallel() var r, u Roar[int] r.Add(1) diff --git a/api/scheduler/scheduler_test.go b/api/scheduler/scheduler_test.go index 8ca8b86d31..5f5d02025c 100644 --- a/api/scheduler/scheduler_test.go +++ b/api/scheduler/scheduler_test.go @@ -19,6 +19,7 @@ func requireNoShutdownErr(t *testing.T, fn func() error) { } func Test_ScheduledJobRuns(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { s := NewScheduler(t.Context()) defer requireNoShutdownErr(t, s.Shutdown) @@ -40,6 +41,7 @@ func Test_ScheduledJobRuns(t *testing.T) { } func Test_JobCanBeStopped(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { s := NewScheduler(t.Context()) defer requireNoShutdownErr(t, s.Shutdown) @@ -64,6 +66,7 @@ func Test_JobCanBeStopped(t *testing.T) { } func Test_JobShouldStop_UponPermError(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { s := NewScheduler(t.Context()) defer requireNoShutdownErr(t, s.Shutdown) @@ -85,6 +88,7 @@ func Test_JobShouldStop_UponPermError(t *testing.T) { } func Test_JobShouldNotStop_UponError(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { s := NewScheduler(t.Context()) defer requireNoShutdownErr(t, s.Shutdown) @@ -109,6 +113,7 @@ func Test_JobShouldNotStop_UponError(t *testing.T) { } func Test_CanTerminateAllJobs_ByShuttingDownScheduler(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { s := NewScheduler(t.Context()) @@ -130,6 +135,7 @@ func Test_CanTerminateAllJobs_ByShuttingDownScheduler(t *testing.T) { } func Test_CanTerminateAllJobs_ByCancellingParentContext(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { ctx, cancel := context.WithTimeout(t.Context(), 2*jobInterval) s := NewScheduler(ctx) @@ -150,6 +156,7 @@ func Test_CanTerminateAllJobs_ByCancellingParentContext(t *testing.T) { } func Test_StartJobEvery_Concurrently(t *testing.T) { + t.Parallel() synctest.Test(t, func(t *testing.T) { ctx, cancel := context.WithTimeout(t.Context(), 2*jobInterval) s := NewScheduler(ctx) diff --git a/api/slicesx/filter_test.go b/api/slicesx/filter_test.go index febe4aa115..40d4376fee 100644 --- a/api/slicesx/filter_test.go +++ b/api/slicesx/filter_test.go @@ -9,6 +9,7 @@ import ( ) func Test_Filter(t *testing.T) { + t.Parallel() test(t, slicesx.Filter, "Filter even numbers", []int{1, 2, 3, 4, 5, 6, 7, 8, 9}, []int{2, 4, 6, 8}, @@ -32,6 +33,7 @@ func Test_Filter(t *testing.T) { } func Test_Retain(t *testing.T) { + t.Parallel() test(t, slicesx.FilterInPlace, "Filter even numbers", []int{1, 2, 3, 4, 5, 6, 7, 8, 9}, []int{2, 4, 6, 8}, diff --git a/api/slicesx/flatten_test.go b/api/slicesx/flatten_test.go index 6875c4e6b4..5a6bca185c 100644 --- a/api/slicesx/flatten_test.go +++ b/api/slicesx/flatten_test.go @@ -8,6 +8,7 @@ import ( ) func Test_Flatten(t *testing.T) { + t.Parallel() t.Run("Flatten an array of arrays", func(t *testing.T) { is := assert.New(t) diff --git a/api/slicesx/includes_test.go b/api/slicesx/includes_test.go index a3f074c1c7..6c36d32c13 100644 --- a/api/slicesx/includes_test.go +++ b/api/slicesx/includes_test.go @@ -7,6 +7,7 @@ import ( ) func Test_Every(t *testing.T) { + t.Parallel() test(t, slicesx.Every, "All start with an A (ok)", []string{"Apple", "Avocado", "Apricot"}, true, @@ -43,6 +44,7 @@ func Test_Every(t *testing.T) { } func Test_Some(t *testing.T) { + t.Parallel() test(t, slicesx.Some, "Some start with an A (ok)", []string{"Apple", "Avocado", "Banana"}, true, diff --git a/api/slicesx/map_test.go b/api/slicesx/map_test.go index a2cd2256de..1d44c27315 100644 --- a/api/slicesx/map_test.go +++ b/api/slicesx/map_test.go @@ -8,6 +8,7 @@ import ( ) func Test_Map(t *testing.T) { + t.Parallel() test(t, slicesx.Map, "Map integers to strings", []int{1, 2, 3, 4, 5}, []string{"1", "2", "3", "4", "5"}, @@ -24,6 +25,7 @@ func Test_Map(t *testing.T) { } func Test_FlatMap(t *testing.T) { + t.Parallel() test(t, slicesx.FlatMap, "Map integers to strings and flatten", []int{1, 2, 3, 4, 5}, []string{"1", "1", "2", "2", "3", "3", "4", "4", "5", "5"}, diff --git a/api/slicesx/unique_test.go b/api/slicesx/unique_test.go index 8ff967ca61..298465aeed 100644 --- a/api/slicesx/unique_test.go +++ b/api/slicesx/unique_test.go @@ -8,6 +8,7 @@ import ( ) func Test_Unique(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("Should extract unique numbers", func(t *testing.T) { @@ -27,6 +28,7 @@ func Test_Unique(t *testing.T) { } func Test_UniqueBy(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("Should extract unique numbers by property", func(t *testing.T) { diff --git a/api/stacks/deployments/deploy_test.go b/api/stacks/deployments/deploy_test.go index a6c4c2e44d..65c729e6fb 100644 --- a/api/stacks/deployments/deploy_test.go +++ b/api/stacks/deployments/deploy_test.go @@ -157,6 +157,7 @@ func agentServer(t *testing.T) string { } func Test_redeployWhenChanged_FailsWhenCannotFindStack(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) err := RedeployWhenChanged(t.Context(), 1, nil, store, nil) @@ -165,6 +166,7 @@ func Test_redeployWhenChanged_FailsWhenCannotFindStack(t *testing.T) { } func Test_redeployWhenChanged_DoesNothingWhenNotAGitBasedStack(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) admin := &portainer.User{ID: 1, Username: "admin"} @@ -179,6 +181,7 @@ func Test_redeployWhenChanged_DoesNothingWhenNotAGitBasedStack(t *testing.T) { } func Test_redeployWhenChanged_DoesNothingWhenNoGitChanges(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) tmpDir := t.TempDir() @@ -243,6 +246,7 @@ func Test_redeployWhenChanged_FailsWhenCannotClone(t *testing.T) { } func Test_redeployWhenChanged(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) tmpDir := t.TempDir() @@ -298,6 +302,7 @@ func Test_redeployWhenChanged(t *testing.T) { } func Test_getUserRegistries(t *testing.T) { + t.Parallel() _, store := datastore.MustNewTestStore(t, false, true) endpointID := 123 diff --git a/api/stacks/stackbuilders/k8s_file_content_builder_test.go b/api/stacks/stackbuilders/k8s_file_content_builder_test.go index 81b34410e8..400e30df2a 100644 --- a/api/stacks/stackbuilders/k8s_file_content_builder_test.go +++ b/api/stacks/stackbuilders/k8s_file_content_builder_test.go @@ -16,6 +16,7 @@ func (m mockDeploymentConfiger) GetResponse() string { } func TestGetResponse(t *testing.T) { + t.Parallel() c := &K8sStackFileContentBuilder{ FileContentMethodStackBuilder: FileContentMethodStackBuilder{ StackBuilder: StackBuilder{ diff --git a/api/stacks/stackbuilders/k8s_url_builder_test.go b/api/stacks/stackbuilders/k8s_url_builder_test.go index 9681037758..3f9d576dd8 100644 --- a/api/stacks/stackbuilders/k8s_url_builder_test.go +++ b/api/stacks/stackbuilders/k8s_url_builder_test.go @@ -7,6 +7,7 @@ import ( ) func TestK8SUrlBuilderGetResponse(t *testing.T) { + t.Parallel() c := &KubernetesStackUrlBuilder{ UrlMethodStackBuilder: UrlMethodStackBuilder{ StackBuilder: StackBuilder{ diff --git a/api/stacks/stackutils/util_test.go b/api/stacks/stackutils/util_test.go index 79d64b251d..ea2873e491 100644 --- a/api/stacks/stackutils/util_test.go +++ b/api/stacks/stackutils/util_test.go @@ -8,6 +8,7 @@ import ( ) func Test_GetStackFilePaths(t *testing.T) { + t.Parallel() stack := &portainer.Stack{ ProjectPath: "/tmp/stack/1", EntryPoint: "file-one.yml", diff --git a/api/stacks/stackutils/validation_test.go b/api/stacks/stackutils/validation_test.go index 28262dceab..678489f2a4 100644 --- a/api/stacks/stackutils/validation_test.go +++ b/api/stacks/stackutils/validation_test.go @@ -10,6 +10,7 @@ import ( ) func TestIsValidStackFile_DefaultPortEnvSubstitution(t *testing.T) { + t.Parallel() yamlContent := []byte(` version: "3" @@ -42,6 +43,7 @@ networks: // validation when the env var is not provided. Docker accepts an empty host port (left side) // but requires a valid container port (right side). func TestIsValidStackFile_MissingEnvVarBehavior(t *testing.T) { + t.Parallel() securitySettings := &portainer.EndpointSecuritySettings{} t.Run("var on left side only passes (docker allows :9090)", func(t *testing.T) { @@ -91,6 +93,7 @@ services: } func TestIsValidStackFile_EnvVarInBothPortFields(t *testing.T) { + t.Parallel() securitySettings := &portainer.EndpointSecuritySettings{} err := IsValidStackFile(StackFileValidationConfig{ Content: []byte(` @@ -123,6 +126,7 @@ func (m mockFileService) FormProjectPathByVersion(projectPath string, version in } func TestValidateStackFiles_EnvVars(t *testing.T) { + t.Parallel() fileContent := []byte(` version: "3" @@ -178,6 +182,7 @@ services: } func TestValidateStackFiles_DotEnvFile(t *testing.T) { + t.Parallel() tmpDir := t.TempDir() err := os.WriteFile(filepath.Join(tmpDir, ".env"), []byte("HOST_PORT=3000\n"), 0600) @@ -208,6 +213,7 @@ services: } func TestValidateStackFiles_EnvFileAttribute(t *testing.T) { + t.Parallel() tmpDir := t.TempDir() err := os.WriteFile(filepath.Join(tmpDir, "web.env"), []byte("HOST_PORT=3000\n"), 0600) @@ -238,6 +244,7 @@ services: } func TestValidateStackFiles_BindMountBlockedForNonAdmin(t *testing.T) { + t.Parallel() fileContent := []byte(` version: "3" diff --git a/api/tag/tag_match_test.go b/api/tag/tag_match_test.go index a540ba5442..651f6dca1b 100644 --- a/api/tag/tag_match_test.go +++ b/api/tag/tag_match_test.go @@ -7,6 +7,7 @@ import ( ) func TestFullMatch(t *testing.T) { + t.Parallel() cases := []struct { name string edgeGroupTags []portainer.TagID @@ -68,6 +69,7 @@ func TestFullMatch(t *testing.T) { } func TestPartialMatch(t *testing.T) { + t.Parallel() cases := []struct { name string edgeGroupTags []portainer.TagID diff --git a/api/tag/tag_test.go b/api/tag/tag_test.go index ea66110e28..07c9c8c9ce 100644 --- a/api/tag/tag_test.go +++ b/api/tag/tag_test.go @@ -8,6 +8,7 @@ import ( ) func TestIntersectionCount(t *testing.T) { + t.Parallel() cases := []struct { name string setA tagSet @@ -57,6 +58,7 @@ func TestIntersectionCount(t *testing.T) { } func TestUnion(t *testing.T) { + t.Parallel() cases := []struct { name string setA tagSet @@ -106,6 +108,7 @@ func TestUnion(t *testing.T) { } func TestContains(t *testing.T) { + t.Parallel() cases := []struct { name string setA tagSet @@ -167,6 +170,7 @@ func TestContains(t *testing.T) { } func TestDifference(t *testing.T) { + t.Parallel() cases := []struct { name string setA tagSet diff --git a/api/uac/configs_test.go b/api/uac/configs_test.go index a690e39d74..f3b0059595 100644 --- a/api/uac/configs_test.go +++ b/api/uac/configs_test.go @@ -14,6 +14,7 @@ import ( ) func TestConfigResourceControlGetter(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/uac/containers_test.go b/api/uac/containers_test.go index 0032b6059f..ec29be647f 100644 --- a/api/uac/containers_test.go +++ b/api/uac/containers_test.go @@ -14,6 +14,7 @@ import ( ) func TestContainerResourceControlGetter(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/uac/generic_rc_getter_test.go b/api/uac/generic_rc_getter_test.go index 3f664a2f4f..93d0ffbd25 100644 --- a/api/uac/generic_rc_getter_test.go +++ b/api/uac/generic_rc_getter_test.go @@ -13,6 +13,7 @@ import ( ) func TestGenericResourcControlGetter(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) @@ -80,6 +81,7 @@ func TestGenericResourcControlGetter(t *testing.T) { } func TestGenericResourcControlGetterWithPortainerLabels(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/uac/networks_test.go b/api/uac/networks_test.go index 825b3cff48..23d0c26f12 100644 --- a/api/uac/networks_test.go +++ b/api/uac/networks_test.go @@ -14,6 +14,7 @@ import ( ) func TestNetworkResourceControlGetter(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/uac/secrets_test.go b/api/uac/secrets_test.go index bbeeeb411a..fe976ed0f9 100644 --- a/api/uac/secrets_test.go +++ b/api/uac/secrets_test.go @@ -14,6 +14,7 @@ import ( ) func TestSecretResourceControlGetter(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/uac/uac_test.go b/api/uac/uac_test.go index 619c023e7a..08eb423947 100644 --- a/api/uac/uac_test.go +++ b/api/uac/uac_test.go @@ -13,6 +13,7 @@ import ( ) func TestCanBypassUAC(t *testing.T) { + t.Parallel() is := require.New(t) admin := &portainer.User{Role: portainer.AdministratorRole} @@ -24,6 +25,7 @@ func TestCanBypassUAC(t *testing.T) { } func TestFilterByResourceControl(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) diff --git a/api/uac/volumes_test.go b/api/uac/volumes_test.go index fa825fce73..7dfde42e70 100644 --- a/api/uac/volumes_test.go +++ b/api/uac/volumes_test.go @@ -14,6 +14,7 @@ import ( ) func TestVolumeResourceControlGetter(t *testing.T) { + t.Parallel() is := require.New(t) ok, store := datastore.MustNewTestStore(t, true, false) diff --git a/pkg/authorization/resolver_test.go b/pkg/authorization/resolver_test.go index 3a7227c62c..80444b2117 100644 --- a/pkg/authorization/resolver_test.go +++ b/pkg/authorization/resolver_test.go @@ -40,6 +40,7 @@ var ( ) func TestComputeBaseRole_UserEndpointAccess(t *testing.T) { + t.Parallel() is := assert.New(t) user := &portainer.User{ID: 1} @@ -67,6 +68,7 @@ func TestComputeBaseRole_UserEndpointAccess(t *testing.T) { } func TestComputeBaseRole_UserGroupAccess(t *testing.T) { + t.Parallel() is := assert.New(t) user := &portainer.User{ID: 1} @@ -100,6 +102,7 @@ func TestComputeBaseRole_UserGroupAccess(t *testing.T) { } func TestComputeBaseRole_TeamEndpointAccess(t *testing.T) { + t.Parallel() is := assert.New(t) user := &portainer.User{ID: 1} @@ -130,6 +133,7 @@ func TestComputeBaseRole_TeamEndpointAccess(t *testing.T) { } func TestComputeBaseRole_TeamGroupAccess(t *testing.T) { + t.Parallel() is := assert.New(t) user := &portainer.User{ID: 1} @@ -167,6 +171,7 @@ func TestComputeBaseRole_TeamGroupAccess(t *testing.T) { } func TestComputeBaseRole_Precedence(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("User endpoint access takes precedence over group access", func(t *testing.T) { @@ -263,6 +268,7 @@ func TestComputeBaseRole_Precedence(t *testing.T) { } func TestComputeBaseRole_NoAccess(t *testing.T) { + t.Parallel() is := assert.New(t) user := &portainer.User{ID: 1} @@ -293,6 +299,7 @@ func TestComputeBaseRole_NoAccess(t *testing.T) { } func TestComputeBaseRole_MultipleTeams_HighestPriorityWins(t *testing.T) { + t.Parallel() is := assert.New(t) user := &portainer.User{ID: 1} @@ -326,6 +333,7 @@ func TestComputeBaseRole_MultipleTeams_HighestPriorityWins(t *testing.T) { } func TestResolveUserEndpointAccess(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("Returns resolved access with role and authorizations", func(t *testing.T) { @@ -366,6 +374,7 @@ func TestResolveUserEndpointAccess(t *testing.T) { } func TestFindRoleByID(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("Finds existing role", func(t *testing.T) { @@ -386,6 +395,7 @@ func TestFindRoleByID(t *testing.T) { } func TestGetHighestPriorityRole(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("Returns nil for empty slice", func(t *testing.T) { diff --git a/pkg/edge/utils_test.go b/pkg/edge/utils_test.go index c53daee723..c89f162df9 100644 --- a/pkg/edge/utils_test.go +++ b/pkg/edge/utils_test.go @@ -8,6 +8,7 @@ import ( ) func TestGetPortainerURLFromEdgeKey(t *testing.T) { + t.Parallel() tests := []struct { name string edgeKey string @@ -30,6 +31,7 @@ func TestGetPortainerURLFromEdgeKey(t *testing.T) { } func TestIsValidEdgeStackName(t *testing.T) { + t.Parallel() f := func(name string, expected bool) { if IsValidEdgeStackName(name) != expected { t.Fatalf("expected %v, found %v", expected, IsValidEdgeStackName(name)) diff --git a/pkg/endpoints/utils_test.go b/pkg/endpoints/utils_test.go index 2e33107be0..03a894d138 100644 --- a/pkg/endpoints/utils_test.go +++ b/pkg/endpoints/utils_test.go @@ -8,6 +8,7 @@ import ( ) func TestIsRegularAgentEndpoint(t *testing.T) { + t.Parallel() tests := []struct { name string endpoint *portainer.Endpoint @@ -52,6 +53,7 @@ func TestIsRegularAgentEndpoint(t *testing.T) { } func TestIsEdgeEndpoint(t *testing.T) { + t.Parallel() tests := []struct { name string endpoint *portainer.Endpoint @@ -89,6 +91,7 @@ func TestIsEdgeEndpoint(t *testing.T) { } func TestIsAssociatedEdgeEndpoint(t *testing.T) { + t.Parallel() tests := []struct { name string endpoint *portainer.Endpoint @@ -141,6 +144,7 @@ func TestIsAssociatedEdgeEndpoint(t *testing.T) { } func TestHasDirectConnectivity(t *testing.T) { + t.Parallel() tests := []struct { name string endpoint *portainer.Endpoint @@ -204,6 +208,7 @@ func TestHasDirectConnectivity(t *testing.T) { } func TestIsStandardEdgeEndpoint(t *testing.T) { + t.Parallel() tests := []struct { name string endpoint *portainer.Endpoint @@ -236,6 +241,7 @@ func TestIsStandardEdgeEndpoint(t *testing.T) { } func TestIsNewerThan225(t *testing.T) { + t.Parallel() tests := []struct { name string version string diff --git a/pkg/fips/fips_test.go b/pkg/fips/fips_test.go index c19a5210fc..f14beae49a 100644 --- a/pkg/fips/fips_test.go +++ b/pkg/fips/fips_test.go @@ -7,6 +7,7 @@ import ( ) func TestInitFIPS(t *testing.T) { + t.Parallel() InitFIPS(false) require.False(t, FIPSMode()) diff --git a/pkg/libcrypto/encrypt_test.go b/pkg/libcrypto/encrypt_test.go index 06d6d044be..44501509e8 100644 --- a/pkg/libcrypto/encrypt_test.go +++ b/pkg/libcrypto/encrypt_test.go @@ -14,6 +14,7 @@ func init() { } func TestEncryptDecrypt(t *testing.T) { + t.Parallel() dataFn := func() []byte { data := make([]byte, 1024) _, err := io.ReadFull(rand.Reader, data) diff --git a/pkg/libhelm/options/chart_reference_test.go b/pkg/libhelm/options/chart_reference_test.go index 06db8c26ed..89b7a24e4d 100644 --- a/pkg/libhelm/options/chart_reference_test.go +++ b/pkg/libhelm/options/chart_reference_test.go @@ -5,6 +5,7 @@ import ( ) func TestConstructChartReference(t *testing.T) { + t.Parallel() tests := []struct { name string registryURL string @@ -61,6 +62,7 @@ func TestConstructChartReference(t *testing.T) { } func TestConstructOCIRegistryReference(t *testing.T) { + t.Parallel() tests := []struct { name string registryURL string diff --git a/pkg/libhelm/sdk/client_test.go b/pkg/libhelm/sdk/client_test.go index 318f6bacda..51f0cd3648 100644 --- a/pkg/libhelm/sdk/client_test.go +++ b/pkg/libhelm/sdk/client_test.go @@ -13,6 +13,7 @@ import ( ) func Test_InitActionConfig(t *testing.T) { + t.Parallel() hspm := NewHelmSDKPackageManager() t.Run("with nil k8sAccess should use default kubeconfig", func(t *testing.T) { @@ -50,6 +51,7 @@ func Test_InitActionConfig(t *testing.T) { } func Test_ClientConfigGetter(t *testing.T) { + t.Parallel() is := assert.New(t) // Create a mock client config @@ -105,6 +107,7 @@ func Test_ClientConfigGetter(t *testing.T) { } func Test_ParseValues(t *testing.T) { + t.Parallel() is := assert.New(t) t.Run("should parse valid YAML values", func(t *testing.T) { diff --git a/pkg/libhelm/sdk/common_test.go b/pkg/libhelm/sdk/common_test.go index f9ea8a73b0..e746ae7e51 100644 --- a/pkg/libhelm/sdk/common_test.go +++ b/pkg/libhelm/sdk/common_test.go @@ -7,6 +7,7 @@ import ( ) func TestAppendChartReferenceAnnotations(t *testing.T) { + t.Parallel() tests := []struct { name string chartPath string @@ -83,6 +84,7 @@ func TestAppendChartReferenceAnnotations(t *testing.T) { } func TestAppendChartReferenceAnnotations_RepoURLLogic(t *testing.T) { + t.Parallel() t.Run("repoURL only added when registryID is zero", func(t *testing.T) { // With registry ID - no repoURL result := appendChartReferenceAnnotations("chart", "url", 5, 0, nil, nil) diff --git a/pkg/libhelm/sdk/get_test.go b/pkg/libhelm/sdk/get_test.go index da71aaec16..bbb90aa096 100644 --- a/pkg/libhelm/sdk/get_test.go +++ b/pkg/libhelm/sdk/get_test.go @@ -10,6 +10,7 @@ import ( ) func Test_Convert(t *testing.T) { + t.Parallel() t.Run("successfully maps a sdk release to a release", func(t *testing.T) { is := assert.New(t) diff --git a/pkg/libhelm/sdk/history_test.go b/pkg/libhelm/sdk/history_test.go index c7732a37d1..b152498b58 100644 --- a/pkg/libhelm/sdk/history_test.go +++ b/pkg/libhelm/sdk/history_test.go @@ -10,6 +10,7 @@ import ( ) func Test_ConvertHistory(t *testing.T) { + t.Parallel() t.Run("successfully maps a sdk release to a release", func(t *testing.T) { is := assert.New(t) diff --git a/pkg/libhelm/sdk/install_test.go b/pkg/libhelm/sdk/install_test.go index cb93c1b361..2c942b08d2 100644 --- a/pkg/libhelm/sdk/install_test.go +++ b/pkg/libhelm/sdk/install_test.go @@ -11,6 +11,7 @@ import ( ) func Test_Install(t *testing.T) { + t.Parallel() test.EnsureIntegrationTest(t) is := require.New(t) diff --git a/pkg/libhelm/sdk/list_test.go b/pkg/libhelm/sdk/list_test.go index b376bb25c5..4bf466502a 100644 --- a/pkg/libhelm/sdk/list_test.go +++ b/pkg/libhelm/sdk/list_test.go @@ -13,6 +13,7 @@ import ( ) func Test_ConvertToReleaseElements(t *testing.T) { + t.Parallel() is := assert.New(t) // Create mock releases diff --git a/pkg/libhelm/sdk/manager_test.go b/pkg/libhelm/sdk/manager_test.go index 69af64ac42..306909dc87 100644 --- a/pkg/libhelm/sdk/manager_test.go +++ b/pkg/libhelm/sdk/manager_test.go @@ -10,6 +10,7 @@ import ( ) func Test_NewHelmSDKPackageManager(t *testing.T) { + t.Parallel() is := assert.New(t) // Test that NewHelmSDKPackageManager returns a non-nil HelmPackageManager diff --git a/pkg/libhelm/sdk/resources_test.go b/pkg/libhelm/sdk/resources_test.go index 0adb30bb37..3b3379476c 100644 --- a/pkg/libhelm/sdk/resources_test.go +++ b/pkg/libhelm/sdk/resources_test.go @@ -11,6 +11,7 @@ import ( ) func TestParseResources(t *testing.T) { + t.Parallel() t.Run("successfully parse single resource", func(t *testing.T) { resourceTypesLists := map[string][]runtime.Object{ "v1/Pod(related)": { @@ -108,6 +109,7 @@ func TestParseResources(t *testing.T) { } func TestEnhanceStatus(t *testing.T) { + t.Parallel() t.Run("healthy running pod", func(t *testing.T) { // Create a ResourceStatus object status := &ResourceStatus{ diff --git a/pkg/libhelm/sdk/rollback_test.go b/pkg/libhelm/sdk/rollback_test.go index 883b7e3383..3ded433ab0 100644 --- a/pkg/libhelm/sdk/rollback_test.go +++ b/pkg/libhelm/sdk/rollback_test.go @@ -10,6 +10,7 @@ import ( ) func TestRollback(t *testing.T) { + t.Parallel() test.EnsureIntegrationTest(t) is := assert.New(t) diff --git a/pkg/libhelm/sdk/search_repo_test.go b/pkg/libhelm/sdk/search_repo_test.go index 9afa22c004..0f7c4bcc8f 100644 --- a/pkg/libhelm/sdk/search_repo_test.go +++ b/pkg/libhelm/sdk/search_repo_test.go @@ -24,6 +24,7 @@ var tests = []testCase{ } func Test_SearchRepo(t *testing.T) { + t.Parallel() is := assert.New(t) // Create a new SDK package manager diff --git a/pkg/libhelm/sdk/show_test.go b/pkg/libhelm/sdk/show_test.go index f625321d0d..3c9de0dea0 100644 --- a/pkg/libhelm/sdk/show_test.go +++ b/pkg/libhelm/sdk/show_test.go @@ -10,6 +10,7 @@ import ( ) func Test_Show(t *testing.T) { + t.Parallel() test.EnsureIntegrationTest(t) is := assert.New(t) diff --git a/pkg/libhelm/sdk/uninstall_test.go b/pkg/libhelm/sdk/uninstall_test.go index 85251cfde5..3534a1c919 100644 --- a/pkg/libhelm/sdk/uninstall_test.go +++ b/pkg/libhelm/sdk/uninstall_test.go @@ -10,6 +10,7 @@ import ( ) func Test_Uninstall(t *testing.T) { + t.Parallel() test.EnsureIntegrationTest(t) is := assert.New(t) diff --git a/pkg/libhelm/sdk/upgrade_test.go b/pkg/libhelm/sdk/upgrade_test.go index 32d7e9be9c..59bb722eb1 100644 --- a/pkg/libhelm/sdk/upgrade_test.go +++ b/pkg/libhelm/sdk/upgrade_test.go @@ -10,6 +10,7 @@ import ( ) func TestUpgrade(t *testing.T) { + t.Parallel() test.EnsureIntegrationTest(t) is := require.New(t) diff --git a/pkg/libhelm/sdk/values_test.go b/pkg/libhelm/sdk/values_test.go index b7e1ee279b..a2fbe0fdd9 100644 --- a/pkg/libhelm/sdk/values_test.go +++ b/pkg/libhelm/sdk/values_test.go @@ -10,6 +10,7 @@ import ( ) func TestMergeValues(t *testing.T) { + t.Parallel() tests := []struct { name string base map[string]any @@ -185,6 +186,7 @@ func TestMergeValues(t *testing.T) { } func TestGetHelmValuesFromFile(t *testing.T) { + t.Parallel() // Create a temporary directory for test files tempDir := t.TempDir() diff --git a/pkg/libhelm/validate_repo_test.go b/pkg/libhelm/validate_repo_test.go index 1635df21ac..597675b945 100644 --- a/pkg/libhelm/validate_repo_test.go +++ b/pkg/libhelm/validate_repo_test.go @@ -11,6 +11,7 @@ import ( ) func Test_ValidateHelmRepositoryURL(t *testing.T) { + t.Parallel() test.EnsureIntegrationTest(t) type testCase struct { @@ -53,6 +54,7 @@ func Test_ValidateHelmRepositoryURL(t *testing.T) { } func TestValidateHelmRepositoryURL(t *testing.T) { + t.Parallel() var fail bool const indexYAML = "apiVersion: v1\nentries: {}\ngenerated: \"2020-01-01T00:00:00Z\"\n" diff --git a/pkg/libhttp/request/payload_test.go b/pkg/libhttp/request/payload_test.go index bc355ab88c..9b41d836e2 100644 --- a/pkg/libhttp/request/payload_test.go +++ b/pkg/libhttp/request/payload_test.go @@ -22,6 +22,7 @@ func (p *requestPayload) Validate(r *http.Request) error { } func Test_GetPayload(t *testing.T) { + t.Parallel() payload := requestPayload{ FirstName: "John", LastName: "Doe", diff --git a/pkg/libhttp/request/request_test.go b/pkg/libhttp/request/request_test.go index f8139465b1..1ca6de8863 100644 --- a/pkg/libhttp/request/request_test.go +++ b/pkg/libhttp/request/request_test.go @@ -6,6 +6,7 @@ import ( ) func TestRetrieveQueryParameter(t *testing.T) { + t.Parallel() tests := []struct { name string url string @@ -57,6 +58,7 @@ func TestRetrieveQueryParameter(t *testing.T) { } func TestRetrieveNumericQueryParameter(t *testing.T) { + t.Parallel() tests := []struct { name string url string @@ -108,6 +110,7 @@ func TestRetrieveNumericQueryParameter(t *testing.T) { } func TestRetrieveBooleanQueryParameter(t *testing.T) { + t.Parallel() tests := []struct { name string url string @@ -159,6 +162,7 @@ func TestRetrieveBooleanQueryParameter(t *testing.T) { } func TestRetrieveArrayQueryParameter(t *testing.T) { + t.Parallel() tests := []struct { name string url string @@ -218,6 +222,7 @@ func TestRetrieveArrayQueryParameter(t *testing.T) { } func TestRetrieveNumberArrayQueryParameter(t *testing.T) { + t.Parallel() tests := []struct { name string url string diff --git a/pkg/libhttp/response/response_test.go b/pkg/libhttp/response/response_test.go index a501c9d5be..064afc427a 100644 --- a/pkg/libhttp/response/response_test.go +++ b/pkg/libhttp/response/response_test.go @@ -11,6 +11,7 @@ import ( ) func TestJSONWithStatus(t *testing.T) { + t.Parallel() type TestData struct { Message string `json:"message"` } @@ -52,6 +53,7 @@ func TestJSONWithStatus(t *testing.T) { } func TestJSON(t *testing.T) { + t.Parallel() type TestData struct { Message string `json:"message"` } @@ -87,6 +89,7 @@ func TestJSON(t *testing.T) { } func TestYAML(t *testing.T) { + t.Parallel() tests := []struct { name string data any @@ -135,6 +138,7 @@ func TestYAML(t *testing.T) { } func TestEmpty(t *testing.T) { + t.Parallel() recorder := httptest.NewRecorder() httpErr := Empty(recorder) diff --git a/pkg/libhttp/response/txresponse_test.go b/pkg/libhttp/response/txresponse_test.go index 5094b4c4f1..8c18519eaa 100644 --- a/pkg/libhttp/response/txresponse_test.go +++ b/pkg/libhttp/response/txresponse_test.go @@ -12,6 +12,7 @@ import ( ) func TestTxResponse(t *testing.T) { + t.Parallel() type sample struct { Name string `json:"name"` } @@ -35,6 +36,7 @@ func TestTxResponse(t *testing.T) { } func TestTxEmptyResponse(t *testing.T) { + t.Parallel() w := httptest.NewRecorder() got := TxEmptyResponse(w, nil) require.Nil(t, got) @@ -54,6 +56,7 @@ func TestTxEmptyResponse(t *testing.T) { } func TestTxFuncResponse(t *testing.T) { + t.Parallel() got := TxFuncResponse(nil, func() *httperror.HandlerError { return nil }) require.Nil(t, got) @@ -69,6 +72,7 @@ func TestTxFuncResponse(t *testing.T) { } func TestTxErrorResponse(t *testing.T) { + t.Parallel() got := TxErrorResponse(nil) require.NotNil(t, got) require.Equal(t, http.StatusInternalServerError, got.StatusCode) diff --git a/pkg/libkompose/convert_test.go b/pkg/libkompose/convert_test.go index f5895571a6..ef61a73dce 100644 --- a/pkg/libkompose/convert_test.go +++ b/pkg/libkompose/convert_test.go @@ -8,6 +8,7 @@ import ( ) func Test_getDefaultConvertOptions(t *testing.T) { + t.Parallel() tests := []struct { name string opts *ConvertOptions @@ -179,18 +180,21 @@ func Test_getDefaultConvertOptions(t *testing.T) { } func Test_ConvertComposeFiles_EmptyInput(t *testing.T) { + t.Parallel() _, err := ConvertComposeFiles(nil, nil) require.Error(t, err) assert.Contains(t, err.Error(), "at least one compose file is required") } func Test_ConvertComposeFiles_EmptySlice(t *testing.T) { + t.Parallel() _, err := ConvertComposeFiles([]string{}, nil) require.Error(t, err) assert.Contains(t, err.Error(), "at least one compose file is required") } func Test_ConvertComposeFiles_InvalidOptions(t *testing.T) { + t.Parallel() _, err := ConvertComposeFiles([]string{"/nonexistent/docker-compose.yml"}, &ConvertOptions{ Provider: "invalid", }) diff --git a/pkg/libkubectl/apply_dynamic_test.go b/pkg/libkubectl/apply_dynamic_test.go index 2b173b20a8..34cb8e8be3 100644 --- a/pkg/libkubectl/apply_dynamic_test.go +++ b/pkg/libkubectl/apply_dynamic_test.go @@ -47,6 +47,7 @@ func skipIfNoKubeconfig(tb testing.TB) string { } func TestApplyDynamic(t *testing.T) { + t.Parallel() tests := []struct { name string manifests []string @@ -604,6 +605,7 @@ func newTestMapper() meta.RESTMapper { // TestApplyResource unit tests for applyResource using fake client (no cluster needed) func TestApplyResource(t *testing.T) { + t.Parallel() client := &Client{} // applyResource doesn't use Client fields directly dynamicClient := newFakeDynamicClient() mapper := newTestMapper() @@ -704,6 +706,7 @@ metadata: } func TestIsManifestFile(t *testing.T) { + t.Parallel() tests := []struct { name string resource string diff --git a/pkg/libkubectl/client_test.go b/pkg/libkubectl/client_test.go index 4f2eae750a..aaed28d867 100644 --- a/pkg/libkubectl/client_test.go +++ b/pkg/libkubectl/client_test.go @@ -7,6 +7,7 @@ import ( ) func TestGenerateConfigFlags(t *testing.T) { + t.Parallel() config, err := generateConfigFlags("test-token", "https://api.example.com", "", "", false) require.NoError(t, err) require.NotNil(t, config) @@ -16,6 +17,7 @@ func TestGenerateConfigFlags(t *testing.T) { } func TestNewClient(t *testing.T) { + t.Parallel() // Test with server and token client, err := NewClient(&ClientAccess{ Token: "test-token", @@ -31,6 +33,7 @@ func TestNewClient(t *testing.T) { } func TestNewClientWithKubeconfig(t *testing.T) { + t.Parallel() // Test with kubeconfig path client, err := NewClient(&ClientAccess{ Token: "", @@ -46,6 +49,7 @@ func TestNewClientWithKubeconfig(t *testing.T) { } func TestNewClientError(t *testing.T) { + t.Parallel() // Test error case when both server and kubeconfig are empty client, err := NewClient(&ClientAccess{ Token: "", diff --git a/pkg/libkubectl/delete_dynamic_test.go b/pkg/libkubectl/delete_dynamic_test.go index 93deeae163..2ffe263925 100644 --- a/pkg/libkubectl/delete_dynamic_test.go +++ b/pkg/libkubectl/delete_dynamic_test.go @@ -16,6 +16,7 @@ import ( // Resource type coverage is handled by ApplyDynamic tests. func TestDeleteDynamic(t *testing.T) { + t.Parallel() tests := []struct { name string manifests []string @@ -160,6 +161,7 @@ data: // TestDeleteDynamicAlreadyDeleted tests the behavior when deleting resources that were already deleted func TestDeleteDynamicAlreadyDeleted(t *testing.T) { + t.Parallel() kubeconfig := skipIfNoKubeconfig(t) manifest := []string{ @@ -190,6 +192,7 @@ data: // TestDeleteDynamicPartialFailure tests deletion when some resources fail func TestDeleteDynamicPartialFailure(t *testing.T) { + t.Parallel() kubeconfig := skipIfNoKubeconfig(t) client, err := NewClient(&ClientAccess{}, "", kubeconfig, false) diff --git a/pkg/libkubectl/resource_test.go b/pkg/libkubectl/resource_test.go index 47016f4d4a..b8199bdd95 100644 --- a/pkg/libkubectl/resource_test.go +++ b/pkg/libkubectl/resource_test.go @@ -7,6 +7,7 @@ import ( ) func TestResourcesToArgsHelper(t *testing.T) { + t.Parallel() tests := []struct { name string resources []string diff --git a/pkg/liboras/dummy_manifest_test.go b/pkg/liboras/dummy_manifest_test.go index 025fa4982e..4b4f64a639 100644 --- a/pkg/liboras/dummy_manifest_test.go +++ b/pkg/liboras/dummy_manifest_test.go @@ -15,6 +15,7 @@ import ( ) func TestGenerateMinimalManifest(t *testing.T) { + t.Parallel() t.Run("creates consistent manifest", func(t *testing.T) { manifest1, bytes1, err1 := generateMinimalManifest() require.NoError(t, err1) @@ -41,6 +42,7 @@ func TestGenerateMinimalManifest(t *testing.T) { } func TestSafeDeleteTags(t *testing.T) { + t.Parallel() t.Run("handles empty tag list", func(t *testing.T) { // Test the early return path - this should not call any registry operations err := SafeDeleteTags(nil, "test-repo", []string{}) diff --git a/pkg/liboras/registry_test.go b/pkg/liboras/registry_test.go index 3aa9c96744..62f0ed2705 100644 --- a/pkg/liboras/registry_test.go +++ b/pkg/liboras/registry_test.go @@ -161,6 +161,7 @@ func TestCreateClient_AuthenticationScenarios(t *testing.T) { } func TestCreateClient_RegistryTypes(t *testing.T) { + t.Parallel() registryTypes := []struct { name string registryType portainer.RegistryType @@ -196,6 +197,7 @@ func TestCreateClient_RegistryTypes(t *testing.T) { } func TestGetRegistryTypeName(t *testing.T) { + t.Parallel() tests := []struct { registryType portainer.RegistryType expectedName string @@ -219,6 +221,7 @@ func TestGetRegistryTypeName(t *testing.T) { } func TestCreateClient_ErrorHandling(t *testing.T) { + t.Parallel() tests := []struct { name string registry portainer.Registry diff --git a/pkg/librand/rand_test.go b/pkg/librand/rand_test.go index 43f7b6dba3..4644f5e848 100644 --- a/pkg/librand/rand_test.go +++ b/pkg/librand/rand_test.go @@ -11,6 +11,7 @@ func init() { } func TestIntn(t *testing.T) { + t.Parallel() i := Intn(10) if i >= 10 || i < 0 { @@ -19,6 +20,7 @@ func TestIntn(t *testing.T) { } func TestInternalIntn(t *testing.T) { + t.Parallel() testCases := []struct { name string max int @@ -48,6 +50,7 @@ func TestInternalIntn(t *testing.T) { } func TestFloat64(t *testing.T) { + t.Parallel() f := Float64() if f >= 1 || f < 0 { @@ -56,6 +59,7 @@ func TestFloat64(t *testing.T) { } func TestInternalFloat64(t *testing.T) { + t.Parallel() testCases := []struct { name string fips bool diff --git a/pkg/libstack/compose/bind_mount_hash_test.go b/pkg/libstack/compose/bind_mount_hash_test.go index 8c501978dd..be4cca295a 100644 --- a/pkg/libstack/compose/bind_mount_hash_test.go +++ b/pkg/libstack/compose/bind_mount_hash_test.go @@ -10,6 +10,7 @@ import ( ) func TestPathHash_File(t *testing.T) { + t.Parallel() dir := t.TempDir() path := filepath.Join(dir, "file.txt") @@ -32,6 +33,7 @@ func TestPathHash_File(t *testing.T) { } func TestPathHash_Directory(t *testing.T) { + t.Parallel() dir := t.TempDir() require.NoError(t, os.WriteFile(filepath.Join(dir, "a.txt"), []byte("aaa"), 0644)) require.NoError(t, os.WriteFile(filepath.Join(dir, "b.txt"), []byte("bbb"), 0644)) @@ -59,6 +61,7 @@ func TestPathHash_Directory(t *testing.T) { } func TestAddBindMountHashLabel(t *testing.T) { + t.Parallel() dir := t.TempDir() webDir := filepath.Join(dir, "web") require.NoError(t, os.MkdirAll(webDir, 0755)) diff --git a/pkg/libstack/compose/compose_test.go b/pkg/libstack/compose/compose_test.go index bab6822792..0fba305a55 100644 --- a/pkg/libstack/compose/compose_test.go +++ b/pkg/libstack/compose/compose_test.go @@ -18,6 +18,7 @@ func checkPrerequisites(t *testing.T) { } func Test_UpAndDown(t *testing.T) { + t.Parallel() checkPrerequisites(t) deployer := compose.NewComposeDeployer() diff --git a/pkg/libstack/compose/composeplugin_windows_test.go b/pkg/libstack/compose/composeplugin_windows_test.go index 58cad33011..9ccf62b218 100644 --- a/pkg/libstack/compose/composeplugin_windows_test.go +++ b/pkg/libstack/compose/composeplugin_windows_test.go @@ -11,6 +11,7 @@ import ( ) func Test_createProject_win(t *testing.T) { + t.Parallel() dir := t.TempDir() projectName := "create-project-test" diff --git a/pkg/libstack/compose/status_integration_test.go b/pkg/libstack/compose/status_integration_test.go index 5d99fe0e98..d90651d846 100644 --- a/pkg/libstack/compose/status_integration_test.go +++ b/pkg/libstack/compose/status_integration_test.go @@ -26,6 +26,7 @@ func ensureIntegrationTest(t *testing.T) { } func TestComposeProjectStatus(t *testing.T) { + t.Parallel() ensureIntegrationTest(t) testCases := []struct { diff --git a/pkg/networking/diagnostics_test.go b/pkg/networking/diagnostics_test.go index 24963b554b..fe8bb26504 100644 --- a/pkg/networking/diagnostics_test.go +++ b/pkg/networking/diagnostics_test.go @@ -37,6 +37,7 @@ type proxyResponse struct { } func TestProbeDNSConnection(t *testing.T) { + t.Parallel() tests := []struct { name string host string @@ -74,6 +75,7 @@ func TestProbeDNSConnection(t *testing.T) { } func TestProbeTelnetConnection(t *testing.T) { + t.Parallel() tests := []struct { name string url string @@ -112,6 +114,7 @@ func TestProbeTelnetConnection(t *testing.T) { } func TestDetectProxy(t *testing.T) { + t.Parallel() fips.InitFIPS(false) tests := []struct { diff --git a/pkg/registryhttp/client_test.go b/pkg/registryhttp/client_test.go index 4ff4214e79..b6d494c9f2 100644 --- a/pkg/registryhttp/client_test.go +++ b/pkg/registryhttp/client_test.go @@ -16,6 +16,7 @@ func init() { } func TestCreateClient(t *testing.T) { + t.Parallel() tests := []struct { name string registry *portainer.Registry @@ -109,6 +110,7 @@ func TestCreateClient(t *testing.T) { } func TestCreateClient_CloudRegistries(t *testing.T) { + t.Parallel() cloudRegistryTypes := []struct { name string registryType portainer.RegistryType @@ -137,6 +139,7 @@ func TestCreateClient_CloudRegistries(t *testing.T) { } func TestCreateClient_CustomTLSConfiguration(t *testing.T) { + t.Parallel() t.Run("TLS enabled with skip verify", func(t *testing.T) { registry := &portainer.Registry{ Type: portainer.CustomRegistry, @@ -192,6 +195,7 @@ func TestCreateClient_CustomTLSConfiguration(t *testing.T) { } func TestCreateClient_TLSWithTrustedCerts_UsesDefaultClientHTTPS(t *testing.T) { + t.Parallel() registry := &portainer.Registry{ Type: portainer.CustomRegistry, URL: "my-registry.local", @@ -213,6 +217,7 @@ func TestCreateClient_TLSWithTrustedCerts_UsesDefaultClientHTTPS(t *testing.T) { } func TestCreateClient_CustomTLS_WithCertPathsMissing_ReturnsError(t *testing.T) { + t.Parallel() registry := &portainer.Registry{ Type: portainer.CustomRegistry, URL: "my-registry.local", diff --git a/pkg/retry/retry_test.go b/pkg/retry/retry_test.go index 08782d204b..fe55989a95 100644 --- a/pkg/retry/retry_test.go +++ b/pkg/retry/retry_test.go @@ -13,6 +13,7 @@ import ( ) func TestRetryTime(t *testing.T) { + t.Parallel() cases := []struct { failures int secGte int @@ -41,6 +42,7 @@ func TestRetryTime(t *testing.T) { } func TestRetryWithWarnings(t *testing.T) { + t.Parallel() // different number of retries than the default settings := Settings{ MaxRetries: 7, diff --git a/pkg/schedule/ticker_test.go b/pkg/schedule/ticker_test.go index e9f16798ae..a62377180d 100644 --- a/pkg/schedule/ticker_test.go +++ b/pkg/schedule/ticker_test.go @@ -23,6 +23,7 @@ func run(ctx context.Context, interval time.Duration, fn func(), cleanup func()) } func TestRunOnInterval_CallsFnOnTick(t *testing.T) { + t.Parallel() var calls atomic.Int32 run(t.Context(), time.Millisecond, func() { calls.Add(1) }, nil) @@ -33,6 +34,7 @@ func TestRunOnInterval_CallsFnOnTick(t *testing.T) { } func TestRunOnInterval_StopsWhenContextCancelled(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(t.Context()) cancel() @@ -46,6 +48,7 @@ func TestRunOnInterval_StopsWhenContextCancelled(t *testing.T) { } func TestRunOnInterval_CallsCleanupOnCancellation(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(t.Context()) var cleanupCalled atomic.Bool @@ -58,6 +61,7 @@ func TestRunOnInterval_CallsCleanupOnCancellation(t *testing.T) { } func TestRunOnInterval_CleanupCalledExactlyOnce(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(t.Context()) var cleanupCount atomic.Int32 @@ -72,6 +76,7 @@ func TestRunOnInterval_CleanupCalledExactlyOnce(t *testing.T) { } func TestRunOnInterval_NilCleanupDoesNotPanic(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(t.Context()) cancel() @@ -85,6 +90,7 @@ func TestRunOnInterval_NilCleanupDoesNotPanic(t *testing.T) { } func TestRunOnInterval_FnNotCalledAfterCancellation(t *testing.T) { + t.Parallel() ctx, cancel := context.WithCancel(t.Context()) cancel() diff --git a/pkg/snapshot/kubernetes_test.go b/pkg/snapshot/kubernetes_test.go index 3f6e46f53f..4c7c4505cd 100644 --- a/pkg/snapshot/kubernetes_test.go +++ b/pkg/snapshot/kubernetes_test.go @@ -17,6 +17,7 @@ import ( ) func TestKubernetesSnapshotNodes(t *testing.T) { + t.Parallel() // Create a fake client fakeClient := kfake.NewClientset() @@ -82,6 +83,7 @@ func TestKubernetesSnapshotNodes(t *testing.T) { } func TestKubernetesSnapshotNodesEmptyCluster(t *testing.T) { + t.Parallel() // Test with no nodes to verify early return behavior fakeClient := kfake.NewClientset() snapshot := &portainer.KubernetesSnapshot{} @@ -99,6 +101,7 @@ func TestKubernetesSnapshotNodesEmptyCluster(t *testing.T) { } func TestCreateKubernetesSnapshotIntegration(t *testing.T) { + t.Parallel() // Integration test to verify CreateKubernetesSnapshot calls kubernetesSnapshotNodes correctly fakeClient := kfake.NewClientset() @@ -158,6 +161,7 @@ func TestCreateKubernetesSnapshotIntegration(t *testing.T) { } func TestKubernetesSnapshotNodesWithAPIError(t *testing.T) { + t.Parallel() // Test error handling when the Kubernetes API returns an error fakeClient := kfake.NewClientset() @@ -183,6 +187,7 @@ func TestKubernetesSnapshotNodesWithAPIError(t *testing.T) { } func TestKubernetesSnapshotNodesSingleNode(t *testing.T) { + t.Parallel() // Test with a single node to verify calculations work for edge case fakeClient := kfake.NewClientset() @@ -215,6 +220,7 @@ func TestKubernetesSnapshotNodesSingleNode(t *testing.T) { } func TestKubernetesSnapshotNodesZeroResources(t *testing.T) { + t.Parallel() // Test with nodes that have zero or very small resources fakeClient := kfake.NewClientset() @@ -246,6 +252,7 @@ func TestKubernetesSnapshotNodesZeroResources(t *testing.T) { } func TestCalculateNodeMetrics(t *testing.T) { + t.Parallel() // Create a test node with specific capacity node := corev1.Node{ Status: corev1.NodeStatus{ diff --git a/pkg/validate/validate_test.go b/pkg/validate/validate_test.go index ca054190d6..c086d62a78 100644 --- a/pkg/validate/validate_test.go +++ b/pkg/validate/validate_test.go @@ -7,6 +7,7 @@ import ( ) func Test_IsURL(t *testing.T) { + t.Parallel() testCases := []struct { name string url string @@ -58,6 +59,7 @@ func Test_IsURL(t *testing.T) { } func Test_IsUUID(t *testing.T) { + t.Parallel() testCases := []struct { name string uuid string @@ -99,6 +101,7 @@ func Test_IsUUID(t *testing.T) { } func Test_IsHexadecimal(t *testing.T) { + t.Parallel() testCases := []struct { name string hex string @@ -130,6 +133,7 @@ func Test_IsHexadecimal(t *testing.T) { } func Test_HasWhitespaceOnly(t *testing.T) { + t.Parallel() testCases := []struct { name string s string @@ -171,6 +175,7 @@ func Test_HasWhitespaceOnly(t *testing.T) { } func Test_MinStringLength(t *testing.T) { + t.Parallel() testCases := []struct { name string s string @@ -218,6 +223,7 @@ func Test_MinStringLength(t *testing.T) { } func Test_Matches(t *testing.T) { + t.Parallel() testCases := []struct { name string s string @@ -247,6 +253,7 @@ func Test_Matches(t *testing.T) { } func Test_IsNonPositive(t *testing.T) { + t.Parallel() testCases := []struct { name string f float64 @@ -278,6 +285,7 @@ func Test_IsNonPositive(t *testing.T) { } func Test_InRange(t *testing.T) { + t.Parallel() testCases := []struct { name string f float64 @@ -331,6 +339,7 @@ func Test_InRange(t *testing.T) { } func Test_IsHost(t *testing.T) { + t.Parallel() testCases := []struct { name string s string @@ -367,6 +376,7 @@ func Test_IsHost(t *testing.T) { } func Test_IsIP(t *testing.T) { + t.Parallel() testCases := []struct { name string s string @@ -403,6 +413,7 @@ func Test_IsIP(t *testing.T) { } func Test_IsDNSName(t *testing.T) { + t.Parallel() testCases := []struct { name string s string @@ -439,6 +450,7 @@ func Test_IsDNSName(t *testing.T) { } func Test_IsTrustedOrigin(t *testing.T) { + t.Parallel() f := func(s string, expected bool) { t.Helper()