github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/store/redis/deploy_test.go (about)

     1  package redis
     2  
     3  import (
     4  	"context"
     5  	"path/filepath"
     6  
     7  	"github.com/projecteru2/core/types"
     8  )
     9  
    10  func (s *RediaronTestSuite) TestDeploy() {
    11  	ctx := context.Background()
    12  	opts := &types.DeployOptions{
    13  		Name:         "app",
    14  		Entrypoint:   &types.Entrypoint{Name: "entry"},
    15  		ProcessIdent: "abc",
    16  		NodeFilter:   &types.NodeFilter{},
    17  	}
    18  
    19  	// no workload deployed
    20  	nodeCount, err := s.rediaron.GetDeployStatus(ctx, opts.Name, opts.Entrypoint.Name)
    21  	s.NoError(err)
    22  	s.Equal(len(nodeCount), 0)
    23  	// have workloads
    24  	key := filepath.Join(workloadDeployPrefix, opts.Name, opts.Entrypoint.Name, "node", "id1")
    25  	_, err = s.rediaron.cli.Set(ctx, key, "", 0).Result()
    26  	s.NoError(err)
    27  	key = filepath.Join(workloadDeployPrefix, opts.Name, opts.Entrypoint.Name, "node", "id2")
    28  	s.NoError(err)
    29  	_, err = s.rediaron.cli.Set(ctx, key, "", 0).Result()
    30  	s.NoError(err)
    31  	nodeCount, err = s.rediaron.GetDeployStatus(ctx, opts.Name, opts.Entrypoint.Name)
    32  	s.NoError(err)
    33  	s.Equal(nodeCount["node"], 2)
    34  }