@@ -17,28 +17,28 @@ limitations under the License.
17
17
package batchcontrollers_test
18
18
19
19
import (
20
- "os"
20
+ // "os"
21
21
"path/filepath"
22
- "testing"
22
+ // "testing"
23
23
24
- "github.com/cortexlabs/cortex/pkg/config"
25
- "github.com/cortexlabs/cortex/pkg/consts"
26
- batch "github.com/cortexlabs/cortex/pkg/crds/apis/batch/v1alpha1"
27
- batchcontrollers "github.com/cortexlabs/cortex/pkg/crds/controllers/batch"
24
+ // "github.com/cortexlabs/cortex/pkg/config"
25
+ // "github.com/cortexlabs/cortex/pkg/consts"
26
+ // batch "github.com/cortexlabs/cortex/pkg/crds/apis/batch/v1alpha1"
27
+ // batchcontrollers "github.com/cortexlabs/cortex/pkg/crds/controllers/batch"
28
28
awslib "github.com/cortexlabs/cortex/pkg/lib/aws"
29
- "github.com/cortexlabs/cortex/pkg/lib/hash"
29
+ // "github.com/cortexlabs/cortex/pkg/lib/hash"
30
30
"github.com/cortexlabs/cortex/pkg/types/clusterconfig"
31
- "github.com/cortexlabs/cortex/pkg/types/metrics"
32
- . "github.com/onsi/ginkgo"
33
- . "github.com/onsi/gomega"
34
- "k8s.io/client-go/kubernetes/scheme"
31
+ // "github.com/cortexlabs/cortex/pkg/types/metrics"
32
+ // . "github.com/onsi/ginkgo"
33
+ // . "github.com/onsi/gomega"
34
+ // "k8s.io/client-go/kubernetes/scheme"
35
35
"k8s.io/client-go/rest"
36
- ctrl "sigs.k8s.io/controller-runtime"
36
+ // ctrl "sigs.k8s.io/controller-runtime"
37
37
"sigs.k8s.io/controller-runtime/pkg/client"
38
38
"sigs.k8s.io/controller-runtime/pkg/envtest"
39
- "sigs.k8s.io/controller-runtime/pkg/envtest/printer"
40
- logf "sigs.k8s.io/controller-runtime/pkg/log"
41
- "sigs.k8s.io/controller-runtime/pkg/log/zap"
39
+ // "sigs.k8s.io/controller-runtime/pkg/envtest/printer"
40
+ // logf "sigs.k8s.io/controller-runtime/pkg/log"
41
+ // "sigs.k8s.io/controller-runtime/pkg/log/zap"
42
42
// +kubebuilder:scaffold:imports
43
43
)
44
44
@@ -54,114 +54,114 @@ var awsClient *awslib.Client
54
54
var clusterConfig * clusterconfig.Config
55
55
var testEnv * envtest.Environment
56
56
57
- func TestAPIs (t * testing.T ) {
58
- RegisterFailHandler (Fail )
59
-
60
- RunSpecsWithDefaultAndCustomReporters (t ,
61
- "Controller Suite" ,
62
- []Reporter {printer.NewlineReporter {}})
63
- }
64
-
65
- var _ = BeforeSuite (func (done Done ) {
66
- logf .SetLogger (zap .New (zap .UseDevMode (true ), zap .WriteTo (GinkgoWriter )))
67
-
68
- crdDirectoryPath := filepath .Join (".." , ".." , "config" , "crd" , "bases" )
69
- Expect (crdDirectoryPath ).To (BeADirectory ())
70
-
71
- By ("bootstrapping test environment" )
72
- testEnv = & envtest.Environment {
73
- CRDDirectoryPaths : []string {crdDirectoryPath },
74
- }
75
-
76
- var err error
77
- cfg , err = testEnv .Start ()
78
- Expect (err ).ToNot (HaveOccurred ())
79
- Expect (cfg ).ToNot (BeNil ())
80
-
81
- err = batch .AddToScheme (scheme .Scheme )
82
- Expect (err ).NotTo (HaveOccurred ())
83
-
84
- // +kubebuilder:scaffold:scheme
85
-
86
- k8sClient , err = client .New (cfg , client.Options {Scheme : scheme .Scheme })
87
- Expect (err ).ToNot (HaveOccurred ())
88
- Expect (k8sClient ).ToNot (BeNil ())
89
-
90
- k8sManager , err := ctrl .NewManager (cfg , ctrl.Options {
91
- Scheme : scheme .Scheme ,
92
- })
93
- Expect (err ).ToNot (HaveOccurred ())
94
-
95
- clusterConfigPath := os .Getenv ("CORTEX_TEST_CLUSTER_CONFIG" )
96
- if clusterConfigPath == "" {
97
- clusterConfigPath = devClusterConfigPath
98
- }
99
-
100
- clusterConfig , err = clusterconfig .NewForFile (clusterConfigPath )
101
- Expect (err ).ToNot (HaveOccurred (),
102
- "error during cluster config creation (custom cluster " +
103
- "config paths can be set with the CORTEX_TEST_CLUSTER_CONFIG env variable)" ,
104
- )
105
-
106
- awsClient , err = awslib .NewForRegion (clusterConfig .Region )
107
- Expect (err ).ToNot (HaveOccurred ())
108
-
109
- accountID , hashedAccountID , err := awsClient .CheckCredentials ()
110
- Expect (err ).ToNot (HaveOccurred ())
111
-
112
- clusterConfig .AccountID = accountID
113
- clusterConfig .Bucket = clusterconfig .BucketName (accountID , clusterConfig .ClusterName , clusterConfig .Region )
114
-
115
- operatorMetadata := & clusterconfig.OperatorMetadata {
116
- APIVersion : consts .CortexVersion ,
117
- OperatorID : hashedAccountID ,
118
- ClusterID : hash .String (clusterConfig .ClusterName + clusterConfig .Region + hashedAccountID ),
119
- IsOperatorInCluster : false ,
120
- }
121
-
122
- // initialize some of the global values for the k8s helpers
123
- config .InitConfigs (clusterConfig , operatorMetadata )
124
-
125
- // mock certain methods of the reconciler
126
- reconcilerConfig := batchcontrollers.BatchJobReconcilerConfig {
127
- GetTotalBatchCount : func (r * batchcontrollers.BatchJobReconciler , batchJob batch.BatchJob ) (int , error ) {
128
- return 1 , nil
129
- },
130
- GetMetrics : func (r * batchcontrollers.BatchJobReconciler , batchJob batch.BatchJob ) (metrics.BatchMetrics , error ) {
131
- return metrics.BatchMetrics {Succeeded : 1 }, nil
132
- },
133
- SaveJobMetrics : func (r * batchcontrollers.BatchJobReconciler , batchJob batch.BatchJob ) error {
134
- return nil
135
- },
136
- SaveJobStatus : func (r * batchcontrollers.BatchJobReconciler , batchJob batch.BatchJob ) error {
137
- return nil
138
- },
139
- }
140
-
141
- err = (& batchcontrollers.BatchJobReconciler {
142
- Client : k8sManager .GetClient (),
143
- Config : reconcilerConfig ,
144
- Log : ctrl .Log .WithName ("controllers" ).WithName ("BatchJob" ),
145
- ClusterConfig : clusterConfig ,
146
- AWS : awsClient ,
147
- Scheme : k8sManager .GetScheme (),
148
- }).SetupWithManager (k8sManager )
149
- Expect (err ).ToNot (HaveOccurred ())
150
-
151
- go func () {
152
- defer GinkgoRecover ()
153
- err = k8sManager .Start (ctrl .SetupSignalHandler ())
154
- Expect (err ).ToNot (HaveOccurred ())
155
- }()
156
-
157
- k8sClient = k8sManager .GetClient ()
158
- Expect (k8sClient ).ToNot (BeNil ())
159
-
160
- close (done )
161
- }, 60 )
162
-
163
- var _ = AfterSuite (func () {
164
- By ("tearing down the test environment" )
165
- err := testEnv .Stop ()
166
- Expect (err ).ToNot (HaveOccurred ())
167
- })
57
+ // func TestAPIs(t *testing.T) {
58
+ // RegisterFailHandler(Fail)
59
+
60
+ // RunSpecsWithDefaultAndCustomReporters(t,
61
+ // "Controller Suite",
62
+ // []Reporter{printer.NewlineReporter{}})
63
+ // }
64
+
65
+ // var _ = BeforeSuite(func(done Done) {
66
+ // logf.SetLogger(zap.New(zap.UseDevMode(true), zap.WriteTo(GinkgoWriter)))
67
+
68
+ // crdDirectoryPath := filepath.Join("..", "..", "config", "crd", "bases")
69
+ // Expect(crdDirectoryPath).To(BeADirectory())
70
+
71
+ // By("bootstrapping test environment")
72
+ // testEnv = &envtest.Environment{
73
+ // CRDDirectoryPaths: []string{crdDirectoryPath},
74
+ // }
75
+
76
+ // var err error
77
+ // cfg, err = testEnv.Start()
78
+ // Expect(err).ToNot(HaveOccurred())
79
+ // Expect(cfg).ToNot(BeNil())
80
+
81
+ // err = batch.AddToScheme(scheme.Scheme)
82
+ // Expect(err).NotTo(HaveOccurred())
83
+
84
+ // // +kubebuilder:scaffold:scheme
85
+
86
+ // k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
87
+ // Expect(err).ToNot(HaveOccurred())
88
+ // Expect(k8sClient).ToNot(BeNil())
89
+
90
+ // k8sManager, err := ctrl.NewManager(cfg, ctrl.Options{
91
+ // Scheme: scheme.Scheme,
92
+ // })
93
+ // Expect(err).ToNot(HaveOccurred())
94
+
95
+ // clusterConfigPath := os.Getenv("CORTEX_TEST_CLUSTER_CONFIG")
96
+ // if clusterConfigPath == "" {
97
+ // clusterConfigPath = devClusterConfigPath
98
+ // }
99
+
100
+ // clusterConfig, err = clusterconfig.NewForFile(clusterConfigPath)
101
+ // Expect(err).ToNot(HaveOccurred(),
102
+ // "error during cluster config creation (custom cluster "+
103
+ // "config paths can be set with the CORTEX_TEST_CLUSTER_CONFIG env variable)",
104
+ // )
105
+
106
+ // awsClient, err = awslib.NewForRegion(clusterConfig.Region)
107
+ // Expect(err).ToNot(HaveOccurred())
108
+
109
+ // accountID, hashedAccountID, err := awsClient.CheckCredentials()
110
+ // Expect(err).ToNot(HaveOccurred())
111
+
112
+ // clusterConfig.AccountID = accountID
113
+ // clusterConfig.Bucket = clusterconfig.BucketName(accountID, clusterConfig.ClusterName, clusterConfig.Region)
114
+
115
+ // operatorMetadata := &clusterconfig.OperatorMetadata{
116
+ // APIVersion: consts.CortexVersion,
117
+ // OperatorID: hashedAccountID,
118
+ // ClusterID: hash.String(clusterConfig.ClusterName + clusterConfig.Region + hashedAccountID),
119
+ // IsOperatorInCluster: false,
120
+ // }
121
+
122
+ // // initialize some of the global values for the k8s helpers
123
+ // config.InitConfigs(clusterConfig, operatorMetadata)
124
+
125
+ // // mock certain methods of the reconciler
126
+ // reconcilerConfig := batchcontrollers.BatchJobReconcilerConfig{
127
+ // GetTotalBatchCount: func(r *batchcontrollers.BatchJobReconciler, batchJob batch.BatchJob) (int, error) {
128
+ // return 1, nil
129
+ // },
130
+ // GetMetrics: func(r *batchcontrollers.BatchJobReconciler, batchJob batch.BatchJob) (metrics.BatchMetrics, error) {
131
+ // return metrics.BatchMetrics{Succeeded: 1}, nil
132
+ // },
133
+ // SaveJobMetrics: func(r *batchcontrollers.BatchJobReconciler, batchJob batch.BatchJob) error {
134
+ // return nil
135
+ // },
136
+ // SaveJobStatus: func(r *batchcontrollers.BatchJobReconciler, batchJob batch.BatchJob) error {
137
+ // return nil
138
+ // },
139
+ // }
140
+
141
+ // err = (&batchcontrollers.BatchJobReconciler{
142
+ // Client: k8sManager.GetClient(),
143
+ // Config: reconcilerConfig,
144
+ // Log: ctrl.Log.WithName("controllers").WithName("BatchJob"),
145
+ // ClusterConfig: clusterConfig,
146
+ // AWS: awsClient,
147
+ // Scheme: k8sManager.GetScheme(),
148
+ // }).SetupWithManager(k8sManager)
149
+ // Expect(err).ToNot(HaveOccurred())
150
+
151
+ // go func() {
152
+ // defer GinkgoRecover()
153
+ // err = k8sManager.Start(ctrl.SetupSignalHandler())
154
+ // Expect(err).ToNot(HaveOccurred())
155
+ // }()
156
+
157
+ // k8sClient = k8sManager.GetClient()
158
+ // Expect(k8sClient).ToNot(BeNil())
159
+
160
+ // close(done)
161
+ // }, 60)
162
+
163
+ // var _ = AfterSuite(func() {
164
+ // By("tearing down the test environment")
165
+ // err := testEnv.Stop()
166
+ // Expect(err).ToNot(HaveOccurred())
167
+ // })
0 commit comments