@@ -32,6 +32,8 @@ import (
32
32
"github.com/sirupsen/logrus"
33
33
)
34
34
35
+ const timeout = 10 * time .Minute
36
+
35
37
// TestFramework is used to support commonly used test features
36
38
type TestFramework struct {
37
39
crioDir string
@@ -128,20 +130,39 @@ func (t *TestFramework) CrictlExpectFailureWithEndpoint(
128
130
129
131
func SetupCrio () string {
130
132
const (
131
- crioURL = "https://github.com/cri-o/cri-o"
132
- timeout = 10 * time .Minute
133
+ // TODO: update to 1.16.0 once released
134
+ crioURL = "https://github.com/cri-o/cri-o"
135
+ crioVersion = "aabfe2eb73c92dc2378b36f0fc782033d9460fda"
136
+ conmonURL = "https://github.com/containers/conmon"
137
+ conmonVersion = "v2.0.1"
133
138
)
134
139
tmpDir := filepath .Join (os .TempDir (), "crio-tmp" )
135
140
136
141
if _ , err := os .Stat (tmpDir ); os .IsNotExist (err ) {
137
142
logrus .Info ("cloning and building CRI-O" )
138
- lcmd ("git clone --depth=1 %s %s" , crioURL , tmpDir ).Wait (timeout )
139
- cmd (tmpDir , "make" ).Wait (timeout )
143
+
144
+ Expect (checkoutAndBuild (tmpDir , crioURL , crioVersion )).To (BeNil ())
145
+
146
+ conmonTmp := filepath .Join (tmpDir , "conmon" )
147
+ checkoutAndBuild (conmonTmp , conmonURL , conmonVersion )
140
148
}
141
149
142
150
return tmpDir
143
151
}
144
152
153
+ func checkoutAndBuild (dir , url , rev string ) error {
154
+ // A much faster approach than just cloning the whole repository
155
+ if err := os .MkdirAll (dir , 0755 ); err != nil {
156
+ return err
157
+ }
158
+ cmd (dir , "git init" ).Wait (timeout )
159
+ cmd (dir , "git remote add origin %s" , url ).Wait (timeout )
160
+ cmd (dir , "git fetch --depth=1 origin %s" , rev ).Wait (timeout )
161
+ cmd (dir , "git checkout -f FETCH_HEAD" ).Wait (timeout )
162
+ cmd (dir , "make" ).Wait (timeout )
163
+ return nil
164
+ }
165
+
145
166
// Start the container runtime process
146
167
func (t * TestFramework ) StartCrio () (string , string , * Session ) {
147
168
// Create a new sandbox directory
@@ -179,7 +200,7 @@ func (t *TestFramework) StartCrio() (string, string, *Session) {
179
200
" --storage-driver=vfs" ,
180
201
filepath .Join (tmpDir , "bin" , "crio" ),
181
202
endpoint ,
182
- filepath .Join (tmpDir , "bin" , "conmon" ),
203
+ filepath .Join (t . crioDir , "conmon" , "bin" , "conmon" ),
183
204
filepath .Join (tmpDir , "exits" ),
184
205
filepath .Join (tmpDir , "attach" ),
185
206
filepath .Join (tmpDir , "log" ),
0 commit comments